S
stormogulen
Hi,
Can someone please help me explain, why this doesn't work? The problem is
the xs:key and xs:keyref. I can only reference the last of the
"afsnit"-nodes (number 302). Whenever I try to reference number 301, I get
the error: 'Undefined values for keyref identity constraint AfsnitFK' (using
xmlspy 2003).
Why, oh why?
----------------------------------------------------------------------------
--
<?xml version="1.0" encoding="UTF-8"?>
<kalkulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="s.xsd">
<tilbudsliste>
<afsnit id="301">
<navn>a</navn>
</afsnit>
<afsnit id="302">
<navn>b</navn>
</afsnit>
</tilbudsliste>
<pris afsnit="302"/>
</kalkulation>
------------------------------
s.xsd --------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="afsnit">
<xs:complexType>
<xs:sequence>
<xs:element name="navn" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
<xs:key name="afsnitPK">
<xs:selector xpath="."/>
<xs:field xpath="@id"/>
</xs:key>
</xs:element>
<xs:element name="tilbudsliste">
<xs:complexType>
<xs:sequence>
<xs:element ref="afsnit" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pris">
<xs:complexType>
<xs:attribute name="afsnit" type="xs:string"/>
</xs:complexType>
<xs:keyref name="afsnitFK" refer="afsnitPK">
<xs:selector xpath="."/>
<xs:field xpath="@afsnit"/>
</xs:keyref>
</xs:element>
<xs:element name="kalkulation">
<xs:complexType>
<xs:sequence>
<xs:element ref="tilbudsliste"/>
<xs:element ref="pris" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Can someone please help me explain, why this doesn't work? The problem is
the xs:key and xs:keyref. I can only reference the last of the
"afsnit"-nodes (number 302). Whenever I try to reference number 301, I get
the error: 'Undefined values for keyref identity constraint AfsnitFK' (using
xmlspy 2003).
Why, oh why?
----------------------------------------------------------------------------
--
<?xml version="1.0" encoding="UTF-8"?>
<kalkulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="s.xsd">
<tilbudsliste>
<afsnit id="301">
<navn>a</navn>
</afsnit>
<afsnit id="302">
<navn>b</navn>
</afsnit>
</tilbudsliste>
<pris afsnit="302"/>
</kalkulation>
------------------------------
s.xsd --------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="afsnit">
<xs:complexType>
<xs:sequence>
<xs:element name="navn" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
<xs:key name="afsnitPK">
<xs:selector xpath="."/>
<xs:field xpath="@id"/>
</xs:key>
</xs:element>
<xs:element name="tilbudsliste">
<xs:complexType>
<xs:sequence>
<xs:element ref="afsnit" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pris">
<xs:complexType>
<xs:attribute name="afsnit" type="xs:string"/>
</xs:complexType>
<xs:keyref name="afsnitFK" refer="afsnitPK">
<xs:selector xpath="."/>
<xs:field xpath="@afsnit"/>
</xs:keyref>
</xs:element>
<xs:element name="kalkulation">
<xs:complexType>
<xs:sequence>
<xs:element ref="tilbudsliste"/>
<xs:element ref="pris" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>