[xml] schema validation of element hierarchy through element wildcard
- From: "philippe ventrillon" <philippe ventrillon fr netcentrex net>
- To: <xml gnome org>
- Subject: [xml] schema validation of element hierarchy through element wildcard
- Date: Wed, 24 Nov 2004 16:25:54 +0100
Hi
!
I face a problem
using libxml2 and as i am quite new to xml ans schema, i'd like someone to tell
me if
this is a bug or if
i missed something obvious.
I have a schema that
describe customers (cust.xsd) it define a cargo element that can contain
any elements of any namespace, but i want to
and validate
strictly these elements.
To fill the cargo, i
built another schema (address.xsd).
To launch the
validation of the document i built a third schema that gathers both cust.xsd and
address.xsd.
For the validation
to proceed i included processContents="strict" in the cargo definition this is
where things start to get wrong, with lax i have not seen any
problem.
I use
libxml2-2.6.16-1 installed on fedora core 1.
Here the command i
launch :
# xmllint --schema
total.xsd cust.xml
<?xml version="1.0"?>
<cust:Customer
xmlns:cust="urn:xmlns:25hoursaday-com:customer"
xmlns:addr="urn:xmlns:25hoursaday-com:address" customerID="12345"
numPurchases="17">
<cust:FirstName>Dare</cust:FirstName>
<cust:LastName>Obasanjo</cust:LastName>
<cust:Cargo>
<addr:Zipcode>
29200
</addr:Zipcode>
<addr:Adress>
<addr:Street>2001 Beagle
Drive</addr:Street>
<addr:City>Redmond</addr:City>
<addr:State>WA</addr:State>
<addr:Zip>98052</addr:Zip>
</addr:Adress>
</cust:Cargo>
<cust:PhoneNumber>425-555-1234</cust:PhoneNumber>
</cust:Customer>
cust32_65.xml:11:
element Street: Schemas validity error : Element 'addr:Street', [strict WC]: No
matching global declaration available.
cust32_65.xml fails to
validate
#
Here are the three
schemas :
cust.xsd----------------------------------------------------------------------------------------------------
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cust="urn:xmlns:25hoursaday-com:customer"
targetNamespace="urn:xmlns:25hoursaday-com:customer"
elementFormDefault="qualified">
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string"
/>
<xs:element name="LastName" type="xs:string"
/>
<xs:element name="Cargo"
minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##other" processContents="strict"
minOccurs="0"
maxOccurs="unbounded"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:any
namespace="##targetNamespace"
processContents="strict"
minOccurs="0" maxOccurs="unbounded"
/>
</xs:sequence>
<xs:attribute name="customerID" type="xs:integer"
/>
<xs:anyAttribute
namespace="##any" processContents="skip"
/>
</xs:complexType>
</xs:element>
<xs:element
name="PhoneNumber" type="xs:string"
/>
<xs:element
name="FrequentShopper" type="xs:boolean" />
</xs:schema>
----------------------------------------------------------------------------------------------------------------
address.xsd-------------------------------------------------------------------------------------------------
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:addr="urn:xmlns:25hoursaday-com:address"
targetNamespace="urn:xmlns:25hoursaday-com:address"
elementFormDefault="qualified">
<xs:element name="Adress">
<xs:complexType>
<xs:sequence>
<xs:element
name="Street" type="xs:string">
</xs:element>
<xs:element
name="City" type="xs:string">
</xs:element>
<xs:element
name="State" type="xs:string">
</xs:element>
<xs:element
name="Zip" type="xs:integer">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element
name="Zipcode"
type="xs:string">
</xs:element>
</xs:schema>
------------------------------------------------------------------------------------------------------------------
total.xsd-------------------------------------------------------------------------------------------------
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import
namespace="urn:xmlns:25hoursaday-com:customer"
schemaLocation="cust.xsd"/>
<xs:import
namespace="urn:xmlns:25hoursaday-com:address"
schemaLocation="addr.xsd"/>
</xs:schema>
-------------------------------------------------------------------------------------------------------------
Any help will be greatly
appreciated
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]