<?xml version="1.0" encoding="UTF-8"?>
<!--
  xmldsig-allowAnyForeign.rnc
  
  This schema is expected to be used together with xmldsig-core-schema.rnc.
  
  This schema mimicks <any ../> in xmldsig-core-schema.xsd.  
  When namespace="##other", any foreign element is allowed.
  When namespace="##any", any foreign element as well as 
  any element valid against xmldsig-core-schema.xsd is allowed.
  
  A schema author might want to create a dedicated schema 
  for a collection of particular algorithms rather than 
  using this schema.
  
  The driver schema (for example, any any-containing-xmldsig.rnc) is 
  expected to define CanonicalizationAlgorithms, SignatureAlgorithms, 
  TransformAlgorithms, and DigestAlgorithms as choices of known 
  values of the Algorithm attribute.
-->
<grammar ns="http://www.w3.org/2000/09/xmldsig#" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <define name="ds_CanonicalizationMethodType" combine="choice">
    <attribute name="Algorithm">
      <data type="anyURI">
        <except>
          <ref name="ds_CanonicalizationAlgorithms"/>
        </except>
      </data>
    </attribute>
    <zeroOrMore>
      <choice>
        <ref name="ds_anyForeignElement"/>
        <ref name="ds_anyDsElement"/>
      </choice>
    </zeroOrMore>
  </define>
  <define name="ds_SignatureMethodType" combine="choice">
    <attribute name="Algorithm">
      <data type="anyURI">
        <except>
          <ref name="ds_SignatureAlgorithms"/>
        </except>
      </data>
    </attribute>
    <optional>
      <!--
        It is allowed to use an HMACOutputLength element even when
        the agorithm is not "http://www.w3.org/2000/09/xmldsig#hmac-sha1"
      -->
      <element name="HMACOutputLength">
        <ref name="ds_HMACOutputLengthType"/>
      </element>
    </optional>
    <zeroOrMore>
      <ref name="ds_anyForeignElement"/>
    </zeroOrMore>
  </define>
  <define name="ds_TransformType" combine="choice">
    <attribute name="Algorithm">
      <data type="anyURI">
        <except>
          <ref name="ds_CanonicalizationAlgorithms"/>
          <ref name="ds_TransformAlgorithms"/>
        </except>
      </data>
    </attribute>
    <zeroOrMore>
      <!--
        It is allowed to use XPath elements even when
        the algorithm is not "http://www.w3.org/TR/1999/REC-xpath-19991116"
      -->
      <choice>
        <ref name="ds_anyForeignElement"/>
        <element name="XPath">
          <data type="string"/>
        </element>
      </choice>
    </zeroOrMore>
  </define>
  <define name="ds_DigestMethodType" combine="choice">
    <attribute name="Algorithm">
      <data type="anyURI">
        <except>
          <ref name="ds_DigestAlgorithms"/>
        </except>
      </data>
    </attribute>
    <zeroOrMore>
      <ref name="ds_anyForeignElement"/>
    </zeroOrMore>
  </define>
  <define name="ds_KeyInfoChild" combine="choice">
    <ref name="ds_anyForeignElement"/>
  </define>
  <define name="ds_KeyValueType" combine="choice">
    <ref name="ds_anyForeignElement"/>
  </define>
  <define name="ds_X509DataForeignChild" combine="choice">
    <ref name="ds_anyForeignElement"/>
  </define>
  <define name="ds_SPKIDataForeignChild" combine="choice">
    <ref name="ds_anyForeignElement"/>
  </define>
  <define name="ds_ObjectChild" combine="choice">
    <ref name="ds_anyForeignElement"/>
  </define>
  <define name="ds_SignaturePropertyChild" combine="choice">
    <ref name="ds_anyForeignElement"/>
  </define>
  <define name="ds_PGPDataForeignChild" combine="choice">
    <ref name="ds_anyForeignElement"/>
  </define>
</grammar>
