Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding node to doc

 
Guru Vasu
Greenhorn
Posts: 9
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to XML/XSLT and I am trying to do the following and I receive a WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

I was able to see the logic behind it and use doc.importNode(child, true) and that didnt work.

I would appreciate any help/advice.





thank you
 
Paul Clapham
Sheriff
Posts: 21319
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"true cube", welcome to JavaRanch. We're friendly here, but we do require members to have valid display names.

Display names must be at least two words: your first name and your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names will be closed.

(And it would also help if you could explain what "didn't work" meant in your original post.)
 
Guru Vasu
Greenhorn
Posts: 9
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thank you for your reply. Just updated my profile.

the error that I was getting was WRONG_DOCUMENT_ERR: A node is used in a different document -- which I just managed to fix by chagning my code to


from



But got a java.lang.UnsupportedOperationException. Here is what I am trying to do.

Extending AbstractXsltView, I am trying to domify my objects and add it to the model object

Here is my code



Do you (or anyone) know of a way to achieve the same in any fashion. Spring website provides an example which works for me (but its too simple for me to use it to comprehend the problem in the above situation).

Thank you for your help in advance
Guru
 
Paul Clapham
Sheriff
Posts: 21319
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your document already has a root node, right? And an XML document can only have one root node. So when you try to add another child to the document, you are violating that rule. Probably you meant to add that node somewhere lower in the tree.
 
Guru Vasu
Greenhorn
Posts: 9
Eclipse IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are right .. took a while for me to figure that out - but commented out the code (//Element rootElement = doc.createElement(root);) and I was able to append the node to the doc.

but now I am getting a java.lang.UnsupportedException - when Spring tries to render the page out - which is generated from NodeAdapter(from Domify jar)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic