xsl-list
[Top] [All Lists]

Re: DTD to Scheme

2005-02-02 01:43:30

Yes, yes, I know.
But this mailing list was the first shot from google and I needed that really quick.
Thanks to all, guys.

Stano.


Michael Kay wrote:

You're on the wrong list for XML Schema questions - the right place is
xmlschema-dev(_at_)w3(_dot_)org(_dot_)

But the answer is that you can express this model without violating UPA. In
shorthand, you write it as

((waiting,passing?)|passing)

Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Stano Paska [mailto:paska(_at_)kios(_dot_)sk] Sent: 02 February 2005 05:23
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] DTD to Scheme

Hi,

I need rewrite som DTD into XML Schema.
I have problem with one part.
In element "item" there may be three combinations of waiting/passing
elements:
one waiting, one passing, or both.

In DTD it is easy and it works:
<!ELEMENT item (risid,(waiting|passing|(waiting,passing)))>

In Scheme it is easy, but it does not work:
    <xsd:element name="item">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="risid"/>
                <xsd:choice>
                    <xsd:element ref="waiting"/>
                    <xsd:element ref="passing"/>
                    <xsd:sequence>
                        <xsd:element ref="waiting"/>
                        <xsd:element ref="passing"/>
                    </xsd:sequence>
                </xsd:choice>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

:0,0: Complex type 'C0' violates the Unique Particle Attribution rule in
its components 'waiting' and 'waiting'

It is possible to write corresponding schema?

Thanks for your solutions.

Stano.

Attachments:
-----------------
test.xml
-----------------
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE result SYSTEM "d:\praca\lucia\klient\dtd.dtd">
<result>
        <item>
                <risid>DE307001001223</risid>
                <waiting>
                        <average>13.99</average>
                        <deviation>6.27</deviation>
                        <count>4</count>
                </waiting>
                <passing>
                        <average>13.99</average>
                        <deviation>6.27</deviation>
                        <count>4</count>
                </passing>
        </item>
</result>

----------------
DTD
----------------
<?xml version="1.0" encoding="UTF-8"?>

<!ELEMENT result (item+|error)>

<!ELEMENT error (#PCDATA)>
<!ELEMENT item (risid,(waiting|passing|(waiting,passing)))>

<!ELEMENT risid (#PCDATA)>
<!ELEMENT waiting (average,deviation,count)>
<!ELEMENT passing (average,deviation,count)>

<!ELEMENT average (#PCDATA)>
<!ELEMENT deviation (#PCDATA)>
<!ELEMENT count (#PCDATA)>

-----------------
Scheme
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>

        <!-- simple elements -->
        <xsd:element name="risid" type="xsd:string"/>
        <xsd:element name="average" type="xsd:decimal"/>
        <xsd:element name="deviation" type="xsd:decimal"/>
        <xsd:element name="count" type="xsd:nonNegativeInteger"/>
        <xsd:element name="error" type="xsd:string"/>

        <!-- complex elements -->
        <xsd:complexType name="record">
                <xsd:sequence>
                        <xsd:element ref="average"/>
                        <xsd:element ref="deviation"/>
                        <xsd:element ref="count"/>
                </xsd:sequence>
        </xsd:complexType>
        <xsd:element name="waiting" type="record"/>
        <xsd:element name="passing" type="record"/>

        <xsd:element name="item">
                <xsd:complexType>
                        <xsd:sequence>
                                <xsd:element ref="risid"/>
                                <xsd:choice>
                                        <xsd:element ref="waiting"/>
                                        <xsd:element ref="passing"/>
                                        <xsd:sequence>
<xsd:element ref="waiting"/> <xsd:element ref="passing"/>
                                        </xsd:sequence>
                                </xsd:choice>
                        </xsd:sequence>
                </xsd:complexType>
        </xsd:element>

        <xsd:element name="result">
                <xsd:complexType>
                        <xsd:choice>
                                <xsd:element ref="error"/>
<xsd:element ref="item" maxOccurs="unbounded"/>
                        </xsd:choice>
                </xsd:complexType>
        </xsd:element>

</xsd:schema>



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--
Stanislav Paška
programátor, www skupina
KIOS s.r.o.
tel: 033 / 794 00 18



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>