Re: XPath validation against a schema rather that against an
Actually, owing to the possibility of wildcards, substitutions and derived types outside a given schema, you cannot even do the particular test mentioned below. In schema for namespace A, we define element ea, which does not forbid itself from being the head of a substitution group. In schema for namespace B, we define element eb which declares itself to be in the substitution group headed by A:ea (satisfying the appropriate conditions on the types of eb and ea). Then in an instance conforming to schema A, we might find B:eb where A:ea is declared to occur. Checking the xpath //B:eb against schema A will not be very useful. Validating against schema B would be better, but would be non-trivial. Given a document with a root of A:x, you're not always going to know which of the other namespaces it declares is the right one to validate some xpath against. If schema A declares type ta and schema B extends this type by adding the element foo and calling the type tb, then an instance document conforming to a type ta can actually contain the content of tb, and hence a foo element. Of course, the moment wildcards (types, elements or attributes) are used, an xpath that descends into the subtree of the document replacing the wildcard can contain anything (subject to the namespace constraints). Jeff ----- Original Message ----- From: "Sean McGrath" <sean.mcgrath@p...> To: <xml-dev@l...> Sent: Monday, January 13, 2003 11:47 PM Subject: XPath validation against a schema rather that against an instance > Heres a question I was asked today which struck me: > > >Is there any way I can validate a XPATH against a XML Schema (and not > >against the XML document) > > I don't know of anything like this. I can see why it would be a useful static > sanity check of XPath usage in some contexts. I.e. "warning: //foo can never > match in schema XXX because there is no 'foo'".
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