XInclude usage and xsi:noNamespaceSchemaLocation limitation, workaround?
Posted: Fri Dec 07, 2012 6:12 pm
First, thank you for being indulgent, I am an XML Schema beginner.
I have build a XML file split up with several includes, using XInclude. I have chosen this method above others because each included XML files can be standalone validated.
As I am working on local file, I didn't defined any namespace and then I use xsi:noNamespaceSchemaLocation attribute to reference my xsd file.
parameters.xml
parameters.xsd
Tranducers/transducer.xml
I don't put the transducers.xsd file because it doesn't give anymore added value to the problem. Just take into account that the transducer.xml is valid against his schema.
So, when I try to validate parameters.xml I got the following error :
The 'noNamespaceSchemaLocation' attribute references a schema whose target namespace was already used for validation.
Error that I can easily understand, but I can not get around in my situation.
What would be the solution in that case. Thanks.
I have build a XML file split up with several includes, using XInclude. I have chosen this method above others because each included XML files can be standalone validated.
As I am working on local file, I didn't defined any namespace and then I use xsi:noNamespaceSchemaLocation attribute to reference my xsd file.
parameters.xml
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="parameters.xsd">
<xi:include href="./Transducers/transducers.xml" parse="xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</Root>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="./Transducers/transducers.xsd"/>
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element ref="Transducers" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Transducers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./transducers.xsd">
...
</Transducers>
So, when I try to validate parameters.xml I got the following error :
The 'noNamespaceSchemaLocation' attribute references a schema whose target namespace was already used for validation.
Error that I can easily understand, but I can not get around in my situation.
What would be the solution in that case. Thanks.