开发者

Validation against 10K XSD - performance problem

开发者 https://www.devze.com 2022-12-23 13:57 出处:网络
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 hom开发者_JS百科ep

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 hom开发者_JS百科epage. 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?


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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消