I have a new XML document parsed in as DOM. Then I have an element to insert
according to the order spesified in a schema.
For example:
I have a XML:
<book>
<chapter1>Introduction</chaper1>
<chapter4>Chapter4</chapter4>
<chapter5>Chapter5</chapter5>
</book>
I need to insert "<book><chapter2>Chapter2></chapter2></book>". Accoding to
schema, the <chapter2> must be after <chapter1> and before <chapter3> that
is missing in this case.
(if I know the element to be insert at a certain position, in this case the
second, it's easy to do. However, generally the position is not known, only
an order determined by the schema.)
How can I generally solve this problem? Is there any way to read in the
schema and perform the insertion according to it?