You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Hess Yvan <yv...@imtf.ch> on 2003/05/27 15:00:23 UTC

XML schema validation performance (precompilation?)

Hi,

I have to validate many XML documents against a XML schema that is always
the same. I use the following code to do the validation for each XML
document:

// Get document builder factory and set its properties
factory = DocumentBuilderFactory.newInstance();
factory.setAttribute("http://apache.org/xml/properties/schema/external-schem
aLocation", schemaNS + " " + schemaURL);
factory.setAttribute("http://apache.org/xml/features/validation/schema", new
Boolean(true));
factory.setAttribute("http://xml.org/sax/features/validation", new
Boolean(true));
factory.setAttribute("http://xml.org/sax/features/namespaces", new
Boolean(true));

// Get document parser and set its error handler
errorHandler = new XMLToolsValidationErrorHandler();
parser = factory.newDocumentBuilder();
parser.setErrorHandler(errorHandler);

// Parse the document
dom = parser.parse(docStream);

In this situation, I  presume that the XML schema is always parsed and
"transformed" that unfortunly take time and I would like to optimize it.

My questions are:

 - Is that right the XML schema is always parsed and "transformed" every
time I call parser.parse() method ?
- How can I optimize XML schema validation if I have every time the same
schema to use to validate many XML documents ? I would like to use something
like you can found into XSLT with precompiled stylesheet.

Thanks for your answer.

Yvan Hess


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


Re: XML schema validation performance (precompilation?)

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
see the xerces grammar FAQ.
Jeff
----- Original Message ----- 
From: "Hess Yvan" <yv...@imtf.ch>
To: <xe...@xml.apache.org>
Sent: Tuesday, May 27, 2003 6:00 AM
Subject: XML schema validation performance (precompilation?)


> Hi,
> 
> I have to validate many XML documents against a XML schema that is always
> the same. I use the following code to do the validation for each XML
> document:
> 


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


WBXML and DOM API

Posted by Asma Alazeib <as...@tuhh.de>.
Hello,

I'm trying to implement the DOM API to load WBXML, the thing is I want to
Load the WBXML tree (DOM) in memory without having to convert it to XML,
I've been trying for a long time to do this, but I think I'm stuck...Does
anyone have any suggestions?

Thanks,

Asma





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


Re: XML schema validation performance (precompilation?)

Posted by "K. Venugopal" <k....@sun.com>.
Hi Huan.


Hess Yvan wrote:

>Hi,
>
>I have to validate many XML documents against a XML schema that is always
>the same. I use the following code to do the validation for each XML
>document:
>
>// Get document builder factory and set its properties
>factory = DocumentBuilderFactory.newInstance();
>factory.setAttribute("http://apache.org/xml/properties/schema/external-schem
>aLocation", schemaNS + " " + schemaURL);
>factory.setAttribute("http://apache.org/xml/features/validation/schema", new
>Boolean(true));
>factory.setAttribute("http://xml.org/sax/features/validation", new
>Boolean(true));
>factory.setAttribute("http://xml.org/sax/features/namespaces", new
>Boolean(true));
>
>// Get document parser and set its error handler
>errorHandler = new XMLToolsValidationErrorHandler();
>parser = factory.newDocumentBuilder();
>parser.setErrorHandler(errorHandler);
>
>// Parse the document
>dom = parser.parse(docStream);
>
>In this situation, I  presume that the XML schema is always parsed and
>"transformed" that unfortunly take time and I would like to optimize it.
>
>My questions are:
>
> - Is that right the XML schema is always parsed and "transformed" every
>time I call parser.parse() method ?
>
>- How can I optimize XML schema validation if I have every time the same
>schema to use to validate many XML documents ? I would like to use something
>like you can found into XSLT with precompiled stylesheet.
>
 Xerces provides caching of grammers and by default grammers are not 
cached , please look in to the sample program 
xni/XMLGrammarBuilder.java  provided with xerces . And as jeff mentioned 
refer to [1].

[1]http://xml.apache.org/xerces2-j/faq-grammars.html

Regards
venu

>
>Thanks for your answer.
>
>Yvan Hess
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>  
>



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