W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > January to March 2000

two problems

From: Stefan Haustein <stefan.haustein@trantor.de>
Date: Sun, 30 Jan 2000 21:31:27 +0100
Message-ID: <38949F9F.8660C4E4@trantor.de>
To: xml-schema-comments <www-xml-schema-comments@w3c.org>

I am currently implementing an XML schema parser. My main problem is
that data types and types are referenced using the same attribute
"type": If I encouter a forward reference to a type definition, I create
a reference to an empty type definition object. The type definiton
object is filled later when the parser reads the real definiton. But I
am not sure if forward references to datatypes are allowed, too. If so,
I would need to handle the forward referenced much more complicated
since datatype and type definitions are different objects -- I would not
know which one to create. 

Also, having a type and separate datatype could solve a problem
described by Roger Costello in XML dev, see below.

My second problem is the content model (in general). A posting from Nils
Klarlund in XML-DEV shows a solution that seems very nice. I appended
his quoted message, too.

Best regards 


Roger Costello wrote:
> Hi Folks,
> I have created an XML Schema document for juice machines. Part of the
> description of each juice machine is its cost. One of the first things
> that I did is create a money datatype:
>     <datatype name="money" source="decimal">
>         <scale value="2"/>
>     </datatype>
> Then, I declared the cost element to be of type money:
>     <element name="cost" type="money"/>
> Seems reasonable, right?  Well, the next thing that I wanted to do was
> to add an attribute - currency - to the cost element.  This is where I
> ran into problems.  Attributes are typically declared like this:
>     <element name="cost">
>         <type>
>             <attribute name="currency" type="string" minOccurs="1"/>
>         <type>
>     </element>
> This declares currency to be a required attribute of cost.  However, in
> adding this attribute, we have lost our nice typing of cost to money
> (i.e., cost of datatype money).
> Unless I am missing something obvious (which may well be the case),
> there is no way to specify a datatype for an element as well as assign
> attributes to it ...  I must not be thinking clearly.  Can someone tell
> me how to assign cost the datatype money as well as giving it the
> attribute currency?  To provide more context to my question, I have
> included below the complete XML Schema which I am trying to enhance to
> give cost the attribute currency.  /Roger

Nils Klarlund wrote:
> I am not qualified to comment on SGML itself, but even XML 1.0 does
> appear to be suffering from over-conceptualization (too many concepts
> that don't fit together too precisely).  As a simple example, look at
> content models:
> - a content model is not a model for content in general, but only two
>   kinds of content, namely elements and character data, not processing
>   instructions and not comments (incidentally, it could have been
>   termed "markup model" as well I think, since markup is a more
>   general concept than content)
> - the content model concept is further split into two concepts:
>   (1) element content, which allows only elements in content
>   (2) mixed content, which allows character data interspersed
>       with elements
> Thus, there are now two similar sets of syntax and regular expressions
> for describing not content, but the projection of content onto
> elements and character data.
> An alternative approach would have declared "content" to simply
> consist of just element nodes and text nodes ("text nodes" as in
> XPATH) representing character data.  Then there would be no need for
> (2), since a content model now describes a regular language over the
> alphabet consisting of what you would expect: element names and the
> token text() (or #PCDATA).  And, you'd be able to describe, say, HTML
> with Appendix elements that must appear at the end:
>   ((#PCDATA | H1 | H2 |...)*, Appendix*)
> So, the distinction between element content and mixed content is a
> needless one that both restricts what can be expressed and that
> muddles the conceptual framework.  (The way of treating content just
> outlined is what we chose for the DSD schema notation, incidentally.)
> XPATH with its tree model goes a far way in clearing up things; so
> does DOM2, but the crown unifying these not-quite-compatible models is
> missing.
> /Nils
Received on Sunday, 30 January 2000 15:28:45 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:49:52 UTC