Problems about the Spectrum Data Model from the view of a Web Service programmer

Gerard gerard.lemson at mpe.mpg.de
Fri Sep 15 04:43:55 PDT 2006


Hi Alasdair
> > I think irrespective of this, we might in the IVOA attempt to not
> > use mixed
> > content in serialisations of data and metadata simply beacues of
> > examples as
> > Alasdair mentions.
> 
> Actually I was arguing precisely the opposite point, I don't really
> see anything wrong with mixed content.
In understood you were arguing the opposite. I gave reasons why I prefer no
mixed content.

> 
> > We can do without and it will be much simpler to
> > transform between different representations (code, databasesof a given
> > underlying model if every data element is explcitily named.
> 
> Every data element is explicitly named in both examples I gave you.
> 
> > Mixed content will allow things that are hard to make sense of in an
> > automated fashion, like
> >
> > <tag1>34<tag2>35</tag2>36<tag3>hello</tag3>76</tag1>
> 
> Err, no that's easier to make sense of in an automated fashion than
> it is to read, although re-arranging your example into a more human
> parsable version,  it's perfectly easy to understand as well...
> 
> <tag1>
>     34 36 76
>    <tag2>35</tag2>
>    <tag3>hello</tag3>
> </tag1>

This is harder (not hard, harder) to parse than the form I would prefer

<tag1>
    <tag1b>34</tag1b>
    <tag1b>36</tag1b>
    <tag1b>76</tag1b>
   <tag2>35</tag2>
   <tag3>hello</tag3>
</tag1>

This is more explicit (in my opinion) and more easily generalizable to other
types. Does not require extra parsing of the contents of the <tag1> element
over pure XML "element finding". 

> 
> In other words,
> 
> 	tag1 		= [ 34, 36, 76 ]
> 	tag1.tag2 	= 35
> 	tag1.tag3 	= hello
> 
> > Such mixed content is fine fore (X)HTML documents, but imho should be
> > avoided if possible for serialisations that are to be read by
> > machines.
> 
> Why? I don't understand why you'd find the above ambiguous?
> 
I gave some other reasons, for example mapping to other representations
which in general benefits from explicit naming as deep down as possible. XML
allows very many different ways of expressing the same thing. I prefer
trying to stick to a single choice where possible.

Btw, I have a question that may reflect my incomplete understanding of XML
schema. How would you declare a complexType that allows elements of the form


> <tag1>
>     34 36 76
>    <tag2>35</tag2>
>    <tag3>hello</tag3>
> </tag1>

I tried 

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

<xsd:complexType name="TagOne" mixed="true">
  <xsd:complexContent>
    <xsd:extension base="xsd:int">
      <xsd:sequence>
        <xsd:element name="tageTwo" type="xsd:int"/>
        <xsd:element name="tageThree" type="xsd:int"/>
      </xsd:sequence>
    </xsd:extension>
  </xsd:complexContent>
</xsd:complexType>

<xsd:element name="tagOne" type="tns:TagOne"/>

</xsd:schema>

But this is illegal, the validator telling me that a complexType can not
extend a simpleType. The following works, 

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

<xsd:complexType name="TagOne" mixed="true">
  <xsd:sequence>
    <xsd:element name="tagTwo" type="xsd:int"/>
    <xsd:element name="tagThree" type="xsd:int"/>
  </xsd:sequence>
</xsd:complexType>

<xsd:element name="tagOne" type="tns:TagOne"/>

</xsd:schema>

But clearly is not declaring the type of the mixed content.
My preferred form of the document would be declared by 

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

<xsd:complexType name="TagOne" mixed="true">
  <xsd:sequence>
    <xsd:element name="tag1b" type="xsd:int" minOccurs="0" 
           maxOccurs="unlimited">
    <xsd:element name="tagTwo" type="xsd:int"/>
    <xsd:element name="tagThree" type="xsd:int"/>
  </xsd:sequence>
</xsd:complexType>

<xsd:element name="tagOne" type="tns:TagOne"/>

</xsd:schema>

This is clearly explicit in the type of the content.
But I'd be interested of finding the appropriate way of declaring the
equivalknt for your representation.

Gerard

> Al.



More information about the dm mailing list