P
pr
I have the following sample XML File:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<parent>
<child ref="1"><grandchild>tom</grandchild></child>
<child ref="1"><grandchild>harry</grandchild></child>
</parent>
And the schema is:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:simpleType name = "oneormore">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="parent">
<xsd:complexType>
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<!-- A chart consists of several rows -->
<xsd:element name="child">
<xsd:complexType>
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="grandchild" type = "xsd:string"/>
</xsd:sequence>
<xsd:attribute name="ref" type="xsd:integer" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<!-- This is not working -->
<xsd:unique name="rowID">
<xsd:selector xpath="parent/child"/>
<xsd:field xpath="@ref"/>
</xsd:unique>
</xsd:element>
</xsd:schema>
The problem is that my XML file validates successfully in my Java
(DOM) app, despite the fact that the values of the ref attributes in
the child element are NOT unique (we have two occurrences of "1").
Is this a bug in the parser, or have I done something wrong in my
schema?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<parent>
<child ref="1"><grandchild>tom</grandchild></child>
<child ref="1"><grandchild>harry</grandchild></child>
</parent>
And the schema is:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:simpleType name = "oneormore">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="parent">
<xsd:complexType>
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<!-- A chart consists of several rows -->
<xsd:element name="child">
<xsd:complexType>
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="grandchild" type = "xsd:string"/>
</xsd:sequence>
<xsd:attribute name="ref" type="xsd:integer" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<!-- This is not working -->
<xsd:unique name="rowID">
<xsd:selector xpath="parent/child"/>
<xsd:field xpath="@ref"/>
</xsd:unique>
</xsd:element>
</xsd:schema>
The problem is that my XML file validates successfully in my Java
(DOM) app, despite the fact that the values of the ref attributes in
the child element are NOT unique (we have two occurrences of "1").
Is this a bug in the parser, or have I done something wrong in my
schema?