

Looking for better way to determine "Insert-able Elements" - DOM3 Validation / XML Schema

From: Casey Jordan <casey.jordan@jorsek.com>
Date: Thu, 22 Jul 2010 12:36:28 -0400
Message-ID: <AANLkTikPSJGjIw6qkPFLQOvZXTFYbK5GSRsh1yrmMYqg@mail.gmail.com>
To: xmlschema-dev@w3.org, www-dom@w3.org
Hi group,

I have implemented the DOM3 Validation spec in JavaScript, but am running
into some efficiency issues.

Mainly with methods like: allowedNextSiblings(), allowedPreviousSiblings(),

All of these methods are created to let the user determine what elements
that can be inserted at a given point.

For instance a simplified example would work as follows.


 <element name="c1"/>
 <element name="c2"/>
 <element name="c3"/>

Thus if I was to ask "What elements can be inserted after <c1/>, I would get

IE <c1>.allowedNextSiblings() == NameList(<c2/>)

So here is my problem, the only way I have been able to reliably get the
correct results is by inserting and validating for each element.

The steps look something like this:

1.) Determine all the elements that can be child nodes of the parent node.
IE DOM3 Validtion allowedChildren()
2.) Insert an empty element for each one at every possible insertion point
and validate.
3.) When insertion produces a valid structure, that element is flagged as
insert-able at given point.

This is extremely accurate, and will work with very complex patterns, but
also *extremely inefficient*, especially in JavaScript.

I would be really appreciative if anyone could help me better understand how
this can be done more efficiently.



Casey Jordan
Jorsek Software LLC.
"CaseyDJordan" on LinkedIn, Twitter & Facebook
Cell (585) 348 7399
Office (585) 239 6060

the information contained herein is prohibited.  If you have received
Thank you.
Received on Thursday, 22 July 2010 16:37:05 GMT
