|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








