Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Attribute declaration, invalid schema

Reply
Thread Tools

Attribute declaration, invalid schema

 
 
pstachy
Guest
Posts: n/a
 
      11-05-2006
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      11-05-2006
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/
 
Reply With Quote
 
 
 
 
pstachy
Guest
Posts: n/a
 
      11-05-2006
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/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schemaLocation" Markus Java 1 11-23-2005 02:41 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
XML schema regular expressions question and recommended XML Schema book Fred Smith XML 1 02-05-2004 11:12 AM
Schema Metadata not a Metadata Schema Brett Selleck XML 1 09-04-2003 05:02 PM
Re: Convert DB2 schema to XML Schema Klaus Johannes Rusch XML 0 08-06-2003 11:23 AM



Advertisments