<!--
    Copyright (C) 2004 Orbeon, Inc.

    This program is free software; you can redistribute it and/or modify it under the terms of the
    GNU Lesser General Public License as published by the Free Software Foundation; either version
    2.1 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Lesser General Public License for more details.

    The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
-->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
    datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

    <start>
        <element name="config">
            <choice>
                <!-- URL is directly under the config element -->
                <data type="string"/>
                <interleave>
                    <element name="url">
                        <data type="string"/>
                    </element>
                    <optional>
                        <element name="content-type">
                            <data type="string">
                                <!-- See: http://www.faqs.org/rfcs/rfc2045.html -->
                                <param name="pattern">[\p{IsBasicLatin}-[&#09;- ()&lt;>@,;:\\"/\[\]=?]]+/[\p{IsBasicLatin}-[&#09;- ()&lt;>@,;:\\"/\[\]=?]]+</param>
                            </data>
                        </element>
                    </optional>
                    <optional>
                        <!-- This must be set to true only if a content-type was set manually -->
                        <element name="force-content-type">
                            <choice>
                                <value>true</value>
                                <value>false</value>
                            </choice>
                        </element>
                    </optional>
                    <optional>
                        <element name="encoding">
                            <text/>
                        </element>
                    </optional>
                    <optional>
                        <!-- This must be set to true only if an encoding was set manually -->
                        <element name="force-encoding">
                            <choice>
                                <value>true</value>
                                <value>false</value>
                            </choice>
                        </element>
                    </optional>
                    <optional>
                        <element name="ignore-connection-encoding">
                            <choice>
                                <value>true</value>
                                <value>false</value>
                            </choice>
                        </element>
                    </optional>
                    <optional>
                        <!-- This will make sense only if the source is XML -->
                        <element name="validating">
                            <data type="boolean"/>
                        </element>
                    </optional>
                    <optional>
                        <!-- This will make sense only if the source is XML -->
                        <element name="handle-xinclude">
                            <data type="boolean"/>
                        </element>
                    </optional>
                    <optional>
                        <!-- This will make sense only if the source is XML -->
                        <element name="external-entities">
                            <data type="boolean"/>
                        </element>
                    </optional>
                    <optional>
                        <!-- This will make sense only if the source is XML -->
                        <element name="handle-lexical">
                            <data type="boolean"/>
                        </element>
                    </optional>
                    <optional>
                        <element name="mode">
                            <choice>
                                <value>html</value>
                                <value>xml</value>
                                <value>text</value>
                                <value>binary</value>
                            </choice>
                        </element>
                    </optional>
                    <zeroOrMore>
                        <element name="header">
                            <element name="name">
                                <data type="string"/>
                            </element>
                            <element name="value">
                                <data type="string"/>
                            </element>
                        </element>
                    </zeroOrMore>
                    <optional>
                        <element name="forward-headers">
                            <text/>
                        </element>
                    </optional>
                    <optional>
                        <element name="cache-control">
                            <interleave>
                                <optional>
                                    <element name="use-local-cache">
                                        <choice>
                                            <value>true</value>
                                            <value>false</value>
                                        </choice>
                                    </element>
                                </optional>
                                <optional>
                                    <element name="conditional-get">
                                        <choice>
                                            <value>true</value>
                                            <value>false</value>
                                        </choice>
                                    </element>
                                </optional>
                            </interleave>
                        </element>
                    </optional>
                    <zeroOrMore>
                        <element name="read-header">
                            <data type="string"/>
                        </element>
                    </zeroOrMore>
                    <optional>
                        <!-- This will make sense only if the source is text/html -->
                        <element name="tidy-options">
                            <interleave>
                                <optional>
                                    <element name="show-warnings">
                                        <choice>
                                            <value>true</value>
                                            <value>false</value>
                                        </choice>
                                    </element>
                                    <optional>
                                        <element name="quiet">
                                            <choice>
                                                <value>true</value>
                                                <value>false</value>
                                            </choice>
                                        </element>
                                    </optional>
                                </optional>
                            </interleave>
                        </element>
                    </optional>
                    <optional>
                        <element name="authentication">
                            <interleave>
                                <element name="username">
                                    <data type="string"/>
                                </element>
                                <optional>
                                    <element name="password">
                                        <data type="string"/>
                                    </element>
                                </optional>
                                <optional>
                                    <element name="domain">
                                        <data type="string"/>
                                    </element>
                                </optional>
                                <optional>
                                    <element name="preemptive">
                                        <choice>
                                            <value>true</value>
                                            <value>false</value>
                                        </choice>
                                    </element>
                                </optional>
                            </interleave>
                        </element>
                    </optional>

                </interleave>
            </choice>
        </element>
    </start>

</grammar>
