xsl-list
[Top] [All Lists]

Re: [xsl] how to break <preformat> into <p>

2015-03-23 06:05:40
You may transform it in two passes:

1. Create a programlisting with <linebreak/> elements, using only the
matching-substring instruction in analyze-string. Store it in a variable.

2. Transform the variable’s children using
for-each-group/@group-ending-with='linebreak' (or @group-starting-with).

Caveat: Make sure that you declare the variable
as="element(programlisting)"; if you omit the as="…" attribute, you will
get a document node containing a programlisting element. Selecting
$variable/node() will yield different elements for both cases:
programlisting/node() if the as="…" attribute is present, programlisting
if it isn’t.

Gerrit

On 23.03.2015 11:54, Joga Singh Rawat jrawat(_at_)aptaracorp(_dot_)com wrote:
Hi Guys,
We need a clue to break <preformat> into multiple paragraph. Using below xsl
we are not able to transform <bold>

Input
<preformat>
Line 1
Line <bold>2</bold>
Line 3
</preformat>

Required output
<programlisting>
<p>Line 1</p>
<p>Line <b>2</b></p>
<p>Line 3</p>
</programlisting>

XSL
<xsl:template match="preformat">
<programlisting>
 <xsl:for-each-group select="." regex="[\n\r]">
  <xsl:non-matching-substring>
   <p><xsl:value-of select="."/></p>
  </xsl:non-matching-substring>
 </xsl:for-each-group>
</programlisting>

Thanks in advance
...JSR



-- 
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>