SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Help needed to spot error

rated by 0 users
This post has 1 Reply | 1 Follower

Not Ranked
Posts 1
eleven Posted: 10-21-2006 12:46 PM
Hi all,
I am a newbie to XML and have been trying to learn how to use schema to validate my entries. Can anyone try to help me spot what is wrong with my XSD because it keeps having error? I am not sure if I have used it correctly. Thank you for your help.

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

<xs:element name="vehicle">
<xs:complexType>
<xs:sequence>
<xs:element ref="car" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="car">
<xs:complexType>
<xs:sequence>
<xs:element ref="reg"/>
<xs:element ref="date"/>
<xs:element ref="start"/>
<xs:element ref="end"/>
<xs:element ref="id"/>
<xs:element ref="purpose"/>
<xs:element ref="fuel" minOccurs="0"/>
<xs:element ref="cost" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="reg">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="1[a-z][a-z][a-z]-[0-9][0-9][0-9]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

<xs:element name="date" type="xs:gYear"/>

<xs:element name="start" type="xs:integer"/>

<xs:element name="end" type="xs:integer" />

<xs:element name="id">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9][0-9][0-9][0-9][0-9][0-9][a-z]" />
</xs:restriction>
</xs:simpleType>
</xs:element>

<xs:element name="purpose" type="xs:string"/>

<xs:element name="fuel" type="xs:decimal" />

<xs:element name="cost" type="xs:decimal" />

</xs:schema>
Top 10 Contributor
Posts 2,284

eleven:
it keeps having error

Perhaps you'd like to expand and elaborate more on this description.

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Page 1 of 1 (2 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems