  | |  | Schema validation with xinclude | Schema validation with xinclude 2004-03-01 - By Stottlemyer, Carl
I am getting errors when I try to validate a document that uses XInclude against a schema. The version of xerces being used is: 2.6.2.
The problem I am having is with the xml:base attribute. The XInclude FAQ says that to solve this problem one must modify the schema elements to allow the xml:base attribute. Unfortunately, I have been unable to figure out how to modify my schema to allow the attribute.
Currently, I have three documents: contacts.xml, name.xml and contacts.xsd. When I parse contacts.xml I get the following error message: [Error] contacts.xsd:25:49: src-resolve: Cannot resolve the name 'xml:base' to a(n) 'attribute declaration' component. [Error] contacts.xsd:25:49: s4s-elt-invalid-content.1: The content of 'nameType' is invalid. Element 'attribute' is invalid, misplaced, or occurs too often. [Error] name.xml:2:6: Document is invalid: no grammar found. [Error] name.xml:2:6: Document root element "name", must match DOCTYPE root "null".
contacts.xml ----------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <contact xmlns="http://test" xmlns:xi="http://www.w3.org/2003/XInclude" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xmlns:xml="http://www.w3.org/XML/1998/namespace" xsd:schemaLocation="http://test contacts.xsd">
<xi:include href="name.xml"/> </contact>
name.xml -------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <name xmlns="http://test"> <first>Carl</first> <last>Stottlemyer</last> </name>
contacts.xsd ------------------------------------------------------------------------ ------------------------- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:test="http://test" targetNamespace="http://test" elementFormDefault="qualified" attributeFormDefault="unqualified"> <!-- (I also downloaded the xml.xsd from w3 and tried this) <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/> --> <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/> <xsd:element name="contact"> <xsd:complexType> <xsd:sequence> <xsd:element name="name" type="test:nameType" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name="nameType"> <xsd:sequence> <xsd:element name="first"/> <xsd:element name="last"/> </xsd:sequence> <xsd:attribute ref="xml:base" use="optional"/> </xsd:complexType> </xsd:schema>
Carl Stottlemyer
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"> <META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6487.1"> <TITLE>Schema validation with xinclude</TITLE> </HEAD> <BODY> <!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">I am getting errors when I try to validate a document that uses XInclude against a schema. The version of xerces being used is: 2.6.2.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">The problem I am having is with the xml:base attribute. The XInclude FAQ says that to solve this problem one must modify the schema elements to allow the xml:base attribute. Unfortunately , I have been unable to figure out how to modify my schema to allow the attribute.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Currently, I have three documents: contacts.xml, name.xml and contacts.xsd. When I parse contacts.xml I get the following error message: </FONT></P>
<P><FONT COLOR="#FF0000" SIZE=2 FACE="Courier New">[Error] contacts.xsd:25:49: src-resolve: Cannot resolve the name 'xml:base' to a(n) 'attribute declaration' component.</FONT>
<BR><FONT COLOR="#FF0000" SIZE=2 FACE="Courier New">[Error] contacts.xsd:25:49: s4s-elt-invalid-content.1: The content of 'nameType' is invalid. Element 'attribute' is invalid, misplaced, or occurs too often.</FONT></P>
<P><FONT COLOR="#FF0000" SIZE=2 FACE="Courier New">[Error] name.xml:2:6: Document is invalid: no grammar found.</FONT>
<BR><FONT COLOR="#FF0000" SIZE=2 FACE="Courier New">[Error] name.xml:2:6: Document root element "name", must match DOCTYPE root "null" ;.</FONT> </P>
<P><FONT SIZE=2 FACE="Arial">contacts.xml</FONT>
<BR><FONT SIZE=2 FACE="Arial">------------------------------------------------- ----------------</FONT>
<BR><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><?xml</FONT><FONT COLOR= "#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE= "Courier New">version=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New"> "1.0"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">encoding=</FONT><FONT COLOR=" #000080" SIZE=2 FACE="Courier New">"UTF-8"</FONT><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">?></FONT>
<BR><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><contact</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xmlns=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New" >"<A HREF="http://test">http://test</A>"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xmlns:xi=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"<A HREF="http://www.w3.org/2003/XInclude">http://www.w3.org/2003 /XInclude</A>"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT >
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xmlns:xsd=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"<A HREF="http://www.w3.org/2001/XMLSchema-instance">http://www.w3 .org/2001/XMLSchema-instance</A>"</FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xmlns:xml=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"<A HREF="http://www.w3.org/XML/1998/namespace">http://www.w3.org/XML /1998/namespace</A>"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"> </FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xsd:schemaLocation=</FONT><FONT COLOR="#000080" SIZE=2 FACE= "Courier New">"<A HREF="http://test">http://test</A></FONT>
<BR> <FONT COLOR="#000080" SIZE=2 FACE="Courier New"> </FONT> <FONT COLOR="#000080" SIZE=2 FACE="Courier New">contacts.xsd"</FONT><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">></FONT> </P>
<P> <FONT COLOR="#0000E1" SIZE=2 FACE ="Courier New"><xi:include</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">href=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"name.xml"</FONT><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">/></FONT>
<BR><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></contact></FONT> </P>
<P><FONT SIZE=2 FACE="Arial">name.xml</FONT>
<BR><FONT SIZE=2 FACE="Arial">------------------------------------------------- -------------</FONT>
<BR><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><?xml</FONT><FONT COLOR= "#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE= "Courier New">version=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New"> "1.0"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">encoding=</FONT><FONT COLOR=" #000080" SIZE=2 FACE="Courier New">"UTF-8"</FONT><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">?></FONT>
<BR><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><name</FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xmlns=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New" >"<A HREF="http://test">http://test</A>"</FONT><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">></FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Courier New"> </FONT> <FONT COLOR=" #0000E1" SIZE=2 FACE="Courier New"><first></FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">Carl</FONT><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></first></FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Courier New"> </FONT> <FONT COLOR=" #0000E1" SIZE=2 FACE="Courier New"><last></FONT><FONT COLOR="#000000" SIZE =2 FACE="Courier New">Stottlemyer</FONT><FONT COLOR="#0000E1" SIZE=2 FACE= "Courier New"></last></FONT>
<BR><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></name></FONT> </P>
<P><FONT SIZE=2 FACE="Arial">contacts.xsd </FONT>
<BR><FONT SIZE=2 FACE="Arial">------------------------------------------------- ------------------------------------------------</FONT>
<BR><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:schema</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xmlns:xsd=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"<A HREF="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001 /XMLSchema</A>"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">< /FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xmlns:xml=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"<A HREF="http://www.w3.org/XML/1998/namespace">http://www.w3.org/XML /1998/namespace</A>"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"> </FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">xmlns:test=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"<A HREF="http://test">http://test</A>"</FONT><FONT COLOR=" #000000" SIZE=2 FACE="Courier New"></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">targetNamespace=</FONT><FONT COLOR="#000080" SIZE=2 FACE= "Courier New">"<A HREF="http://test">http://test</A>"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">elementFormDefault=</FONT><FONT COLOR="#000080" SIZE=2 FACE= "Courier New">"qualified"</FONT><FONT COLOR="#000000" SIZE=2 FACE= "Courier New"></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">attributeFormDefault=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"unqualified"</FONT><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">></FONT>
<BR>
<BR><FONT COLOR="#228820" SIZE=2 FACE="Courier New"><!--</FONT>
<BR> <FONT SIZE=2 FACE="Arial">(I also downloaded the xml.xsd from w3 and tried this)</FONT>
<BR> <FONT COLOR="#228820" SIZE=2 FACE="Courier New"><xsd:import</FONT><FONT COLOR="#000000" SIZE=2 FACE= "Courier New"></FONT> <FONT COLOR="#228820" SIZE=2 FACE="Courier New">namespace= "<A HREF="http://www.w3.org/XML/1998/namespace">http://www.w3.org/XML/1998 /namespace</A>"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">< /FONT>
<BR> <FONT COLOR="#228820" SIZE=2 FACE="Courier New">schemaLocation= "xml.xsd"/></FONT>
<BR><FONT COLOR="#228820" SIZE=2 FACE="Courier New">--></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:import</FONT><FONT COLOR="#000000" SIZE=2 FACE= "Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">namespace= </FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"<A HREF="http://www .w3.org/XML/1998/namespace">http://www.w3.org/XML/1998/namespace</A>"</FONT ><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">/></FONT>
<BR>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:element</FONT><FONT COLOR="#000000" SIZE=2 FACE= "Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">name=< /FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"contact"</FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:complexType ></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:sequence></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd :element</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">name=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"name"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">type =</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"test:nameType" ;</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT>
<BR> <FONT COLOR=" #0000E1" SIZE=2 FACE="Courier New">maxOccurs=</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"unbounded"</FONT><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">/></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></xsd:sequence></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></xsd :complexType></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></xsd:element></FONT>
<BR>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:complexType</FONT><FONT COLOR="#000000" SIZE=2 FACE= "Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">name=< /FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"nameType"</FONT ><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:sequence> ;</FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:element</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">name =</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"first"</FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">/></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:element</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">name =</FONT><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"last"</FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">/></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></xsd:sequence ></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"><xsd:attribute< /FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR=" #0000E1" SIZE=2 FACE="Courier New">ref=</FONT><FONT COLOR="#000080" SIZE=2 FACE= "Courier New">"xml:base"</FONT><FONT COLOR="#000000" SIZE=2 FACE= "Courier New"></FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">use=</FONT ><FONT COLOR="#000080" SIZE=2 FACE="Courier New">"optional"</FONT> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New">/></FONT>
<BR> <FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></xsd:complexType></FONT>
<BR><FONT COLOR="#0000E1" SIZE=2 FACE="Courier New"></xsd:schema></FONT> </P>
<P><FONT SIZE=2 FACE="Arial">Carl Stottlemyer</FONT> </P>
</BODY> </HTML>
|
|
 |