From: <al...@sa...> - 2016-05-03 13:54:40
|
We assumed vtd-xml was just a fast XML parser, so we used other tools/apis to format the XML and control whitespaces. We take the bytes from vtdnav.getXML().getBytes() and pass them to a stream to be used with javax.xml.transform.Transformer. The Transformer allows you to set properties to control indentation and effectively takes out the whitespace you see with vtd-xml. It also handles adding newlines, whether they are in the source XML or not. This keeps the formatted xml from being one long line. We use vtd-xml to create and parse XML for applications and processes. Its the best tool for the job. We use javax.xml classes to format XML for people and documentation. Regards, Al G ---------- Original Message ----------- From: Jimmy Zhang <jz...@xi...> To: Suresh Naidu <sur...@gm...>, Jimmy Zhang <jz...@xi...> Cc: vtd...@li... Sent: Mon, 02 May 2016 21:49:19 -0500 Subject: Re: [Vtd-xml-users] Suggestion in Removing the spaces after Removing the Element > The current implementation of expandWhite space is greedy, it will eat up all white spaces surrounding the element, > > more fine-grained control will be introduced in next release of vtd-xml ...2.13 that is... > > > ----- Original Message ----- > > From: Suresh Naidu <sur...@gm...> > > To:"Jimmy Zhang" <jz...@xi...> > > Cc: > > Sent:Sun, 1 May 2016 23:40:42 +0200 > > Subject:Re: [Vtd-xml-users] Suggestion in Removing the spaces after Removing the Element > > Dear Zhang, > > Thanks .I have checked your solution .I agree to you and I have posted our discussion ,sample on stack overflow . > > Still I have a concern,the solution is not fully correct to our requirement. > > Input to the program is: > > <root> > <address1>Address1</address1> > <name>suresh</name> > <address>Address</address> > <address2>Address2</address2> > </root> > > Output got: > > <root> > <address1>Address1</address1><address>Address</address> > <address2>Address2</address2> > </root> > > Output Expected: > > <root> > <address1>Address1</address1> > <address>Address</address> > <address2>Address2</address2> > </root> > > Can this be achievable as we should not change the format of it. > > Thanks & Regards, > G. Suresh Naidu > > On Sun, May 1, 2016 at 2:32 AM, Jimmy Zhang <jz...@xi...> wrote: > > > After some polishing I made your code work... see my attachment, > > I have a request: would you please post a question on stack overflow, so I can respond, and the content of our correspondence can thus be made available to public and help them as well > > > ----- Original Message ----- > > > From: Suresh Naidu <sur...@gm...> > > To:"Jimmy Zhang" <jz...@xi...> > > Cc: > > Sent:Sun, 1 May 2016 01:35:36 +0200 > > Subject:Re: [Vtd-xml-users] Suggestion in Removing the spaces after Removing the Element > > Dear Zhang, > > I have tried with expandwhitespaces method with multiple ways,but i could not get the output. > > I have not find much examples about its usage. > > Can you check and let me know if i am using it correctly or not. > > I have attached the source code and file used. > > Thanks & Regards, > G . Suresh Naidu > > On Sat, Apr 30, 2016 at 8:39 PM, Jimmy Zhang <jz...@xi...> wrote: > > Yes, there is, in version 2.12, there is a method called expandWhiteSpace in VTDNav, it works like the following > > public final long expandWhiteSpaces(long l) > New in v2.12 This method will take a segment descriptor and return a new descriptor that includes all the leading and trailing white spaces around the input segment It has no effect on CDATA A typical usage would be 'expandWhiteSpaces(getElementFragment())'Parameters:l - upper 32 bits length of the segment, lower 32 bits offset of the segment, unit is byte offsetReturns:a long 64 bit segment descriptorThrows:NavException > > > ----- Original Message ----- > > > From: Suresh Naidu <sur...@gm...> > > To:"Jimmy Zhang" <jz...@xi...> > > Cc: > > Sent:Sat, 30 Apr 2016 06:23:38 +0200 > > Subject:Re: [Vtd-xml-users] Suggestion in Removing the spaces after Removing the Element > > Thanks zhang for your reply.It is not a show stopper..but the requirement from client is to remove that spaces...is there an option to do that with vtd- xml. > Thanks & Regards, > G.Suresh Naidu > On Apr 30, 2016 3:00 AM, "Jimmy Zhang" <jz...@xi...> wrote: > > How big a deal is it ? cosmetic or show stopping? > > > ----- Original Message ----- > > From: Suresh Naidu <sur...@gm...> > > To:<vtd...@li...> > > Cc: > > Sent:Fri, 29 Apr 2016 10:40:39 +0200 > > Subject:[Vtd-xml-users] Suggestion in Removing the spaces after Removing the Element > > Dears, > > We are using VTD XML for our application.Can you help us in solving the issue in our application. > > The issue is: > > input xml: > > <root> > <name>suresh</name> > <address>Address</address> > </root> > > output xml: > > <root> > > <address>Address</address> > </root> > > But i want the output to be: > > <root> > > <address>Address</address> > > </root> > > When i remove the element with xmlmodifier it is creating an empty space(new line) for the removed element. > > Is there any possibility to remove that vtdxml? > > Thanks & Regards, > G . Suresh Naidu > > > > ------- End of Original Message ------- |