How to prevent formatting of specific nodes
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!
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@gmail.com> wrote:
<body> <pre><b>test</b></pre> </body>
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@gmail.com>:
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@gmail.com> wrote:
<body> <pre><b>test</b></pre> </body>
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.
participants (2)
-
Christian Grün -
Erdal Karaca