[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
- From: Rick Jelliffe <email@example.com>
- To: firstname.lastname@example.org
- Date: Thu, 30 Aug 2001 15:25:05 +1000
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" >
<rule context = "/*">
<assert test = "/myelement">Root element should be "myelement".</assert>
You can also specify that some elements may not appear except as children
of the same namespace.
<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>