Lists Home |
Date Index |
W3C XML Schema based typing can handle the situation fine. I can query all comment types from that example using XSLT 2.0/XPath 2.0 or XQuery. The query
//*[. instance of element ipo:comment]
should return all comments that have ipo:comment as the head of their substitution group. The syntax is acknowledgeably quite verbose and I've heard that some people have petitioned the working group to create a shorthand syntax.
From: Alaric B. Snell [mailto:email@example.com]
Sent: Fri 12/6/2002 7:01 AM
To: Joe English; firstname.lastname@example.org
Subject: Re: [xml-dev] bohemians, gentry
On Thursday 05 December 2002 20:14, Joe English wrote:
> It seems to me that the "International Purchase Order" schema
> in section 4 of the W3C XML Schema Primer  comes close to the
> edge of that slippery slope. While _most_ of it can be processed
> by WXS-oblivious tools, there are some tasks that can't be done
> (or can't be done easily) without a type-annotated PSVI and full
> schema information. For instance: write a program that extracts
> all of the comments from a purchase order (see the schema fragment
> in section 4.6), Now you could do this with an XSL transform that
> extracted all the 'ipo:shipComment' and 'ipo:customerComment'
> elements (since those are the only two elements defined to
> be of that type), but that's fragile; if the schema is extended
> to include other comment types, the transform will silently
That's an argument *for* typing - but not done the way XSD does it!
Those two elements (shipComment and customerComment) are both comments,
typewise. They may be other types too in a type system with inheritance, of
course, such as 'text in language associated by nearest xml:lang' and
'string' and so on.
Now, with type information you *can* extract all the comments, no matter what
they are called. XSD might have you get that type information by referencing
the XSD itself or with xsi:type, whereas the alternative is to make a
convention that element names are type names and make sure that all comments
are in elements called <comment> and all titles in <title> and so on.
The latter approach has problems when you want two different comments in the
same element, though; by using the names of the children as types you remove
the ability to give them names expressing their relationship to the parent.
There's something to be said for mechanisms like xsi:type that attach the
typing as explicit metadata, but without requiring the loading and processing
(according to complex rules) of a schema, in those cases...
A city is like a large, complex, rabbit
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>
The list archives are at http://lists.xml.org/archives/xml-dev/
To subscribe or unsubscribe from this list use the subscription