Re: ASN.1 => XML Schema questions

Hello Geoff,

At 08:18 01/06/27 +1000, Geoff Elgey wrote:
>I do not see why a repetition of <all> could not be parsed correctly, as
>well as including the necessary type and schema information.
>
>For example:
>
><complexType name="T">
><all minOccurs="0" maxOccurs="unbounded">
>     <element name="x" type="integer"/>
>     <element name="y" type="integer"/>
>     <element name="z" type="integer" minOccurs="0"/>
></all>
></complexType>
>
>So given the following input:
>
><T><x>1</x><y>2</y><z>3</z><z>1</z><y>2</y><x>3</x><y>1</y><x>2</x><y>1</y> 
><z>2</z></T>

This is a benign example. Just change it to:

<T><x>1</x><y>2</y><z>3</z><y>2</y><x>3</x><y>1</y><x>2</x><y>1</y><z>2</z></T>

Now, does this parse as:

>complexType: T
>content: list
>    item 1 = <x>1</x><y>2</y><z>3</z>
>    item 2 = <y>2</y><x>3</x>
>    item 3 = <y>1</y><x>2</x>
>    item 4 = <y>1</y><z>2</z> <== error: missing element 'x'

or as:

>complexType: T
>content: list
>    item 1 = <x>1</x><y>2</y>
>    item 2 = <z>3</z><y>2</y><x>3</x>
>    item 3 = <y>1</y><x>2</x>
>    item 4 = <y>1</y><z>2</z> <== error: missing element 'x'

No way to decide, I guess.

>I'm sure such reasoning applies to other repetition types as well -- how
>does XML Schema handle an unbounded sequence containing a single
>element, which is itself unbounded? Is it {x*} or {x}* ?

I think there is an implicit understanding that in some cases,
nobody will actually care, and everybody will understand that
you won't, and can't, care. The problem is just that these
cases are not explicit, and that because others have been
made explicit, it is confusing.



> > > So your options are either
> > >
> > > - stick to W3C XML Schema and make a compromise by using (a|b)* rather
> > >   than (ab|ba)*.

I'm confused. Is (ab|ba)* really what what was needed?
This is completely deterministic, as far as I understand.
It therefore should be allowed in DTDs, and if it doesn't
work in Schemas, that would be a big problem.



>I've already got a schema language (ASN.1) that I want to translate to
>XML Schema -- the main sticking point is collections of SET (ie <all>)
>without requiring the definition of additional named complex types.
>
>I've seen proposals that translate the ASN.1 type "SEQUENCE OF T" to the
>following XML Schema:
>
><complexType>
><sequence>
>   <element name="Item" type="T" minOccurs="0" maxOccurs="unbounded"/>
></sequence>
></complexType>
>
>ie "<Item><T>...</T></Item><Item><T>...</T></Item>"
>
>Which can lead to name conflicts, especially if there is more than one
>SEQUENCE OF ... definition.

Well, yes, you have to create a separate element name for each
"Sequence of" construct. Is that so difficult?


>Replacing that ugly set-up with <all minOccurs="0"
>maxOccurs="unbounded"> would solve these problems, IMHO. The problem is
>that XML Schema will not allow it. If there are good theoretical reasons
>why, then I'll try another solution or stick with the ugly,
>counter-intuitive method already proposed.

XML Schemas could allow it if all the elements in the <all>
group have minOccurs=maxOccurs=1, without much influence on
implementations. But that would produce a very special case
in the spec. If minOccurs=0 is allowed, then implementations
get quite a bit more complex (although greadily eating up as
many of the minOccurs=0 as possible still can make sure that
computation is fast).

It would be good to know exactly what ASN.1 allows, and
what not (maybe that has already been said, and I missed it).


Regards,   Martin.

Received on Wednesday, 27 June 2001 01:25:39 UTC