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 Laura Smith <La...@xxi.com> on 2003/08/01 17:55:00 UTC

Keyrefs and mixed content

The following schema and instance validated properly with the following:

Name: org/apache/xerces
Specification-Title: Java API for XML Processing
Specification-Vendor: Sun Microsystems Inc.
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/xerces2-j
Specification-Version: 1.2
Implementation-Version: Xerces-J_2_0_1_01
Implementation-Title: org.apache.xerces
Comment: Xerces parser implementing JAXP

Why won't it validate properly with this version?

Name: org/apache/xerces/impl/Version
Comment: @impl.name@ for http://xml.apache.org/xerces2-j
Implementation-Title: org.apache.xerces.impl.Version
Implementation-Version: 2.5.0
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/xerces2-j/

Here's the schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>

	<xs:element name="Zones">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="Zone" type="Zone" maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:complexType>
		<xs:key name="ZoneName">
			<xs:selector xpath="./Zone"/>
			<xs:field xpath="@name"/>
		</xs:key>
		<xs:keyref name="ZoneToZoneName" refer="ZoneName">
			<xs:selector xpath="./Zone/Zone"/>
			<xs:field xpath="."/>
		</xs:keyref>
	</xs:element>

	<xs:complexType name="Zone" mixed="true" >
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="Country" type="xs:string"/>
			<xs:element name="Zone" type="Zone"/>
		</xs:choice>
		<xs:attribute name="name" type="xs:string" use="optional"/>
	</xs:complexType>

</xs:schema>

And here's the instance:

<?xml version="1.0" encoding="UTF-8"?>
<Zones>
	<Zone name="United States">
		<Country>US</Country>
	</Zone>

	<Zone name="United States Plus Mexico">
		<Country>MX</Country>
		<Zone>United States</Zone>
	</Zone>
</Zones>

With the keyref I'm validating that the content of the nested zone (in this case <Zone>United States</Zone>) matches one of the zone names.  Any idea why this no longer works?

Thanks,
Laura