tags:

views:

62

answers:

3

I have an XSD scheme which has 10K lines. It takes 5 seconds to validate my XML with 500 lines. I get dynamically XML via POST from external server, on every click of the user on my homepage. The validation takes 5+ seconds, which is very much for every click of the user. PHP Example:

$doc = new DOMDocument();
$doc->load('file.xml'); //100 to 500 lines
$doc->schemaValidate('schema.xsd'); //schema.xsd 10 000 lines

Do you have any idea how I can validate the XML against the XSD faster?

A: 

You could create a subset of the XSD, which contains only the parts you need for your site. Validate against the full schema only after the final submit.

nfechner
I tought about this too, but unfortunately I can not define a subset. I need the whole scheme.
Maybe this might help (but only on Windows systems):http://objectmix.com/xml-soap/86164-validating-xml-file-against-xml-schema-using-javascript.htmlBut I can't images that might really be faster.
nfechner
+1  A: 

Some things to check:

  1. Is the schema a local file, or are you fetching it over the network (e.g. via http: or file: to a mounted volume)?

  2. Can you cache your schema? Many schema validation engines let you load the schema and cache it, and then do multiple validations against an internal representation.

  3. What does your schema look like? 5 seconds for a 10K schema seems pretty slow.

  4. What XML schema validator are you using?

lavinio
A: 

Use a different XML library and/or do your remote operation in the background and have the web read the latest cache.

NeuroScr