W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2010

Re: Optimizing a schema.

From: Cheney, Edward A SSG RES USAR USARC <austin.cheney@us.army.mil>
Date: Thu, 22 Jul 2010 06:51:52 -0500
To: Casey Jordan <casey.jordan@jorsek.com>
Cc: xmlschema-dev@w3.org
Message-ID: <f70c88d7e4b6.4c47ea88@us.army.mil>
Casey,

The only formal method is to create a series of style rules to evaluate input against.  To improve processing speed I recommend setting the input to an array and splitting each element into its own index of that array.  When the presence of an element fails one of your style rules convert that element into an empty string, but do not remove the index.  Splicing arrays is extremely slow in JavaScript.  DOM methods are also extremely slow, so do not use them.  Instead use the join method on your array and output the array using a single innerHTML method if in a browser or document.write from a command line interpreter.  Eliminating DOM methods from JavaScript will reduce processing time to as much as one forth the original time.  Eliminating a series of splice methods in addition to removing DOM methods from your JavaScript can push your code from being four times faster to as much as six times faster to evaluate.

I recommend passing through the entire array once without any recursive logic and performing separate iterative evaluations, such as a function call from inside a loop that returns prematurely only when changes no longer occur.

If possible I would avoid my prior suggestions as much as possible by forcing as much of this automation into your XSLT engine and performing as little effort as possible within your JS code.

Austin Cheney
Received on Thursday, 22 July 2010 11:52:29 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:22 GMT