You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Colin Savage <CS...@RUBICO.COM> on 2001/11/02 18:27:08 UTC

xsd schema unique problem

Hi

I apologise for the length of this schema, I have tried to reproduce this
error in a simpler way but with no success. I have included the whole files.

using Xerces 1.4.3 i am getting the following errors

[Error] dictionary.xml:10:25: Duplicate unique value [ID Value:  hello1]
declared for identity constraint of element "dictionary".
[Error] dictionary.xml:11:25: Duplicate unique value [ID Value:  hello2]
declared for identity constraint of element "dictionary".
java.lang.NullPointerException
        at
org.apache.xerces.validators.common.XMLValidator$ValueStoreBase.append(XMLVa
lidator.java:4751)
        at
org.apache.xerces.validators.common.XMLValidator$ValueStoreCache.transplant(
XMLValidator.java:5335)
        at
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator
.java:1459)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1204)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1122)
        at sax.SAXCount.print(SAXCount.java:160)
        at sax.SAXCount.main(SAXCount.java:394)

There are 2 errors which occur here, the first is the duplicate unique
value(s) which apply to the following schema and instance fragments

                     <xsd:element name="dictionary" type="dictionaryType">
			<xsd:unique name="uniqueKey2">
				<xsd:selector xpath="*"/>
				<xsd:field xpath="@key"/>
			</xsd:unique>
			<xsd:keyref name="dictionary" refer="uniqueKey2">
				<xsd:selector xpath="*"/>
				<xsd:field xpath="@key"/>
			</xsd:keyref>
		</xsd:element>
		
		and

		<dictionary key="bob">
		<string key="hello1">some other stuff</string>		
		<string key="hello2">some other stuff</string>		
		<dictionary key="bob">
			<string key="hello1">some other stuff</string>

			<string key="hello2">some other stuff</string>

		</dictionary>
		</dictionary>

I believe that this is incorrect since the xpath should only select the
immediate children of the dictionary, not their children too (I have also
tried xpath="child::*")
		
The second error is the java.lang.NullPointerException which occurs even if
there are no duplicate key attributes anywhere in the document

Please could somebody take a look at this and help me out.

I am going to get flamed for this, but I have run it through msxml4 and it
behaves correctly (i.e. within each dictionary element, the children must
have a unique key)

Thanks
Colin

 <<xml.zip>>