S
smachin1000
Hi All,
In the sample schema & document below, I'd like the attribute "name" to
be unique for all function elements under function_list. The tools I'm
using (XML Spy and xmllint) all validate the sample document and do not
pick up that the name is not unique.
Any clues as to what could be going wrong?
Thanks.
-----------------------------------------------------------------------------------------------------------------------------
function_list.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="function_list">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element ref="function"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="unique_fn_name">
<xs:selector xpath="function_list"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="function">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<!-- want the above attribute to be unique -->
</xs:complexType>
</xs:element>
</xs:schema>
-----------------------------------------------------------------------------------------------------------------------------
function_list.xml:
<?xml version="1.0" encoding="UTF-8"?>
<function_list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="function_list.xsd">
<function name="fred"/>
<function name="fred"/>
<function name="frog"/>
<function name="fred"/>
</function_list>
In the sample schema & document below, I'd like the attribute "name" to
be unique for all function elements under function_list. The tools I'm
using (XML Spy and xmllint) all validate the sample document and do not
pick up that the name is not unique.
Any clues as to what could be going wrong?
Thanks.
-----------------------------------------------------------------------------------------------------------------------------
function_list.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="function_list">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element ref="function"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="unique_fn_name">
<xs:selector xpath="function_list"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="function">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<!-- want the above attribute to be unique -->
</xs:complexType>
</xs:element>
</xs:schema>
-----------------------------------------------------------------------------------------------------------------------------
function_list.xml:
<?xml version="1.0" encoding="UTF-8"?>
<function_list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="function_list.xsd">
<function name="fred"/>
<function name="fred"/>
<function name="frog"/>
<function name="fred"/>
</function_list>