Flaw? - <?xml-model?> and multiple namespaces
Posted: Mon Sep 02, 2013 10:51 pm
Hi,
I have two RelaxNG schemas called Address.rng and Customers.rng, with target namespaces "http://www.myserver.com/xmlns/address" and "http://www.myserver.com/xmlns/customers".
Schema Customers.rng has an <anyName> instruction, like this:
This means i can put elements from any namespace except "blah" within element "CustomerInformation", like this:
To validate this document i use an xml-model instruction:
<?xml-model href="Customers.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
But, this doesn't work, because namespace "http://www.myserver.com/xmlns/address" is not defined. So, i add a second xml-model instruction:
<?xml-model href="Address.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
But, this also doesn't work, because these xml-model instructions are used one-by-one, not together.
Any ideas?
Thank you,
- Carla
Full Example:
Address.rng:
Customers:
Example.xml:
I have two RelaxNG schemas called Address.rng and Customers.rng, with target namespaces "http://www.myserver.com/xmlns/address" and "http://www.myserver.com/xmlns/customers".
Schema Customers.rng has an <anyName> instruction, like this:
Code: Select all
<element name="CustomerInformation">
<anyName>
<except>
<nsName ns="blah"/>
</except>
</anyName>
</element>
Code: Select all
<cust:CustomerInformation xmlns:cust="http://www.myserver.com/xmlns/customers">
<addr:Address xmlns:addr="http://www.myserver.com/xmlns/address">
</addr:Address>
</cust:CustomerInformation>
<?xml-model href="Customers.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
But, this doesn't work, because namespace "http://www.myserver.com/xmlns/address" is not defined. So, i add a second xml-model instruction:
<?xml-model href="Address.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
But, this also doesn't work, because these xml-model instructions are used one-by-one, not together.
Any ideas?
Thank you,
- Carla
Full Example:
Address.rng:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<grammar
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
ns="http://www.myserver.com/xmlns/address"
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
<start>
<ref name="start"/>
</start>
<define name="start">
<element name="Address">
<element name="Street">
<data type="string"/>
</element>
<element name="City">
<data type="string"/>
</element>
<element name="State">
<data type="string"/>
</element>
<element name="ZipCode">
<data type="string"/>
</element>
</element>
</define>
</grammar>
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<grammar
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
ns="http://www.myserver.com/xmlns/customers"
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
<start>
<ref name="start"/>
</start>
<define name="start">
<element name="Customers">
<element name="CustomerInformation">
<element name="CustomerNumber">
<data type="integer"/>
</element>
<element name="blabla">
<data type="integer"/>
</element>
<element>
<anyName>
<except>
<nsName ns="blah"/>
</except>
</anyName>
<text/>
</element>
</element>
</element>
</define>
</grammar>
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="Address.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="Customers.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<cust:Customers
xmlns:addr="http://www.myserver.com/xmlns/address"
xmlns:cust="http://www.myserver.com/xmlns/customers">
<cust:CustomerInformation>
<cust:CustomerNumber error1="">990023</cust:CustomerNumber>
<addr:Address>
<addr:Street>9902 Broadway</addr:Street>
<addr:City>Chicago</addr:City>
<addr:error2/>
<addr:State>IL</addr:State>
<addr:ZipCode error3="">60612</addr:ZipCode>
</addr:Address>
</cust:CustomerInformation>
</cust:Customers>