You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by allan horgan <al...@risaris.com> on 2004/04/13 10:48:24 UTC

Validating against an xsd without xsdSchemaLocation

Hi,

At the moment I validate my xml against my xsd by having my xml
reference my xsd in the xsdSchemaLocation attribute as standard and
using the parse method on the XercesDOMParser as follows:

    XercesDOMParser *parser = new XercesDOMParser;    
   
    parser->setValidationScheme(XercesDOMParser::Val_Always);
    parser->setDoNamespaces(true);
    parser->setDoSchema(true);
    parser->setValidationSchemaFullChecking(true);
    
    //Register an error reporter to catch errors in the parsing
    DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter();
    parser->setErrorHandler(errReporter);
    
    //Create a memBufInputSource to tell Xerces where to find the xml
    char bufId[] = "updatedNewData";
    MemBufInputSource mb((const   XMLByte* const) updatedNewData, 
			strlen(updatedNewData),XStr(bufId).unicodeForm());
    

    //Parse the incoming xml!
    try
    {
	parser->parse(mb);
    }





. However, in my application, I have my xsd cached in DOM form. I feel
that the regular way of validating could be speeded up if there was an
API available to parse a given XML input against a xsd in DOM form, eg
void parse(XmlCh *xml, DOMDocument *xsd);
Is there any way like this I could take advantage of the fact that I
already have the xsd cached in DOM form and not go through the method I
am using above, which I feel is probably redoing what I have already
done, ie reparsing my xsd?

Allan


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Validating against an xsd without xsdSchemaLocation

Posted by Gareth Reakes <pa...@parthenoncomputing.com>.
Hi,

> . However, in my application, I have my xsd cached in DOM form. I feel
> that the regular way of validating could be speeded up if there was an
> API available to parse a given XML input against a xsd in DOM form, eg
> void parse(XmlCh *xml, DOMDocument *xsd);
> Is there any way like this I could take advantage of the fact that I
> already have the xsd cached in DOM form and not go through the method I
> am using above, which I feel is probably redoing what I have already
> done, ie reparsing my xsd?

There are methods on DOMBuilder and XercesDOMParser to cache schema
grammars. The internal model for the grammar is not a DOM tree so you
would still have to serialize and then create an InputSource to pass into
the caching methods. However, you would only have to do this once so you
should realize good speed improvements.

Gareth

-- 
Gareth Reakes, Managing Director            +44-1865-811184
Parthenon Computing                http://www.parthcomp.com




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org