Dear XercesJ User's List,

I'm trying to use keys and keyrefs to validate the existence of elements
while parsing with the xerces-j v1.4.3 parser. It appears that when I try to
use substitution groups along with deriving concrete data types from
abstract types that errors are being reported from what appears (to my
inexperienced eyes) to be correct. The errors for the attached files are:

>[Error] animalML.xml:19:9: Key with value [ID Value:  Baby] not found for
> identity constraint of element "Home".
> [Error] animalML.xml:19:9: Key with value [ID Value:  Abby] not found for
> identity constraint of element "Home".
>
The XSV validator does not report errors.
IBM SchemaQuality Checker seems to be trying to tell me something, but I'm
not sure how to interpret the output. Here's a small sampling:
ERROR
 file = file:D:/Projects/0507/research/Schemas/animalML.xsd line 11 column
45
SEVERITY: 0
ERROR TYPE: 2
MESSAGE
No node in element http://www.ara.com/animals:Home corresponds to
<xsd:selector
xpath="AnimalList/Animal"/>
 defined in <xsd:key name="AnimalNameCheck">
    <selector xpath="AnimalList/Animal"/>
    <field xpath="@name"/>
</xsd:key>
. Invalid XPath starting from
http://www.ara.com/animals:Home:AnimalList/Animal.

Finally, when I define the derivations without using substitution groups, I
need to use xsi:type to indicate which concrete derivation in the instance
file. This is a little bit more inconvenient, but the errors go away.

If you got this far, you can probably predict what my questions would be,
but here they are anyway:

Could there be something wrong with my schema or key/keyref definitions,
that xerces doesn't like?
Does anyone have any opinions on the use of substitution groups?

As always, responses are very much appreciated.

John Powell
Applied Research Associates, Inc.


<?xml version="1.0"?>
<Home xmlns="http://www.ara.com/animals"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://www.ara.com/animals animalML.xsd">
	<AnimalList>
		<Cat name="Abby">
			<Age>3</Age>
		</Cat>
		<Dog name="Baby">
			<Food>Anything</Food>
		</Dog>
	</AnimalList>
	<PetList>
		<Pet>
			<AnimalName>Baby</AnimalName>
		</Pet>
		<Pet>
			<AnimalName>Abby</AnimalName>
		</Pet>
	</PetList>
</Home>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.ara.com/animals"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns="http://www.ara.com/animals"; elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xsd:element name="Home">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="AnimalList"/>
				<xsd:element ref="PetList"/>
			</xsd:sequence>
		</xsd:complexType>
		<xsd:key name="AnimalNameCheck">
			<xsd:selector xpath="AnimalList/Animal"/>
			<xsd:field xpath="@name"/>
		</xsd:key>
		<xsd:keyref name="NameRef" refer="AnimalNameCheck">
			<xsd:selector xpath="PetList/Pet/AnimalName"/>
			<xsd:field xpath="."/>
		</xsd:keyref>
	</xsd:element>
	<xsd:element name="PetList">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="Pet" maxOccurs="unbounded"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="Pet">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="AnimalName" type="xsd:string"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="AnimalList">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="Animal" maxOccurs="unbounded"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="Animal" type="AnimalType" abstract="true"/>
	<xsd:element name="Cat" type="CatType" substitutionGroup="Animal"/>
	<xsd:element name="Dog" type="DogType" substitutionGroup="Animal"/>
	<xsd:complexType name="AnimalType">
		<xsd:attribute name="name" type="xsd:string" use="required"/>
	</xsd:complexType>
	<xsd:complexType name="CatType">
		<xsd:complexContent>
			<xsd:extension base="AnimalType">
				<xsd:sequence>
					<xsd:element name="Age" type="xsd:string"/>
				</xsd:sequence>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>
	<xsd:complexType name="DogType">
		<xsd:complexContent>
			<xsd:extension base="AnimalType">
				<xsd:sequence>
					<xsd:element name="Food" type="xsd:string" minOccurs="0"/>
				</xsd:sequence>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>
</xsd:schema>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to