hi,
i tried to delete an element in xml..for that i used servlet coding...it is getting deleted but blank spaces are remaining i dont want that blank spaces..can any one do me needfull..here is my code..can any one check it
madhuri kunchala wrote:the code is in servlet...from servlet im deleting xml file
(His point was that the question has nothing to do with servlets, and everything to do with XML. You could be calling the same code from Swing, an Applet, a console program, anywhere.)
Define "it doesn't remove spaces". At what point do you see the spaces? What happens if you print out the node value immediately after removing the spaces?
madhuri kunchala
Ranch Hand
Joined: Mar 30, 2010
Posts: 350
posted
0
k..i got it..it is moved to xml..no one is responding to my question...
madhuri kunchala
Ranch Hand
Joined: Mar 30, 2010
Posts: 350
posted
0
it is going to delete and spaces are left..example here is my sample xml
'original xml file'
after doing delete of the pack..the output is
im getting spaces like this
</MA05>
<MA00>
i.e after end of first pack and start of next pack..
I'd probably just post-process the output file since you're not in control of how the transformer chooses to render XML (unless you are, in which case figure out what property needs to be set).
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12324
1
posted
0
Stop and think.
You already have the information you need - the offending blank lines are a child node of type TEXT_NODE and a direct child of the PACKS element (document root ?)
You want the TEXT_NODE between your MAxx Elements to only have one formatting crlf instead of several.
Now - how those extra lines got in there is not clear from my cursory examination of your code, but you should be able to locate the TEXT_NODE and change it.
Bill
madhuri kunchala
Ranch Hand
Joined: Mar 30, 2010
Posts: 350
posted
0
i tried according what you had suggested by unable to remove spaces..
David Newton wrote:I'd probably just post-process the output file since you're not in control of how the transformer chooses to render XML (unless you are, in which case figure out what property needs to be set).
With the caveat that this is silly, because inter-nodal space shouldn't matter.
William Brogden
Author and all-around good cowpoke
Rancher
David Newton wrote:I'd probably just post-process the output file since you're not in control of how the transformer chooses to render XML (unless you are, in which case figure out what property needs to be set).
With the caveat that this is silly, because inter-nodal space shouldn't matter.
madhuri kunchala
Ranch Hand
Joined: Mar 30, 2010
Posts: 350
posted
0
According to William Brogden, i had changed my transformer code...eventhough same problem arises....is there any solution for my problem..
David Newton wrote:I'd probably just post-process the output file since you're not in control of how the transformer chooses to render XML (unless you are, in which case figure out what property needs to be set).
With the caveat that this is silly, because inter-nodal space shouldn't matter.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12324
1
posted
0
I suppose you could always treat it as a pure text problem, reading the file line by line and discarding blank lines, writing the lines with content to a new file, which what David meant by "post process".
Or the equivalent in memory with a custom OutputStream - however I suspect that your code or the transformer you are using is somehow introducing the extra blank lines.
Bill
madhuri kunchala
Ranch Hand
Joined: Mar 30, 2010
Posts: 350
posted
0
hi,
i checked line by line...but i didnt see that where to remove the blank lines...
Er. Anyway, go through the output file line by line and remove any lines that are entirely whitespace, just like William already said. Still with the caveat that this should in no way be necessary if the XML is being parsed in any reasonable way. You realize you're talking about non-significant whitespace between elements, right?
madhuri kunchala
Ranch Hand
Joined: Mar 30, 2010
Posts: 350
posted
0
hi,
According to William and David i checked line by line and i used 'OutputStream' also..but im unable to remove the spaces...here is my modified code...can anyone help in this issue..