key/keyref problem

Hello,

My head is sore from bashing it against a brick wall so I hope someone can
help me with this!

Below is some XML, a schema and the output from XSV when I try to validate.

I am trying to express a key/keyref constraint but I always get an XSV
error.  I have tried altering the position of the xsd:keyref and xsd:key
elements in case it is some sort of scoping problem but with no success.

(I have also tried the example from section 5 of the primer (4Q99.xml and
report.xsd) and I get the same error, although I admit I did change
report.xsd by removing the import and changing 'xipo:SKU' to 'string'!)

Could someone please explain to me what I'm doing wrong?

Many thanks,
Adam


**********************************************************************
*** XSV

<?xml version='1.0'?>
<xsv
	docElt='{urn:acw:keyref1}root'
	instanceAssessed='true'
	instanceErrors='1'
	rootType='[Anonymous]'
	schemaDocs='keyref1.xsd'
	schemaErrors='0'
	schemaLocs=''
	target='file:/Z:/src/XML/testConstraints/keyref1.xml'
	validation='strict'
	version='XSV 1.196/1.97 of 2001/06/09 19:14:08'
	xmlns='http://www.w3.org/2000/05/xsv'>
	
	<invalid
		char='39'
		code='cvc-identity-constraint.2.3.2'
		line='1'
		resource='file:/Z:/src/XML/testConstraints/keyref1.xml'>
		No key or unique constraint named k1:mykey declared, refed
by keyref dummy1
	</invalid>

</xsv>


**********************************************************************
*** keyref1.xml

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="urn:acw:keyref1">
	<keyrefs>
		<keyref key="1"/>
		<keyref key="2"/>
		<keyref key="2"/>
	</keyrefs>
	<keys>
		<key id="1"/>
		<key id="2"/>
		<key id="3"/>
		<key id="4"/>
	</keys>
</root>


**********************************************************************
*** keyref1.xsd

<?xml version="1.0" encoding="utf-8"?>

<xsd:schema targetNamespace="urn:acw:keyref1"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:k1="urn:acw:keyref1"
        elementFormDefault="qualified">
        
<xsd:element name="root">

<xsd:complexType>
<xsd:sequence>
<xsd:element name="keyrefs" type="k1:keyrefsType">
</xsd:element>
<xsd:element name="keys" type="k1:keysType">
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:key name="mykey">
<xsd:selector xpath="k1:keys/k1:key"/>
<xsd:field xpath="@id"/>
</xsd:key>

<xsd:keyref name="dummy1" refer="k1:mykey">
<xsd:selector xpath="k1:keyrefs/k1:keyref"/>
<xsd:field xpath="@key"/>
</xsd:keyref>

</xsd:element>

<xsd:complexType name="keyrefsType">
<xsd:sequence>
<xsd:element name="keyref" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="key" type="xsd:positiveInteger" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="keysType">
<xsd:sequence>
<xsd:element name="key" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="id" type="xsd:positiveInteger" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

</xsd:schema>

Received on Monday, 2 July 2001 13:27:51 UTC