OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Can XML Schemas do this?

[ Lists Home | Date Index | Thread Index ]

Eric van der Vlist scripsit:

> I think that the additional complexity is overstated. SAX is my favorite
> XML API and I find it much more robust (and only slightly more complex)
> to never rely on the relative order of children elements. In the
> frequent case where I want to build an object out of an element, I use
> to create the object and assign the properties given as attributes on a
> start element, assign properties independently for each child element
> and do final tests and operations on end element. 

But this is not true streaming: you are using SAX in order to create
your application-specific ?OM.  Where you do not have the capacity or the
need to represent the document as a clump of objects, having a prescribed
ordering can be quite useful.

In one application, I have to process a stream of elements that look
like this:

	<subject>
		<type>some-identifier</type>
		<code>some-other-identifier</code>
		<value>some human readable string</value>
	</subject>

Declaratively speaking, a subject has a type, a code, and a value.  But by
relying on the order, I can dispatch to separate handlers depending on
the value of the type element, which can then pick up the value of the
code and (if desired) the value of the value elements.  If they could
occur in any order, I would have to buffer up the (possibly long) value
element until I knew what, if anything, to do with it.

Furthermore, if I extended the value element to contain child elements
(as might be plausible for i18n purposes such as ruby or directionality),
I would have to provide a DOM-like representation of them, whereas with
my present design I can just let the code handler capture the SAX events
for the child elements directly.

> Out of context, no (sorry for that). This snippet came from a section
> giving hints to write extensible Relax NG schemas and if this is
> important for you, I think that using "interleave" is really a thing to
> do.

I agree in that case, but really because RNG has no means of doing
group-style redefinition, only choice-style and interleave-style.
(The reason for this is that if a definition were group-redefined twice,
the order of application would be unclear, since RNG definitions are
inherently unordered.)

-- 
John Cowan   jcowan@reutershealth.com  http://www.ccil.org/~cowan
Most languages are dramatically underdescribed, and at least one is 
dramatically overdescribed.  Still other languages are simultaneously 
overdescribed and underdescribed.  Welsh pertains to the third category.
        --Alan King




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS