Well, there's no bug here, just an opportunity for improvement... 

Meanwhile I'm wondering if your argument against using SCM is really a stopper.

Firstly, although the schema is composite, is it really impossible to create an SCM file for the complete composite schema?

Secondly, the rules against combining schemas loaded using SCM might be over-simplistic. There might be circumstances in which loading a schema from SCM and then loading additional components from regular schema documents might work. (The main things than come to mind that could cause problems would be if the "regular schema documents" either (a) redefine, or (b) extend the substitution groups of, components defined in the precompiled SCM. It might be worth looking at the detail of your schemas and doing some experiments.

Michael Kay

On 11 Jun 2013, at 18:09, Peter Cowan wrote:

Dear Michael,

Further to my email regarding schema performance, I was wondering if it was worth raising a bug at saxonica.plan.io?

Best Wishes,


On 05/06/13 19:32, Michael Kay wrote:

Begin forwarded message:

From: Michael Kay <mike@saxonica.com>
Subject: Re: [saxon] Schema loading advice
Date: 5 June 2013 19:17:55 GMT+01:00
To: Mailing list for the SAXON XSLT and XQuery processor <saxon-help@lists.sourceforge.net>
Cc: Peter Cowan <prc@corefiling.co.uk>

Thanks for the enquiry. We haven't done detailed performance tests on schema loading but we are aware that there is lots of room for improvement and I'm hoping we can schedule some work on this soon. With large schemas it's often the case that large parts of the schema are unused and a considerable saving might be possible by doing lazy validation/compilation of components.

In the meantime the best I can suggest is to look at SCM, the schema component model. The Validate command allows you to output a .scm file containing the schema in compiled form, and this should be significantly faster to load than the original source schema documents. Of course this assumes that you are using the same schema repeatedly.

Michael Kay

On 4 Jun 2013, at 18:27, Peter Cowan wrote:

Hi All,

I'm using Saxon 9.5EE (under Java 1.6) to perform a large number of
schema aware XPath evaluations on xml documents.

The schemas I'm using are composite, around 3.4mb and are already in
memory provided by an API as DOM (backed by Xerces).

In some independent tests I've tried loading the schemas from in memory
DOMSources and StreamSources (backed by ByteArrayInputStreams) using the
load method on the Schema Manager object which takes about 3.8 seconds.
I then ran a similar test building a Schema with Xerces from the same in
memory sources and this took about 800ms

Regrettably we have to load the schema twice but ideally would like it
to be as fast as possible.
Are these kind of speeds normal?
Are there any tips to improve schema loading speed?
Do you require more information to answer the former questions?

Many thanks,


Peter Cowan, CoreFiling Limited
Phone: +44-1865-203192

How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
saxon-help mailing list archived at http://saxon.markmail.org/

Peter Cowan, CoreFiling Limited
Phone: +44-1865-203192