Xerces 3.0 XML Schema Validierung



  • Hi,

    Ich habe heut zum ersten mal versucht mit Hilfe von xerces ein XML Dokument gegen eine Schema Datei zu validieren. Leider hat dies nicht ganz funktioniert und ich frage mich wo der Fehler liegt? Zum Verständnis, ich würde gerne immer auf eine externe Schema-Datei verweisen.

    Mein Code:

    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);
    

    Ausgabe:

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

    Mein XML-Dokument:

    <?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">
    ...
    

    Meine Schema-Datei:

    <?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>
    


  • Wie die Meldung schon sagt: Vermutlich muss bei der Property fgXercesSchemaExternalSchemaLocation ein Namespace/Location-Paar übergeben werden. Sonst weiss der Parser ja auch nicht für welchen Namespace dieses Schema ist.

    XMLCh const* location = XMLString::transcode("http://www.ikg.uni-bonn.de/sig3d/pilot3d D:\\Documents\\schema.xsd");
    


  • Dieser Thread wurde von Moderator/in evilissimo aus dem Forum C++ in das Forum Rund um die Programmierung verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.


Anmelden zum Antworten