• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help needed on "Expand empty XML node"

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
 
reply
    Bookmark Topic Watch Topic
  • New Topic