[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] how to break into


Subject: Re: [xsl] how to break <preformat> into <p>
From: "Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 23 Mar 2015 11:05:34 -0000

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 variablebs 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="b&" 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="b&" attribute is present, programlisting
if it isnbt.

Gerrit

On 23.03.2015 11:54, Joga Singh Rawat jrawat@xxxxxxxxxxxxxx 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
GeschC$ftsfC<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.imsieke@xxxxxxxxx, http://www.le-tex.de

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

GeschC$ftsfC<hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard VC6ckler


Current Thread
Keywords
xsl