Attribute declaration, invalid schema

P

pstachy

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:)
 
M

Martin Honnen

pstachy said:
<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.
 
P

pstachy

Thanks. It worked:)

Martin Honnen napisal(a):
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top