Thanks for your reply. I have a program that modifies the source xml files in some specific positions. My clients want the output xml file should be changed only in those specific portions.
So when the output file changes the elements out of those specific portions my clients get confused. They do not want this unwanted changes.
Is there any fix?
Regards.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 11691
posted
0
The only "fix" I can think of would be to forget treating the input and output as XML and treat it as text.
A bit of a pain to program but it would ensure that <tag/> and <tag></tag> and all the various formatting crlfs and tabs that people don't think about when looking at an XML document don't get changed.
Well, it looks like the XMLWriter might have an option to output empty elements in the short form or in the long form, based on that code you posted. But it can't possibly have an option "output in the same form as the original document" because the XMLWriter can't know what the form in the original document was. That's because the parser doesn't keep track of that.
And that's because it doesn't matter. If your customer thinks it matters then they are making a mistake and you should educate them. It doesn't matter.
asfak mahamud
Greenhorn
Joined: Apr 17, 2008
Posts: 5
posted
0
Thanks for your reply.
I have solved the problem almost like the way William Brogden has said.
1. At first I have taken the xml file and done a "find and replace operation" to all the "></" places with "a long special text" that must not occur in the xml file using apache common io.
2. Then I did my usual task and got the output file.
3. Then I did find and replace operation again upon both input and output file. This time I only replaced my "a long special text" with an empty string.
That's it.
Regards.
>
This message was edited 1 time. Last update was at by asfak mahamud
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 11691
posted
0
Ha! That is a rather elegant solution, thanks for reporting it.
Bill
subject: empty xml element is changed in the output while using dom4j-1.6.jar