Problems validating XML file against Schema
Posted: Thu Sep 09, 2004 9:55 pm
Hi,
I just got OxygenXML and was all excited about it, when I realized that it's not validating an XML file properly.
I must be doing something wrong since I can't imagine that something that's based on Xerces-J is not following the spec.
These files validate 100% in XMLSpy, by the way.
Here is the XML file (store.xml):
Here is the XSD file (store.xsd):
Here is the DTD file (store.dtd) (which actually does validate fine, but I am including it here for completeness since it's referenced in the XML):
Here are the error messages I get when I try to hit "Validate" botton for the store.xsd:
E src-resolve.4.2: Error resolving component 'store:StoreType'. It was detected that 'store:StoreType' is in namespace 'http://www.apl.jhu.edu/~davids/605742/', but components from this namespace are not referenceable from schema document 'file:/C:/temp/store.xsd'. If this is the incorrect namespace, perhaps the prefix of 'store:StoreType' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/C:/temp/store.xsd'. store.xsd file:/C:/temp/store.xsd 8:48E InvalidRegex: Pattern value '[\sa-zA-Z0-9-]*' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'. store.xsd file:/C:/temp/store.xsd 15:30E src-resolve: Cannot resolve the name 'store:Title' to a(n) 'simpleType definition' component. store.xsd file:/C:/temp/store.xsd 40:79E src-resolve: Cannot resolve the name 'store:IntegerList' to a(n) 'simpleType definition' component. store.xsd file:/C:/temp/store.xsd 48:54
Here are the error messages I get when I hit the validate botton for the store.xml:
E cvc-elt.1: Cannot find the declaration of element 'store'. store.xml file:/C:/temp/store.xml 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1
Can someone point out to me what I am setting up wrong in OxygenXML? I am pretty sure that the errors it's showing to me are wrong. These files comply with the XML spec.
Just to give you a specific example. OxygenXML is complaining about a regular expression for this line:
It says that "-" has to be specified by "\-". This is not true according to the spec:
http://www.w3.org/TR/xmlschema-0/#regexAppendix
Thanks,
Yaakov.
I just got OxygenXML and was all excited about it, when I realized that it's not validating an XML file properly.

I must be doing something wrong since I can't imagine that something that's based on Xerces-J is not following the spec.
These files validate 100% in XMLSpy, by the way.
Here is the XML file (store.xml):
Code: Select all
<?xml version="1.0"?>
<!DOCTYPE store SYSTEM "store.dtd">
<store
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.apl.jhu.edu/~davids/605742/"
xsi:noNamespaceSchemaLocation="store.xsd">
<cust_list>
<customer cid="C-1" >
<name title="Mr.">
<first>Sam</first>
<middle>Ta</middle>
<middle>Chuan</middle>
<last>Chu</last>
</name>
<address>
<street>123-A Kensington Circle</street>
<city>London</city><country>England</country>
</address>
<purchase date="2002-01-12" items="I-34 I-62 I-15" qty="3 1 1" />
<purchase date="2002-01-13" items="I-15" qty="2" />
</customer>
<customer cid="C-2" ctype="bad">
<name title="Dr.">
<first>Darsana</first>
<last>Sudarsen</last>
</name>
<address>
<street>11100 Johns Hopkins</street>
<city>Baltimore</city><state>MD</state>
<zip>21207</zip>
</address>
<purchase date="2002-02-02" items="I-62 I-5" qty="2 1" />
</customer>
</cust_list>
<inventory_list>
<item item_no="I-5" supplier_id="S-1">
<description>Ivory Soap</description>
<in_stock>50</in_stock>
<price>1.09</price>
<cost>.28</cost>
</item>
<item item_no="I-15" supplier_id="S-1">
<description>Cheer Detergent</description>
<in_stock>37</in_stock>
<price>5.98</price>
<cost>2.10</cost>
</item>
<item item_no="I-34" supplier_id="S-1">
<description>Bounty Paper Towels</description>
<in_stock>112</in_stock>
<price>1.48</price>
<cost>.57</cost>
</item>
<item item_no="I-62" supplier_id="S-2">
<description>Sunshine Tissues</description>
<in_stock>320</in_stock>
<price>1.65</price>
<cost>.98</cost>
</item>
</inventory_list>
<supplier_list>
<supplier sid="S-1">
<company>Proctor and Gamble</company>
<telephone>1-800-PAMPERS</telephone>
</supplier>
<supplier sid="S-2">
<company>Sunshine Products</company>
<telephone>1-888-344-9881</telephone>
</supplier>
</supplier_list>
</store>
Code: Select all
<?xml version="1.0"?>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://www.apl.jhu.edu/~davids/605742/"
xmlns:store="http://www.apl.jhu.edu/~davids/605742/">
<element name="store" type="store:StoreType"/>
<simpleType name="ProperName">
<restriction base="string">
<pattern value="[A-Z][a-zA-Z]*"/>
</restriction>
</simpleType>
<simpleType name="MixedName">
<restriction base="string">
<pattern value="[\sa-zA-Z0-9-]*"/>
</restriction>
</simpleType>
<complexType name="StoreType">
<all>
<element name="cust_list" type="store:CustListType" minOccurs="0"/>
<element name="inventory_list" type="store:InventoryListType" minOccurs="0"/>
<element name="supplier_list" type="store:SupplierListType" minOccurs="0"/>
</all>
</complexType>
<complexType name="CustListType">
<sequence>
<element name="customer" type="store:CustomerType" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="CustomerType">
<sequence>
<element name="name">
<complexType>
<sequence>
<element name="first" type="store:ProperName"/>
<element name="middle" type="store:ProperName" minOccurs="0" maxOccurs="unbounded"/>
<element name="last" type="store:ProperName"/>
</sequence>
<attribute name="title" type="store:Title" use="optional" default="Ms."/>
</complexType>
</element>
<element name="address" type="store:AddressType"/>
<element name="purchase" minOccurs="0" maxOccurs="unbounded">
<complexType>
<attribute name="date" type="date"/>
<attribute name="items" type="IDREFS"/>
<attribute name="qty" type="store:IntegerList"/>
</complexType>
</element>
</sequence>
<attribute name="cid" type="ID"/>
<attribute name="ctype" type="string" use="optional" default="good"/>
</complexType>
<simpleType name="IntegerList">
<list itemType="integer"/>
</simpleType>
<simpleType name="Title">
<restriction base="string">
<enumeration value="Mr."/>
<enumeration value="Ms."/>
<enumeration value="Mrs."/>
<enumeration value="Miss"/>
<enumeration value="Dr."/>
</restriction>
</simpleType>
<group name="USAddressGroup">
<sequence>
<element name="state" type="store:USState"/>
<element name="zip" type="store:ZipCode"/>
</sequence>
</group>
<complexType name="AddressType">
<sequence>
<element name="street" type="store:MixedName"/>
<element name="city" type="store:ProperName"/>
<choice>
<element name="country" type="store:ProperName"/>
<group ref="store:USAddressGroup"/>
</choice>
</sequence>
</complexType>
<simpleType name="ZipCode">
<restriction base="string">
<pattern value="[0-9]{5}"/>
</restriction>
</simpleType>
<simpleType name="USState">
<restriction base="string">
<enumeration value="AK"/>
<enumeration value="AL"/>
<enumeration value="MD"/>
</restriction>
</simpleType>
<complexType name="InventoryListType">
<sequence>
<element name="item" type="store:ItemType" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="ItemType">
<all>
<element name="description" type="string"/>
<element name="in_stock" type="nonNegativeInteger"/>
<element name="price" type="decimal"/>
<element name="cost" type="decimal"/>
</all>
<attribute name="item_no" type="ID"/>
<attribute name="supplier_id" type="IDREF"/>
</complexType>
<simpleType name="StdTelNum">
<restriction base="string">
<pattern value="\d{1}-\d{3}-\d{3}-\d{4}"/>
</restriction>
</simpleType>
<simpleType name="StringTelNum">
<restriction base="string">
<pattern value="\d{1}-\d{3}-[A-Z0-9]{7}"/>
</restriction>
</simpleType>
<simpleType name="AllTelNum">
<union memberTypes="store:StdTelNum store:StringTelNum"/>
</simpleType>
<complexType name="SupplierListType">
<sequence>
<element name="supplier" minOccurs="0" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="company" type="store:MixedName"/>
<element name="telephone" type="store:AllTelNum"/>
</sequence>
<attribute name="sid" type="ID"/>
</complexType>
</element>
</sequence>
</complexType>
</schema>
Code: Select all
<!ELEMENT store (cust_list, inventory_list, supplier_list) >
<!ATTLIST store
xmlns:xsi CDATA #FIXED "http://www.w3.org/2001/XMLSchema-instance"
xmlns CDATA #FIXED "http://www.apl.jhu.edu/~davids/605742/"
xsi:noNamespaceSchemaLocation CDATA #REQUIRED>
<!ELEMENT cust_list (customer+) >
<!ELEMENT customer (name, address, purchase*) >
<!ATTLIST customer
cid ID #REQUIRED
ctype NMTOKEN #IMPLIED>
<!ELEMENT name (first, middle*, last) >
<!ATTLIST name title (Dr. | Mr. | Ms. | Miss) #IMPLIED>
<!ELEMENT first (#PCDATA) >
<!ELEMENT middle (#PCDATA) >
<!ELEMENT last (#PCDATA) >
<!ELEMENT address (street+, city, (country | (state, zip)))>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT zip (#PCDATA)>
<!ELEMENT purchase EMPTY >
<!ATTLIST purchase
date CDATA #IMPLIED
items IDREFS #REQUIRED
qty NMTOKENS #REQUIRED >
<!ELEMENT inventory_list (item+) >
<!ELEMENT item (description, in_stock, price, cost) >
<!ATTLIST item
item_no ID #REQUIRED
supplier_id IDREF #REQUIRED >
<!ELEMENT description (#PCDATA)>
<!ELEMENT in_stock (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT cost (#PCDATA)>
<!ELEMENT supplier_list (supplier+) >
<!ELEMENT supplier (company, telephone) >
<!ATTLIST supplier
sid ID #REQUIRED>
<!ELEMENT company (#PCDATA)>
<!ELEMENT telephone (#PCDATA)>
Here are the error messages I get when I try to hit "Validate" botton for the store.xsd:
E src-resolve.4.2: Error resolving component 'store:StoreType'. It was detected that 'store:StoreType' is in namespace 'http://www.apl.jhu.edu/~davids/605742/', but components from this namespace are not referenceable from schema document 'file:/C:/temp/store.xsd'. If this is the incorrect namespace, perhaps the prefix of 'store:StoreType' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/C:/temp/store.xsd'. store.xsd file:/C:/temp/store.xsd 8:48E InvalidRegex: Pattern value '[\sa-zA-Z0-9-]*' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'. store.xsd file:/C:/temp/store.xsd 15:30E src-resolve: Cannot resolve the name 'store:Title' to a(n) 'simpleType definition' component. store.xsd file:/C:/temp/store.xsd 40:79E src-resolve: Cannot resolve the name 'store:IntegerList' to a(n) 'simpleType definition' component. store.xsd file:/C:/temp/store.xsd 48:54
Here are the error messages I get when I hit the validate botton for the store.xml:
E cvc-elt.1: Cannot find the declaration of element 'store'. store.xml file:/C:/temp/store.xml 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1E TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'http://www.apl.jhu.edu/%7Edavids/605742/'. store.xsd file:/C:/temp/store.xsd 6:1
Can someone point out to me what I am setting up wrong in OxygenXML? I am pretty sure that the errors it's showing to me are wrong. These files comply with the XML spec.
Just to give you a specific example. OxygenXML is complaining about a regular expression for this line:
Code: Select all
<pattern value="[\sa-zA-Z0-9-]*"/>
http://www.w3.org/TR/xmlschema-0/#regexAppendix
Thanks,
Yaakov.