all groups > dotnet xml > september 2004 >
You're in the

dotnet xml

group:

XML Schema



XML Schema shakuf
9/27/2004 12:31:01 AM
dotnet xml: hi
i would like to define a type with restrictions, i used the following schema
but i get an error

<xs:element name="Latitude">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="LatitudeType">
<xs:attribute name="Units" type="LatLonUnitsType" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<!--
-->
<xs:simpleType name="LatitudeType">
<xs:restriction base="xs:double">
<xs:minInclusive value="-90.0" />
<xs:maxInclusive value="90.0" />
</xs:restriction>
</xs:simpleType>


it does not recognize the LatitudeType.
i want Latitude to be a double with restriction

can any one tell me how can i corrent it
Re: XML Schema Martin Honnen
9/27/2004 1:56:21 PM


[quoted text, click to view]


[quoted text, click to view]

You have not shown us your XML instance document.
When I use the following schema

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

<xs:simpleType name="LatitudeType">
<xs:restriction base="xs:double">
<xs:minInclusive value="-90.0" />
<xs:maxInclusive value="90.0" />
</xs:restriction>
</xs:simpleType>

<xs:element name="Latitude">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="LatitudeType">
<xs:attribute name="Units" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="Latitude" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

and the following instance

<?xml version="1.0" encoding="UTF-8"?>
<root
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="test2004092701Xsd.xml">

<Latitude Units="degree">90</Latitude>

<Latitude Units="degree">188.5</Latitude>

</root>

then both Xerces-Java as well as MSXML 4 flag an error for the 188.5 value.

If the above doesn't work for you then please tell us which XML parser
you are using and what else is different in your schema.


--

Martin Honnen
AddThis Social Bookmark Button