Validator ignores my <xs:unique>

Discussion in 'XML' started by Ulf Heyder, Oct 15, 2003.

  1. Ulf Heyder

    Ulf Heyder Guest

    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:eek:bjektType"
    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>
    Ulf Heyder, Oct 15, 2003
    #1
    1. Advertising

  2. > 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:eek:bjekt/@nummer"/>
    </xs:unique>

    Hope this helps.
    Itay Zandbank, Nov 4, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dipl.-Ing. Hanns-Walter Schulz

    ISE Testbench/Schematic Generation ignores package

    Dipl.-Ing. Hanns-Walter Schulz, Apr 15, 2005, in forum: VHDL
    Replies:
    5
    Views:
    1,447
    Mike Treseler
    Apr 26, 2005
  2. Dirk Meusel

    formsauthentication ignores web.config

    Dirk Meusel, Aug 29, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    2,306
    Jerry III
    Aug 29, 2003
  3. Replies:
    4
    Views:
    886
    Richter~9.6
    Feb 13, 2007
  4. ToshiBoy
    Replies:
    6
    Views:
    829
    ToshiBoy
    Aug 12, 2008
  5. Token Type
    Replies:
    9
    Views:
    339
    Chris Angelico
    Sep 9, 2012
Loading...

Share This Page