My first XSD... please help

This should cover W3C XML Schema, Relax NG and DTD related problems.
abdelhak
Posts: 2
Joined: Tue Aug 28, 2007 3:32 pm

My first XSD... please help

Post by abdelhak » Tue Aug 28, 2007 3:46 pm

Hi everybody,
I have a xml-document dat looks like this:

<?xml version="1.0"?>
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="XsdCatalog.xsd">
<cd>
<title>AAA</title>
<artist>BBB</artist>
<country>CCC</country>
<company>DDD</company>
<price>10.50</price>
<year>1999</year>
</cd>

.........
</catalog>


the xsd file looks like the following:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="CATALOG">
<xs:complexType>
<xs:sequence>
<xs:element name="CD" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="TITLE" type="xs:string"/>
<xs:element name="ARTIST" type="xs:string"/>
<xs:element name="COUNTRY" type="xs:string"/>
<xs:element name="COMPANY" type="xs:string"/>
<xs:element name="PRICE">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minExclusive value="0"/>
<xs:fractionDigits value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="YEAR"/>
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:pattern value="[1-9]{4}"/>
</xs:restriction>
</xs:simpleType>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Nou if I try to bouwse the xml file using explorer, I'm supposed to get an error because
as you kan see I used tag names in lowercase in the xml doc (titel) but in de xsd I've used uppercases...maybe I'm wrong but can you please tel me wat I'm doing wrong?

thanx

jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post by jkmyoung » Tue Aug 28, 2007 5:17 pm

You've already named your problem: case

Either change your schema to use lowercase or change your source to use upper case.

abdelhak
Posts: 2
Joined: Tue Aug 28, 2007 3:32 pm

Post by abdelhak » Wed Aug 29, 2007 9:30 am

Hi,
The reason why I used lowercase in de xml document is to test whether the schema (XSD) is a valid one. if het is, I should get an ERROR when brouwsing de xml-doc, because het is then illegal to use voor example an element 'title' or 'artist' in de xml document instead you have toe use 'TITLE' and 'ARTIST'. wat doe you think???

Post Reply