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

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: [relax-ng-comment] Are sequences and interleaves overloaded?


I've been going around and around this maypole on the xml-dev and
xmlSchema-dev lists for a couple of weeks, so I figure it's time to torture
RELAX NG people with this:

I've got a content model, unordered, which I wish to interleave with ANY
elements of ANY other content model. I can't seem to do this in either XML
Schema or RELAX NG without having to explicitly interleave the unordered
elements between each and every element in each and every content model. For
example, in XML Schema, a definition such as this works:

<?xml version="1.0" encoding="UTF-8"?>
<schema  
	xmlns="http://www.w3.org/2001/XMLSchema" 
	xmlns:g="http://www.example.com/g"
	targetNamespace="http://www.example.com/g"
	elementFormDefault="qualified"
>
	<group name="ABC">
		<choice>
			<element name="A" minOccurs="0"
maxOccurs="unbounded"/>
			<element name="B"  minOccurs="0"
maxOccurs="unbounded"/>
			<element name="C" minOccurs="0"
maxOccurs="unbounded"/>
			<any namespace="##other" processContents="lax"/>
		</choice>
	</group>

	<complexType name="foo">
		<sequence>
			<group ref="g:ABC" maxOccurs="unbounded"/>
			<element name="x"/>
			<group ref="g:ABC" maxOccurs="unbounded"/>
			<element name="y"/>
			<group ref="g:ABC" maxOccurs="unbounded"/>
			<element name="z"/>
			<group ref="g:ABC" maxOccurs="unbounded"/>
		</sequence>
	</complexType>

	<element name="foos">
		<complexType>
			<sequence>
				<element name="foo" type="g:foo"
maxOccurs="unbounded"/>
			</sequence>
		</complexType>
	</element>
</schema>


Notice that foo has to have group refs between each element. I don't think
RELAX NG does any better here, assuming that I want to maintain the ordering
of x,y,z children in the foo element.

To my mind, the basic problem here that both RELAX NG and XML Schema share
is that both languages convolute the concept of "order" and "contiguity" in
the term "sequence". Conversely, while XML Schema views <all> content models
as unordered yet contiguous, RELAX NG choses to see interleaved content
models as unordered and discontiguous (yet maintaining contiguity and order
of sequence components within interleaved content models). [I'm basing my
understanding of RELAX NG on the tutorial, not the spec, so I may not be
fully cognizant of the capabilities of RELAX NG].

The point I'm getting to is why not separate out the notion of order from
that of contiguity? For example, why not have content models of <ordered>
and <unordered>, with attributes of "contiguous" and "discontiguous"?  That
way, the above schema could be written as such (apologies that it's XML
Schema syntax and not RELAX NG, but the ideas apply to both):


<?xml version="1.0" encoding="UTF-8"?>
<schema  
	xmlns="http://www.w3.org/2001/XMLSchema" 
	xmlns:g="http://www.example.com/g"
	targetNamespace="http://www.example.com/g"
	elementFormDefault="qualified"
>

	<group name="ABC">
		<unordered contiguous="false">
			<element name="A" minOccurs="0"
maxOccurs="unbounded"/>
			<element name="B"  minOccurs="0"
maxOccurs="unbounded"/>
			<element name="C" minOccurs="0"
maxOccurs="unbounded"/>
			<any namespace="##other" processContents="lax"/>
		</unordered>
	</group>

	<complexType name="foo">
		<unordered contiguous="true">
			<ordered contiguous="false">
				<element name="x"/>
				<element name="y"/>
				<element name="z"/>
			</ordered>
			<group ref="g:ABC" maxOccurs="unbounded"/>
		</unordered>
	</complexType>

	<element name="foos">
		<complexType>
			<ordered> <!-- contiguous="true" by default -->
				<element name="foo" type="g:foo"
maxOccurs="unbounded"/>
			</ordered>
		</complexType>
	</element>
</schema>

Note that the conguity/discontiguity concept could also apply to element
declarations with cardinality >1, probably by adding and attribute:

	<element name="foo" type="g:foo" maxOccurs="unbounded"
contiguous="true"/>

I can't be the first one who's suggested this, so there must be something
terribly naive in this concept somewhere, or the capability is actually
supported by RELAX NG in some other fashion.

Later,
Jeff



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC