T
tthunder
Hi @all,
Please check the following XML file and XML schema definition below
first:
-------
XML File (full):
-------
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:\example.xsd">
<Sect>
<no>6</no>
</Sect>
<Sect>
<no>6</no>
</Sect>
</Root>
-------
XML Schema File (full):
-------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element ref="Sect" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="dateAndProdNumKey">
<xs:selector xpath="Sect"/>
<xs:field xpath="no"/>
</xs:unique>
</xs:element>
<xs:element name="Sect">
<xs:complexType>
<xs:sequence>
<xs:element ref="no"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="no" type="xs:integer"/>
</xs:schema>
-------
This example works perfect, or in other words, the validation fails,
because there is a voilation of the "unqiue" constraint.
Now, I change the files and use the following "options":
-------
XML File (snippet):
-------
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.example.org/graph" xsi:schemaLocation="http://
www.example.org/graph c:\example.xsd">
-------
XML Schema File (snippet):
-------
<xs:schema xmlns="http://www.example.org/graph" xmlns:xs="http://
www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/
graph" elementFormDefault="qualified"
attributeFormDefault="qualified">
-------
The only thing changed is, that I am using a target namespace.
Basically, validation still works. If I insert wrong elements, the
validation fails. Otherwise it's ok.
However, the unique constraint DOES NOT work any more! That means,
that the example XML postet above is considered valid!
I am testing about one day now... no clue, why validation does not
work as expected.
All validation tools I tested so far (XMLSpy, libxml2,...) consider
the XML file valid!
Thanks a lot in advance,
Kirsten
Please check the following XML file and XML schema definition below
first:
-------
XML File (full):
-------
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:\example.xsd">
<Sect>
<no>6</no>
</Sect>
<Sect>
<no>6</no>
</Sect>
</Root>
-------
XML Schema File (full):
-------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element ref="Sect" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="dateAndProdNumKey">
<xs:selector xpath="Sect"/>
<xs:field xpath="no"/>
</xs:unique>
</xs:element>
<xs:element name="Sect">
<xs:complexType>
<xs:sequence>
<xs:element ref="no"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="no" type="xs:integer"/>
</xs:schema>
-------
This example works perfect, or in other words, the validation fails,
because there is a voilation of the "unqiue" constraint.
Now, I change the files and use the following "options":
-------
XML File (snippet):
-------
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.example.org/graph" xsi:schemaLocation="http://
www.example.org/graph c:\example.xsd">
-------
XML Schema File (snippet):
-------
<xs:schema xmlns="http://www.example.org/graph" xmlns:xs="http://
www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/
graph" elementFormDefault="qualified"
attributeFormDefault="qualified">
-------
The only thing changed is, that I am using a target namespace.
Basically, validation still works. If I insert wrong elements, the
validation fails. Otherwise it's ok.
However, the unique constraint DOES NOT work any more! That means,
that the example XML postet above is considered valid!
I am testing about one day now... no clue, why validation does not
work as expected.
All validation tools I tested so far (XMLSpy, libxml2,...) consider
the XML file valid!
Thanks a lot in advance,
Kirsten