How to prevent formatting of specific nodes

Thursday, 26 June 2014 · 4 messages
EK
Erdal Karaca26 Jun 2014 12:04 #
Hi, Using org.basex.io.serial.Serializer to serialize nodes from a DB, I want to be able to prevent formatting/indentation of specific nodes. For example:
<body>
<pre><b>test</b></pre>
</body>
When serializing something like that, the output will be:
<body>
    <pre>
        <b>test</b></pre>
</body>
The desired output would be:
<body>
    <pre><b>test</b></pre>
</body>
I.e. the pre elements must not be indented. I only found this parameter for the serializer cdata-section-elements Which I guess would enclose the contents of the pre elements by CDATA:
<body>
    <pre><![CDATA[<b>test</b>]]></pre>
</body>
Which would not be the desired output. Thanks!
CG
Christian Grün26 Jun 2014 12:16 #
Hi Erdal, the "indent" serialization parameter should help you: http://docs.basex.org/wiki/Serialization Best, Christian
Quoted text · Erdal Karaca · 5 lines
On Thu, Jun 26, 2014 at 12:04 PM, Erdal Karaca <erdal.karaca.de at gmail.com> wrote: > <body> > <pre><b>test</b></pre> > </body>
EK
Erdal Karaca26 Jun 2014 12:20 #
Thanks, Christian! That parameter tells the serializer to "globally" (per serialization) turn indentation on/off, no? I would need to indent all elements in general but ignore indentation for specific elements. Is that covered by the indent parameter (it only accepts yes/no as value)? Thanks. 2014-06-26 12:16 GMT+02:00 Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 16 lines
> Hi Erdal, > > the "indent" serialization parameter should help you: > > http://docs.basex.org/wiki/Serialization > > Best, > Christian > > > On Thu, Jun 26, 2014 at 12:04 PM, Erdal Karaca > <erdal.karaca.de at gmail.com> wrote: > > <body> > > <pre><b>test</b></pre> > > </body> >
CG
Christian Grün26 Jun 2014 12:23 #
Quoted text · Erdal Karaca · 5 lines
> That parameter tells the serializer to "globally" (per serialization) turn > indentation on/off, no? > I would need to indent all elements in general but ignore indentation for > specific elements. > Is that covered by the indent parameter (it only accepts yes/no as value)?
Yes, this parameter is global. As far as I know, there is no option to locally control indentation, so you could use XQuery to build the desired XML representation which you can then serialize.

⚡Generated with XQuery