Xerces-C++ Schema validation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nuno

    Xerces-C++ Schema validation

    Hello,

    I'm looking for a way of validating/parsing the xsd file (schema), i
    only been able of validating the xml file with the corresponding
    schema, but what i want is only validate the xsd file, to check if the
    schema is valid.

    I'm using Xerces-C++ and the only thing that i found is a way of
    parsing the xml file with the xml schema like this:

    SAX2XMLReader* parser = XMLReaderFactor y::createXMLRea der();
    ...
    parser->loadGrammar(xs dFile.c_str(), Grammar::Schema GrammarType,
    true);
    parser->setFeature(XML Uni::fgXercesUs eCachedGrammarI nParse, true);
    parser->parse(xmlFile. c_str());

    But when i try this with only the xsd file
    (ex:parser->parse(xsdFile. c_str());) the parser gives me these errors:
    ERR: Unknown element 'xs:element'
    ERR: Attribute 'ref' is not declared for element 'xs:element'
    ERR: Unknown element 'xs:schema'
    ERR: Attribute '{http://www.w3.org/2000/xmlns/}xs' is not declared for
    element 'xs:schema'
    ERR: Unknown element 'xs:element'
    ERR: Attribute 'name' is not declared

    My question is:
    is there any way in Xerces-C++ to validate one xsd file only, not the
    xml file against it's schema?

    Thanks
    Nuno

  • spiff

    #2
    Re: Xerces-C++ Schema validation

    Hi Nuno!

    AFAIK Xerces can't do this for you. Using Saxon-SA you can validate the
    schema itself.

    Regards
    spiff


    ValidatorBuddy - Use Xerces, Saxon or MSXML in XMLSpy


    Nuno schrieb:
    Hello,
    >
    I'm looking for a way of validating/parsing the xsd file (schema), i
    only been able of validating the xml file with the corresponding
    schema, but what i want is only validate the xsd file, to check if the
    schema is valid.
    >
    I'm using Xerces-C++ and the only thing that i found is a way of
    parsing the xml file with the xml schema like this:
    >
    SAX2XMLReader* parser = XMLReaderFactor y::createXMLRea der();
    ...
    parser->loadGrammar(xs dFile.c_str(), Grammar::Schema GrammarType,
    true);
    parser->setFeature(XML Uni::fgXercesUs eCachedGrammarI nParse, true);
    parser->parse(xmlFile. c_str());
    >
    But when i try this with only the xsd file
    (ex:parser->parse(xsdFile. c_str());) the parser gives me these errors:
    ERR: Unknown element 'xs:element'
    ERR: Attribute 'ref' is not declared for element 'xs:element'
    ERR: Unknown element 'xs:schema'
    ERR: Attribute '{http://www.w3.org/2000/xmlns/}xs' is not declared for
    element 'xs:schema'
    ERR: Unknown element 'xs:element'
    ERR: Attribute 'name' is not declared
    >
    My question is:
    is there any way in Xerces-C++ to validate one xsd file only, not the
    xml file against it's schema?
    >
    Thanks
    Nuno

    Comment

    Working...