  | |  | Keyrefs and mixed content | Keyrefs and mixed content 2003-08-01 - By Laura Smith
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: @(protected)@ 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="@(protected)"/> </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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6249.1"> <TITLE>Keyrefs and mixed content</TITLE> </HEAD> <BODY> <!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">The following schema and instance validated properly with the following:</FONT> </P>
<P><FONT SIZE=2 FACE="Courier New">Name: org/apache/xerces</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Specification-Title: Java API for XML Processing</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Specification-Vendor: Sun Microsystems Inc. </FONT>
<BR><FONT SIZE=2 FACE="Courier New">Implementation-Vendor: Apache Software Foundation</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Implementation-URL: <A HREF="http://xml .apache.org/xerces2-j">http://xml.apache.org/xerces2-j</A></FONT>
<BR><FONT SIZE=2 FACE="Courier New">Specification-Version: 1.2</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Implementation-Version: Xerces-J_2_0_1_01< /FONT>
<BR><FONT SIZE=2 FACE="Courier New">Implementation-Title: org.apache.xerces< /FONT>
<BR><FONT SIZE=2 FACE="Courier New">Comment: Xerces parser implementing JAXP< /FONT> </P>
<P><FONT SIZE=2 FACE="Arial">Why won't it validate properly with this version?< /FONT> </P>
<P><FONT SIZE=2 FACE="Courier New">Name: org/apache/xerces/impl/Version</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Comment: @(protected)@ for <A HREF="http:/ /xml.apache.org/xerces2-j">http://xml.apache.org/xerces2-j</A></FONT>
<BR><FONT SIZE=2 FACE="Courier New">Implementation-Title: org.apache.xerces .impl.Version</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Implementation-Version: 2.5.0</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Implementation-Vendor: Apache Software Foundation</FONT>
<BR><FONT SIZE=2 FACE="Courier New">Implementation-URL: <A HREF="http://xml .apache.org/xerces2-j/">http://xml.apache.org/xerces2-j/</A></FONT> </P>
<P><FONT SIZE=2 FACE="Arial">Here's the schema:</FONT> </P>
<P><FONT SIZE=2 FACE="Courier New"><?xml version="1.0" encoding= "UTF-8"?></FONT>
<BR><FONT SIZE=2 FACE="Courier New"><xs:schema xmlns:xs='<A HREF="http://www .w3.org/2001/XMLSchema'">http://www.w3.org/2001/XMLSchema'</A>></FONT> </P>
<P> <FONT SIZE=2 FACE="Courier New"> <xs:element name="Zones"></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><xs:complexType></FONT>
<BR> <FONT SIZE=2 FACE= "Courier New"><xs:sequence></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><xs:element name=" ;Zone" type="Zone" maxOccurs="unbounded"/></FONT>
<BR> <FONT SIZE=2 FACE= "Courier New"></xs:sequence></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"></xs:complexType></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><xs:key name="ZoneName" ;></FONT>
<BR> <FONT SIZE=2 FACE= "Courier New"><xs:selector xpath="./Zone"/></FONT>
<BR> <FONT SIZE=2 FACE= "Courier New"><xs:field xpath="@(protected)"/></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"></xs:key></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><xs:keyref name=" ;ZoneToZoneName" refer="ZoneName"></FONT>
<BR> <FONT SIZE=2 FACE= "Courier New"><xs:selector xpath="./Zone/Zone"/></FONT>
<BR> <FONT SIZE=2 FACE= "Courier New"><xs:field xpath="."/></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"></xs:keyref></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"> </xs:element></FONT> </P>
<P> <FONT SIZE=2 FACE="Courier New"> <xs:complexType name="Zone" mixed="true" ></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><xs:choice minOccurs="0 " maxOccurs="unbounded"></FONT>
<BR> <FONT SIZE=2 FACE= "Courier New"><xs:element name="Country" type="xs:string" /></FONT>
<BR> <FONT SIZE=2 FACE= "Courier New"><xs:element name="Zone" type="Zone"/>< /FONT>
<BR> <FONT SIZE=2 FACE="Courier New"></xs:choice></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><xs:attribute name="name " type="xs:string" use="optional"/></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"> </xs:complexType></FONT> </P>
<P><FONT SIZE=2 FACE="Courier New"></xs:schema></FONT> </P>
<P><FONT SIZE=2 FACE="Arial">And here's the instance:</FONT> </P>
<P><FONT SIZE=2 FACE="Courier New"><?xml version="1.0" encoding= "UTF-8"?></FONT>
<BR><FONT SIZE=2 FACE="Courier New"><Zones></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"> <Zone name="United States"></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><Country>US</Country>< /FONT>
<BR> <FONT SIZE=2 FACE="Courier New"> </Zone></FONT> </P>
<P> <FONT SIZE=2 FACE="Courier New"> <Zone name="United States Plus Mexico"></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><Country>MX</Country>< /FONT>
<BR> <FONT SIZE=2 FACE="Courier New"><Zone>United States</Zone ></FONT>
<BR> <FONT SIZE=2 FACE="Courier New"> </Zone></FONT>
<BR><FONT SIZE=2 FACE="Courier New"></Zones></FONT> </P>
<P><FONT SIZE=2 FACE="Arial">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?</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Thanks,</FONT>
<BR><FONT SIZE=2 FACE="Arial">Laura</FONT> </P>
</BODY> </HTML>
|
|
 |