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. Advertising

  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. Advertising

  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. Advertising

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:
    955
  2. Markus
    Replies:
    1
    Views:
    1,528
    Markus
    Nov 23, 2005
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,248
    Stanimir Stamenkov
    Apr 25, 2005
  4. Alex Vinokur
    Replies:
    4
    Views:
    582
    Jonathan Turkanis
    Apr 5, 2004
  5. Manuel Collado
    Replies:
    6
    Views:
    1,410
    Manuel Collado
    Oct 20, 2011
Loading...

Share This Page