Hi, 

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++ 3.0 SAX2 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:*
==========================================================
SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
parser->setFeature(XMLUni::fgXercesSchema, true);
parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);

XMLCh* str (XMLString::transcode("D://Documents//CityGML.xsd"));

parser->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation, str);
==============================================================

*Results:*
Fatal Error: schemaLocation does not contain namespace-location pairs at line: 2

==============================================================

*XML Document Snippet:*

<?xml version="1.0" encoding="ASCII"?>
<CityModel xmlns="http://www.ikg.uni-bonn.de/sig3d/pilot3d"; 
xmlns:gml="http://www.opengis.net/gml"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://www.ikg.uni-bonn.de/sig3d/pilot3d/CityGML.xsd";>
...

==============================================================
*
Schema Snippet:*
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.citygml.org/citygml/profiles/base/1.0"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";
    targetNamespace="http://www.citygml.org/citygml/profiles/base/1.0"; 
elementFormDefault="qualified"
    attributeFormDefault="unqualified">
    <xs:import namespace="http://www.opengis.net/citygml/appearance/1.0"; 
schemaLocation="CityGML/appearance.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/building/1.0"; 
schemaLocation="CityGML/building.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/cityfurniture/1.0"; 
schemaLocation="CityGML/cityFurniture.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/cityobjectgroup/1.0"; 
schemaLocation="CityGML/cityObjectGroup.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/generics/1.0"; 
schemaLocation="CityGML/generics.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/landuse/1.0"; 
schemaLocation="CityGML/landUse.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/relief/1.0"; 
schemaLocation="CityGML/relief.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/transportation/1.0"; 
schemaLocation="CityGML/transportation.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/vegetation/1.0"; 
schemaLocation="CityGML/vegetation.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/waterbody/1.0"; 
schemaLocation="CityGML/waterBody.xsd"/>
    <xs:import namespace="http://www.opengis.net/citygml/texturedsurface/1.0"; 
schemaLocation="CityGML/texturedSurface.xsd"/>
</xs:schema>
==============================================================

Greets,
Dennis

Reply via email to