I need to transform an xml doc and I want the output to be formatted so I use <xsl:output indent="yes" />
. But I want a specific element to not indent. For example, my xml (after any transformation, like removing elements etc) is unformatted like this:
<root><code><run><formula>xyz</formula></code></root>
with <xsl:output indent="yes" />
I getting output like this:
<root>
<code>
<run>
<formula>xyz</formula>
</run>
</code>
</root>
I am looking for output like this:
<root>
<code>
<run><formula>xyz</formula></run>
</code>
</root>
basically I don't want <run>
(and elements inside it) to format.
Can this be done with XSL? Or I need to parse the file, after XSL transformation, to remove \\n after <run>
and before </run>
?
(note: my xml is big with hundreds of elements. The above is just an example) (note 2: I am using java. Thus the java tag)
XSLT 3.0 allows you to say <xsl:output indent="yes" suppress-indentation="run"/>
. For this you will need to switch to an XSLT 3.0 processor, which in the Java world means Saxon.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.