How to take effect on dom manipulation???

K

Ksou

I need to copy a node from tree A to tree B. And then export tree B as image
by an API org.apache.batik.transcoder.image.JPRGTranscoder. But I got a
strange thing that the exported image does not have expected effect. But I
can get the manipulated one when I export it as XML file by
javax.xml.transform.Transformer.

I want to know is there any method I need to invoke after dom manipulated
for making manipulation effective.

Here is the code for manipulating the tree:
.....
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
Document document = documentBuilderFactory.newDocumentBuilder().parse(new
StringBufferInputStream(xmlString));

Document originalDocument =
documentBuilderFactory.newDocumentBuilder().parse(new
File("C:\\sample.svg"));
// remove a node
Element manipulatedGroupElement =
originalDocument.getElementById("manipulatedGroup");
Node manipulatedGroupParentNode = manipulatedGroupElement.getParentNode();
manipulatedGroupParentNode.removeChild(manipulatedGroupElement);

// add a new node which is copied from anther tree
Node clonedNode =
originalDocument.importNode(document.getElementById("manipulatedGroup"),true
);
manipulatedGroupParentNode.appendChild(clonedNode);
.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top