Ok, I turned on namespace processing using setDoNamespace(true), but the
results are not what I expected (see below). I want to use an external
schema specified by the caller and not the schema called out in the XML
document. How do I do this with Xerces? And what exactly is the cause of
the below error?

========================================================================
=================
Error reported by the Parser

<?xml-stylesheet type="text/xsl" href="BCME_Transform.xsl"?>
<bcme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
Line 4::Column 58
xsi:noNamespaceSchemaLocation="787_BCMEdition_v1.1.xds">

Parser Error Message: The schemaLocation attribute does not contain
pairs of values. 
========================================================================
==================

DeWayne Dantlzer
206-544-3658


-----Original Message-----
From: Alberto Massari [mailto:[email protected]] 
Sent: Thursday, January 08, 2009 11:30 PM
To: [email protected]
Subject: Re: Validation using a schema

You also need to turn on namespace processing using
setDoNamespaces(true)

Alberto

Dantzler, DeWayne C wrote:
> Hello,
>
> I trying for the first time to validate an XML document with a schema,

> but I'm not sure of the results from the parser. I'm currently using 
> Xerces C++ 2.8.0 DOM Parser. What is the correct syntax to specify a 
> schema? If the schema and xml file are in the same directory can I 
> just use the filename of the schema or do I have to specify a full
pathname?
> If the schema is not in the same directory or location then what is 
> the correct syntax? Here's what I've done.
>
> Code snippet:
> ==========================================================
> //perform the necessary DOM Parser init and setup ... omitting all the

> gory details
>
> //setup the Entity Resolver to redirect the parser to use the external

> Schema _XmlDOMParser->setEntityResolver(resolver);
>
> //Turn on the necessary features to allow validation by an external 
> Schema _XmlDOMParser->setValidationScheme(_XmlDOMParser->Val_Always);
>
> //enable schema processing
> _XmlDOMParser->setDoSchema(true);
>
> //specify schema to use where scheme syntax is the filename i.e 
> bcme.xsd _XmlDOMParser->setExternalSchemaLocation((const char* 
> const)schema); _XmlDOMParser->loadGrammar(schema, 
> Grammar::SchemaGrammarType, true);
>
>
> //ignore DTD's
> _XmlDOMParser->setSkipDTDValidation(false);
>
> //attempt to parse the xml
> _XmlDOMParser->parse(xmlDoc2Parse);
> ==============================================================
>
> Results: Lots of Parser Errors but several of the elments are defined 
> in the schema. See schema and xml below
>
> The following error occurred during XML Schema or DTD validation
>
> XML Parser Error in file "bcme.xml"
>
> <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet 
> type="text/xsl" href="BCME_Transform.xsl"?>
> Line 3::Column 6      <bcme
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>
> Parser Error Message: Unknown element 'bcme'
>
> The following error occurred during XML Schema or DTD validation
>
> XML Parser Error in file "bcme.xml"
>
> <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet 
> type="text/xsl" href="BCME_Transform.xsl"?>
> Line 3::Column 17     <bcme
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>
> Parser Error Message: Attribute 'xmlns:xsi' is not declared for 
> element 'bcme'
>
> The following error occurred during XML Schema or DTD validation
>
> <?xml-stylesheet type="text/xsl" href="BCME_Transform.xsl"?> <bcme 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> Line 4::Column 32
> xsi:noNamespaceSchemaLocation="BCMEdition_v1.1.xds">
>
> Parser Error Message: Attribute 'xsi:noNamespaceSchemaLocation' is not

> declared for element 'bcme'
>
> The following error occurred during XML Schema or DTD validation
>
> <bcme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:noNamespaceSchemaLocation="BCMEdition_v1.1.xds">
> Line 5::Column 11     <edition>
>
> Parser Error Message: Unknown element 'edition'
>
> The following error occurred during XML Schema or DTD validation
>
> xsi:noNamespaceSchemaLocation="BCMEdition_v1.1.xds">
> <edition>
> Line 6::Column 15
> <editionid>D633W101-AFA_20080604.0000000000</editionid>
>
> Parser Error Message: Unknown element 'editionid'
> ==============================================================
>
> XML Document Snippet:
>
> <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet 
> type="text/xsl" href="BCME_Transform.xsl"?> <bcme 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  xsi:noNamespaceSchemaLocation="BCMEdition_v1.1.xds">
>   <edition>
>     <editionid>D633W101-AFA_20080604.0000000000</editionid>
>     <editionType>Replace</editionType>
>     <editionNumber>0000000000</editionNumber>
>   </edition>
>
> ==============================================================
> Schema Snippet
>
> <?xml version="1.0" encoding="UTF-8"?> <xs:schema 
> xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>       
>       <xs:element name="bcme">
>               <xs:complexType>
>                       <xs:sequence>
>                               <xs:element ref="edition"/>
>                               <xs:element ref="publication"/>
>                               <xs:element ref="files"/>
>                               <xs:element ref="toc"/>
>                       </xs:sequence>
>               </xs:complexType>
>       </xs:element>
>       <xs:element name="edition">
>               <xs:complexType>
>                       <xs:sequence>
>                               <xs:element ref="editionid"/>
>                               <xs:element ref="editionType"/>
>                               <xs:element ref="editionNumber"/>
>                               <xs:element ref="lastEdition"
> minOccurs="0"/>
>                       </xs:sequence>
>               </xs:complexType>
>       </xs:element>
> ==============================================================
>
> DeWayne Dantlzer
>
>   

Reply via email to