Hi Sandy,
The answers to both of your questions are "yes". As a matter of fact, I simply made a copy of the ASBuilder.java file in the sample, added timestamp statement in the appropriate places to measure parsing costs, and then used the program to test a schema that I defined and an xml instance document conformant to the schema. Here is the code snippet (you can see it is basically the same as the ASBuilder.java in the samples):
//
// PARSING XML SCHEMAS
// try
{
ASModel asmodel = null;
for (i = 0; i < asfiles.size(); i++)
{
asmodel = parser.parseASURI((String)asfiles.elementAt(i));
parser.setAbstractSchema(asmodel);
}
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
} parser.setEntityResolver(EntityCache.instance());
try
{
long a = System.currentTimeMillis();
for (int j=0; j<100; j++)
parser.parseURI("http://localhost:8004/pcsp/test.xml");
long b = System.currentTimeMillis() - a; System.out.println("total time = "+b);
System.exit(1);
}
catch (Exception e){}
I passed the schema file as one of the argument to main(). The exact code in the sample builds an AbstractModel and sets it on the parser. Then the parser is used to parse an xml instance document 100 times. I expect that the subsequent rounds of parsing of this document use the same preparsed schema and thus there should be an performance improvement over non-AS parser, such as a DOMParser. But that was not what I saw - AS seems to provide no performance gain.
-Shengyou
At 07:44 PM 06/19/2002 -0400, [EMAIL PROTECTED] wrote:
>Did you call parseASXXX to parse the schema(s), and call setASModel to set them back onto the ASBuilder? You need to do that to reuse the preparsed schema(s).
Sandy Gao Software Developer, IBM Canada (1-905) 413-3255 [EMAIL PROTECTED]
Shengyou Zeng
<[EMAIL PROTECTED] To: [EMAIL PROTECTED]
om> cc:
Subject: xerces-j 2 sample ASBuilder - AS performance>
06/07/2002
07:15 PM>
Please respond
to
xerces-j-user>
The sample program dom.ASBuilder shipped with Xerces-j 2.0.1 "illustrates how to preparse xml schema documents and how to validate instance documents against preparsed schema grammars." (quotes from DOM Sample page for xerces-j 2). I was hoping that, because of schema preparsing, the performance of ASBuilder should improve compared to straight DOM 2. However, that is not the case. As a matter of fact, the DOM 3 implementation with schema preparsing fares worse than DOM 2 xerces-j (org.apache.xerces.parsers.DOMParser). For example, in my case, using the same schema and the same xml instance (parsing and validating 100x), ASBuilder costs 10000 ms while DOMParser costs 8000 ms. (In case you are wondering, I did set schema validation and namespace features to true for the DOMParser).
My understanding is that Abstract Schema preparses schema and validation of repeat xml documents uses the preparsed schema. This is what sample ASBuilder is supposed to demonstrate. Thus using Abstract Schema should save schema (loading and) parsing time. But why don't see the performance gain one would expect? What am I missing?
Thanks.
-Shengyou
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
