473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Validator ignores my <xs:unique>

Hello everyone,

I want to add a unique constraint to a XSD I created.

After I modified validation (XMLSpy, Castor-0.9.5 marshaller) of my
example (see below) against the XSD (also see below) doesn't lead to
any errors/warnings.

I tried several different combinations for the <xs:selector> and
<xs:field>.

Does anyone have an idea what I do wrong?

Thanks, Ulf

--- UniqueTest.xsd ---------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="http://www.test.de/test"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://www.test.de/test" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<!-- -->
<xs:element name="liste">
<xs:complexType>
<xs:sequence>
<xs:element name="objekt" type="test:objektType"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="unq">
<xs:selector xpath="liste"/>
<xs:field xpath="objekt/@nummer"/>
</xs:unique>
</xs:element>
<!-- -->
<xs:complexType name="objektType">
<xs:sequence>
<xs:element name="beschreibung" type="xs:string"/>
<xs:element name="typ" type="xs:string"/>
</xs:sequence>
<xs:attribute name="nummer" use="required">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="9999"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:schema>

--- UniqueTest.xml ---------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by DAVID ibR (ibR
Ges. für Geoinformation mbH) -->
<liste
xmlns="http://www.test.de/test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.test.de/test UniqueTest.xsd">
<objekt nummer="123">
<beschreibung>blubber</beschreibung>
<typ>wenigschlimm</typ>
</objekt>
<objekt nummer="123">
<beschreibung>bla</beschreibung>
<typ>schlimm</typ>
</objekt>
<objekt nummer="234">
<beschreibung>blubb</beschreibung>
<typ>sehrschlimm</typ>
</objekt>
<objekt nummer="345">
<beschreibung>blubbidubb</beschreibung>
<typ>schlimm</typ>
</objekt>
</liste>
Jul 20 '05 #1
1 2678
> Hello everyone,

I want to add a unique constraint to a XSD I created.

Does anyone have an idea what I do wrong?


You need to fully qualify your XPath expression, like so:

<xs:unique name="unq">
<xs:selector xpath="test:liste"/>
<xs:field xpath="test:objekt/@nummer"/>
</xs:unique>

Hope this helps.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sachinik19 | last post by:
Hi, xml file : ------------- <?xml version='1.0'?> <query xmlns='jabber:iq:privacy' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="jabber:iq:privacy privacy.xsd">...
2
by: Aray | last post by:
I googled for it for few houres, but didn't resolve it, any hints will be thinkfull. I want to use the following XSD file to guarantee <element1is unique, but it doesn't work. The following...
1
by: cedric.louyot | last post by:
Hi, I've written a schema that looks like : <xs:schema> <xs:complexType name="myType"> <xs:sequence> <xs:element name="e1" type="T1" maxOccurs="unbounded"/> <xs:element name="e2"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.