[xsl] insert tags out of context in XSL

Subject: [xsl] insert tags out of context in XSL
From: Peter Carlson <carlson@xxxxxxxxxxxxxxxxx>
Date: Fri, 03 May 2002 08:11:34 -0700

I am trying to break up a single block of text into multiple blocks at the
linefeed marker.

I found the l2br solution in the FAQ, but I don't want to put a <br />, I
want to use </para><para>.

Since these tags are out of context in the xsl, it won't work since it's not
valid XML. I tried using the &lt;para&gt;, but they are considered tags in
the next transform.

Any suggestions or pointing to the correct FAQ would be helpful.



My XML looks like


I want to transform it to


The code I am using to convert at the linefeed is (from skew.org)
See notes in ### below for where I want to put </para><para>

    <xsl:template name="lf2br">
        <!-- import $StringToTransform -->
        <xsl:param name="StringToTransform"/>
            <!-- string contains linefeed -->
            <xsl:when test="contains($StringToTransform,'&#xA;')">
                <!-- output substring that comes before the first linefeed
                <!-- note: use of substring-before() function means
                <!-- $StringToTransform will be treated as a string,
                <!-- even if it is a node-set or result tree fragment.
                <!-- So hopefully $StringToTransform is really a string!
                <!-- by putting a 'br' element in the result tree instead
                <!-- of the linefeed character, a <br> will be output at
                                <!-- that point in the HTML
<!-- #######THIS IS WHERE I WANT TO PUT </para><para> ########-->
                <!-- repeat for the remainder of the original string -->
                <xsl:call-template name="lf2br">
                    <xsl:with-param name="StringToTransform">
            <!-- string does not contain newline, so just output it -->
                <xsl:value-of select="$StringToTransform"/>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread