Attribute declaration, invalid schema

Discussion in 'XML' started by pstachy, Nov 5, 2006.

  1. pstachy

    pstachy Guest

    Hi all,
    I've got this problem declaring attribute for the element. W3C
    Validator doesn't find this ok. I really dont know how to declare the
    attribute for the tag which has simle content(doesn't have other tags
    in itself). In this case:

    <price curr="PLN">12.30</price>

    My Schema for that:

    <xs:element name="price">
    <xs:complexType>
    <xs:simpleContent>
    <xs:restriction base="xs:decimal">
    <xs:minInclusive value="0" />
    <xs:fractionDigits value="2" />
    </xs:restriction>

    </xs:simpleContent>

    <xs:attribute name="curr" use="required" type="xs:string"
    fixed="PLN" />

    </xs:complexType>
    </xs:element>

    Please, tell me what is wrong. Thx:)
     
    pstachy, Nov 5, 2006
    #1
    1. Advertisements

  2. pstachy wrote:

    > <price curr="PLN">12.30</price>



    > <xs:element name="price">
    > <xs:complexType>
    > <xs:simpleContent>
    > <xs:restriction base="xs:decimal">
    > <xs:minInclusive value="0" />
    > <xs:fractionDigits value="2" />
    > </xs:restriction>
    >
    > </xs:simpleContent>
    >
    > <xs:attribute name="curr" use="required" type="xs:string"
    > fixed="PLN" />
    >
    > </xs:complexType>
    > </xs:element>



    If you do e.g.

    <xs:simpleType name="priceContent">
    <xs:restriction base="xs:decimal">
    <xs:minInclusive value="0" />
    <xs:fractionDigits value="2" />
    </xs:restriction>
    </xs:simpleType>

    <xs:element name="price">
    <xs:complexType>
    <xs:simpleContent>
    <xs:extension base="priceContent">
    <xs:attribute name="curr" use="required" type="xs:string"/>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>

    then I think it works. That way you have a simple type restriction for
    the contents of the price element but the type of the price element
    itself is a complex type that extends the priceContent type with the
    curr attribute.




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Nov 5, 2006
    #2
    1. Advertisements

  3. pstachy

    pstachy Guest

    Thanks. It worked:)

    Martin Honnen napisal(a):
    > pstachy wrote:
    >
    > > <price curr="PLN">12.30</price>

    >
    >
    > > <xs:element name="price">
    > > <xs:complexType>
    > > <xs:simpleContent>
    > > <xs:restriction base="xs:decimal">
    > > <xs:minInclusive value="0" />
    > > <xs:fractionDigits value="2" />
    > > </xs:restriction>
    > >
    > > </xs:simpleContent>
    > >
    > > <xs:attribute name="curr" use="required" type="xs:string"
    > > fixed="PLN" />
    > >
    > > </xs:complexType>
    > > </xs:element>

    >
    >
    > If you do e.g.
    >
    > <xs:simpleType name="priceContent">
    > <xs:restriction base="xs:decimal">
    > <xs:minInclusive value="0" />
    > <xs:fractionDigits value="2" />
    > </xs:restriction>
    > </xs:simpleType>
    >
    > <xs:element name="price">
    > <xs:complexType>
    > <xs:simpleContent>
    > <xs:extension base="priceContent">
    > <xs:attribute name="curr" use="required" type="xs:string"/>
    > </xs:extension>
    > </xs:simpleContent>
    > </xs:complexType>
    > </xs:element>
    >
    > then I think it works. That way you have a simple type restriction for
    > the contents of the price element but the type of the price element
    > itself is a complex type that extends the priceContent type with the
    > curr attribute.
    >
    >
    >
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    pstachy, Nov 5, 2006
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    1,184
  2. Markus
    Replies:
    1
    Views:
    1,924
    Markus
    Nov 23, 2005
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,566
    Stanimir Stamenkov
    Apr 25, 2005
  4. Alex Vinokur
    Replies:
    4
    Views:
    872
    Jonathan Turkanis
    Apr 5, 2004
  5. Ovidesvideo
    Replies:
    4
    Views:
    748
    Andrey Tarasevich
    Dec 10, 2004
  6. kelvSYC
    Replies:
    6
    Views:
    7,987
    Richard Herring
    May 17, 2005
  7. Replies:
    4
    Views:
    1,358
    Richard Tobin
    Dec 12, 2006
  8. Manuel Collado
    Replies:
    6
    Views:
    1,700
    Manuel Collado
    Oct 20, 2011
Loading...