Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Validator ignores my <xs:unique>

Reply
Thread Tools

Validator ignores my <xs:unique>

 
 
Ulf Heyder
Guest
Posts: n/a
 
      10-15-2003
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"
xmlnss="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="testbjektType"
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"
xmlnssi="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>
 
Reply With Quote
 
 
 
 
Itay Zandbank
Guest
Posts: n/a
 
      11-04-2003
> 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="testbjekt/@nummer"/>
</xs:unique>

Hope this helps.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts Validator - creditCard validator smrimell@gmail.com Java 4 02-13-2007 08:32 PM
ISE Testbench/Schematic Generation ignores package Dipl.-Ing. Hanns-Walter Schulz VHDL 5 04-26-2005 02:45 PM
VC6 Compiler ignores Array indexing? Ultraman Aries MCSD 2 06-05-2004 01:46 PM
Mozilla Firefox ignores GetRight. Watchman Firefox 1 04-08-2004 07:59 AM
formsauthentication ignores web.config Dirk Meusel ASP .Net 4 08-29-2003 06:17 PM



Advertisments