Re: additional spaces in complex elements using PrettyFormat
SoTaNeZ <[email protected]> Thu, 17 Jan 2013 10:29:26 +0100
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <CAJypjWet=XYarsdQ3of4ij5R57tUpt4fsFMeoer+mSPjO1_u+g@mail.gmail.com> |
--===============1316243345== Content-Type: multipart/alternative; boundary=f46d042de45f8aa34004d378a154 --f46d042de45f8aa34004d378a154 Content-Type: text/plain; charset=ISO-8859-1 Thank you very much, your second solution works perfect. 2013/1/15 Rolf Lear <[email protected]> > > Hi S... > > If white-space is important to you you can do a number of things.... > > 1. you can use the *raw* Format (which changes nothing) instead of the > Pretty or Compact format, and then set up your JDOM content to have the > right whitespace in the right places, then the Outputter with Raw formatter > will not modify the whitespace (which both Pretty and Compact do). > 2. if only *part* of the XML document has significant whitespace (which I > think is your case), then you can use the xml:space="preserve" attribute > and JDOM will not modify any whitespace in that content. > > <paragraph align="justified" xml:space="preserve"> > According to the normalized curve A (LA<sub>eq inter</sub>) the > values... > </paragraph > > > Rolf > > > On 15/01/2013 3:56 AM, SoTaNeZ wrote: > > Hello. > > I have some complex elements in which their texts are mixed with some HTML > markup that I treat as XML elements. For example: > > ------------------------------------------------------ > <paragraph align="justified"> > According to the normalized curve A (LA > <sub>eq inter</sub> > ) the values... > </paragraph > > ------------------------------------------------------ > > The above example is in PrettyFormat. > > My intention is to use an XSL to transform this text to HTML, keeping > the HTML representation, so using "xsl:copy-of" I can copy the whole > paragraph as is. > The problem is that the XML elements inserted between the text are > represented in a new line, so the XLT transformation adds both white spaces > before and after these elements in the HTML output: > > ------------------------------------------------------ > According to the normalized curve A (LA eq inter ) the values... > ------------------------------------------------------ > > when the output I want should be: > > ------------------------------------------------------ > According to the normalized curve A (LAeq inter) the values... > ------------------------------------------------------ > > I cannot use the CompactFormat, because I need these XMLs to be readable > by humans. > > The problem is solved if I manually place these inner XML elements in > the same line with the rest of the text: > > ------------------------------------------------------ > <paragraph align="justified"> > According to the normalized curve A (LA<sub>eq inter</sub>) the > values... > </paragraph > > ------------------------------------------------------ > > Is there a way to tell JDOM to format complex XML elements (those having > text and other elements) this way, or maybe other workarounds? > > I prefer to avoid post-processing of the outputted XMLs files... > > Thank you very much. > > > > _______________________________________________ > To control your jdom-interest membership:http://www.jdom.org/mailman/options/jdom-interest/[email protected] > > > --f46d042de45f8aa34004d378a154 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thank you very much, your second solution works perfect.<br><br><div class= =3D"gmail_quote">2013/1/15 Rolf Lear <span dir=3D"ltr"><<a href=3D"mailt= o:[email protected]" target=3D"_blank">[email protected]</a>></span><br><blockqu= ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s= olid;padding-left:1ex"> =20 =20 =20 <div text=3D"#000000" bgcolor=3D"#FFFFFF"> <br> <div>Hi=A0 S...<br> <br> If white-space is important to you you can do a number of things....<br> <br> 1. you can use the *raw* Format (which changes nothing) instead of the Pretty or Compact format, and then set up your JDOM content to have the right whitespace in the right places, then the Outputter with Raw formatter will not modify the whitespace (which both Pretty and Compact do).<br> 2. if only *part* of the XML document has significant whitespace (which I think is your case), then you can use the xml:space=3D"preserve" attribute and JDOM will not modify a= ny whitespace in that content.<br> <br> <div> <div>=A0 =A0 <paragraph align=3D"justified" xml:space=3D"preserve"></div><div class=3D"im"> <div>=A0 =A0 =A0 According to the normalized curve A (LA<sub>= eq inter</sub>) the values...</div> <div>=A0 =A0 </paragraph=A0></div> </div></div> <br> Rolf<div><div class=3D"h5"><br> <br> On 15/01/2013 3:56 AM, SoTaNeZ wrote:<br> </div></div></div> <blockquote type=3D"cite"><div><div class=3D"h5">Hello. <div><br> <div>I have some complex elements in which their texts are mixed with some HTML markup that I treat as XML elements. For example:</div> <div><br> </div> <div>------------------------------------------------------</div> <div> <div>=A0 =A0 <paragraph align=3D"justified"></div= > <div>=A0 =A0 =A0 According to the normalized curve A (LA</div> <div>=A0 =A0 =A0 <sub>eq inter</sub></div> <div>=A0 =A0 =A0 ) the values...</div> <div>=A0 =A0 </paragraph=A0></div> </div> <div>------------------------------------------------------</div> <div><br> </div> <div>The above example is in PrettyFormat.</div> <div><br> </div> <div>My intention is to use an XSL to transform this text to HTML, keeping the HTML representation, so using "xsl:copy-of= " I can copy the whole paragraph as is.</div> <div>The problem is that the XML elements inserted between the text are represented in a new line, so the XLT transformation adds both white spaces before and after these elements in the HTML output:</div> <div><br> </div> <div> ------------------------------------------------------</div> <div> <div>According to the normalized curve A (LA=A0<font size=3D"1">e= q inter</font>=A0) the values...</div> </div> <div>------------------------------------------------------</div> <div><br> </div> <div>when the output I want should be:</div> <div><br> </div> <div>------------------------------------------------------</div> <div>According to the normalized curve A (LA<font size=3D"1">eq inter</font>) the values...</div> <div>------------------------------------------------------</div> <div><br> </div> <div>I cannot use the CompactFormat, because I need these XMLs to be readable by humans.</div> <div><br> </div> <div>The problem is solved if I manually place these inner XML elements in the same line with the rest of the text:</div> <div><br> </div> <div>------------------------------------------------------</div> <div> <div>=A0 =A0 <paragraph align=3D"justified"></div= > <div>=A0 =A0 =A0 According to the normalized curve A (LA<sub>eq inter</sub>) the values...</div> <div>=A0 =A0 </paragraph=A0></div> </div> <div>------------------------------------------------------</div> <div><br> </div> <div>Is there a way to tell JDOM to format complex XML elements (those having text and other elements) this way, or maybe other workarounds?</div> <div><br> </div> <div>I prefer to avoid post-processing of the outputted XMLs files...</div> <div><br> </div> <div>Thank you very much.</div> </div> <div><br> </div> <br> <fieldset></fieldset> <br> </div></div><pre>_______________________________________________ To control your jdom-interest membership: <a href=3D"http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourh= ost.com" target=3D"_blank">http://www.jdom.org/mailman/options/jdom-interes= t/[email protected]</a></pre> </blockquote> <br> </div> </blockquote></div><br> --f46d042de45f8aa34004d378a154-- --===============1316243345== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/[email protected] --===============1316243345==--