classpathx-xml
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpathx-xml] bug: insertBefore() with DocumentFragments


From: Nic Ferrier
Subject: [Classpathx-xml] bug: insertBefore() with DocumentFragments
Date: 20 Mar 2003 04:01:29 +0000

inserting DocumentFragments with multiple children in them doesn't
seem to work.

with one child it works, with multiples it doesn't.


The following code illustrates the problem:


String[] toAdd = ...
String clauseToAdd = ...
Element toEdit = ... // some element in the Document.

// Get a doc fragment containing one child for each of 
// the clauses specified in toAdd[] (these come from other docs).
DocumentFragment clauseToAdd = precedentDOM.createDocumentFragment();
getClauses(toAdd, clauseToAdd);

// Add the contents of the fragment AFTER the toEdit element.
Node clauseSection = (Element) toEdit.getParentNode();
if (clauseSection.getChildNodes().getLength() == 1)
        clauseSection.appendChild(clauseToAdd);
else {  
        Node insertionPoint = toEdit.getNextSibling();
        while (! (insertionPoint instanceof Element))
                insertionPoint = insertionPoint.getNextSibling();

///////  this line causes the problem.
        clauseSection.insertBefore(clauseToAdd, insertionPoint);
}


I get a NullPointerException,
        at gnu.xml.dom.DomNode.insertBefore(DomNode.java:585)
        at gnu.xml.dom.DomNode.insertBefore(DomNode.java:614)


The method works perfectly well with the crimson in the jdk.



Nic





reply via email to

[Prev in Thread] Current Thread [Next in Thread]