OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wanting advice on finding out the root element in a w3c schema



There is no way to determine the root element of a document from
a W3C XML Schema schema.

Any element definition in an XML schema (not being a local one) 
could be used as the top level of an element (or the top-level of 
a branch of that namespace.)

You can find possible tops of branches.  But wildcards and other recursion
needed to be coped with too.

If you want to specify the root element of a document, you can use a 
Schematron schema like the following:
<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern>
          <rule context = "/*">
               <assert test = "/myelement">Root element should be "myelement".</assert>
          </rule>
     </pattern>
</schema>

You can also specify that some elements may not appear except as children
of the same namespace.

     <pattern>
          <rule context = "ns1:e1 | ns1:e2 | ns1:e3 ">
               <assert test = "../ns1:*">e1, e2, and e3 must appear as children of 
              an element in the same namespace.</assert>
          </rule>
     </pattern>

Cheers
Rick Jelliffe