• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Help needed on "Expand empty XML node"

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to output xml node like below

<tag></tag>

instead of

<tag/>

Currently Iam doing this with DOM parser using java

Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
DOMSource domSource = new DOMSource((Node) doc);
StreamResult result = new StreamResult(file);

transformer.transform(domSource, result);

Please help... .
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why? They're semantically equivalent. All standard libraries will likely use the short form.
 
Mamatha Kv
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I agree they are semantically equivalent.
But in our case, the input xml files given by the clients for translations. We translate the node content and write back the xml file using DOM. In this process the empty nodes are replaced as <tag/>.

So when the clients view the xmls they see the difference, the way these tags are written back.

Is there way we can override this property to expand the empty nodes/tag.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mamatha Kv wrote:

So when the clients view the xmls they see the difference, the way these tags are written back.


Since they are semantically equal, there's shouldn't be a problem if the client sees them rendered in a different way. This discussion is similar to what was discussed sometime back here
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your client simple does not understand that the two forms are equivalent, you could always write your own serializer.

Bill
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nah... all it should take is saying to the client "That's an empty element too. It works exactly the same as the empty element you typed in. There's no difference, nothing to worry about."
 
Fire me boy! Cool, soothing, shameless self promotion:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic