[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: an elements schema context via xslt

Subject: RE: an elements schema context via xslt
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 30 Jun 2005 23:58:37 +0100
element schema
> I wonder if it is possible (with a reasonable amount of code) to find
> out (given a xml document, the xpath to an element in this doc and the
> schema (xsd) document upon which the document is/was created), to find
> out which are the possible child- (and sibling- and attribute-)
> elements for the given element - using xslt.

If you read the schema spec, you will see that there's a significant amount
of work a schema processor has to do to build a schema (= a set of type
definitions) from a schema document (an xs:schema element in a source XML
document). You don't want to try writing this code yourself in XSLT. For
example, you would have to analyze model groups, attribute groups, and
substitition groups, all recursively, you would have to understand schema
imports and namespaces, wildcards, subtypes derived by extension, and a host
of other things.

(Incidentally, some schema-aware XML editors clearly don't do this very
well.)

Your better bet is to access a compiled schema using extension functions. It
shouldn't be too difficult to do this using Saxon-SA.

Also, having a path expression that identifies an element doesn't make it
especially easy to work out which element declaration or type definition is
applicable to that element. A schema-aware processor will validate the
source document and annotate each node with a reference to the schema type
that was used to validate it: with some use of extension functions, you can
get from this type annotation to the definition of the schema type in the
compiled schema, and from this to the list of permitted children.

Michael Kay
http://www.saxonica.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.