W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2002

Problems with keys and keyrefs

From: Gabriele Zannoni <gzannoni@supereva.it>
Date: Sat, 2 Mar 2002 07:39:49 -0500 (EST)
Message-ID: <002901c1c1e7$839f8400$8119fea9@gabriele>
To: <xmlschema-dev@w3.org>
I'm experiencing schemas for a few days and I have some problems
understanding the behavior of keys and keyrefs.

For example the schema:
<schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified" xmlns:ns="http://tempuri.org/XMLSchema.xsd"
<element name="document">
            <element name="keyList" type="ns:keyListType">
            <key name="aKey">
                <selector xpath="ns:key" />
                <field xpath="." />
            <element name="keyRefList" type="ns:keyListType">
            <keyref name="aKeyRef" refer="ns:aKey">
                <selector xpath="ns:key" />
                <field xpath="." />
<complexType name="keyListType">
        <element name="key" type="string" maxOccurs="unbounded" />

runned over the XML:

<document xmlns="http://tempuri.org/XMLSchema.xsd">

rises an error: The keyref '{http://tempuri.org/XMLSchema.xsd}aKey' does not
resolve to a key for the Identity Constraint

The problem disappear if I declare the keys on the "document" element scope.

I hope there's someone who can help me.

Received on Saturday, 2 March 2002 10:29:53 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:55 UTC