[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

insert tags out of context in XSL

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

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.

Thanks

--Peter

My XML looks like

<root>
<para>xxx
yyy
zzz
</para>

I want to transform it to

<root>
    <para>xxx</para>
    <para>yyy</para>
    <para>zzz</para>
</root>




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"/>
        <xsl:choose>
            <!-- 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!
-->
                <xsl:value-of
select="substring-before($StringToTransform,'&#xA;')"/>
                <!-- 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> ########-->
                <br/>
                <!-- repeat for the remainder of the original string -->
                <xsl:call-template name="lf2br">
                    <xsl:with-param name="StringToTransform">
                        <xsl:value-of
select="substring-after($StringToTransform,'&#xA;')"/>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <!-- string does not contain newline, so just output it -->
            <xsl:otherwise>
                <xsl:value-of select="$StringToTransform"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.