Re: [xsl] Putting characters in an element

Subject: Re: [xsl] Putting characters in an element
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 2 Oct 2003 14:21:05 +0100

This is a FAQ for both xslt 1 and 2, string oerations need strings as
input and get a string by taking the string value of any nodes supplied,
so all markup is lost on input to teh function, so clearly can't be
there on output.
You don't want to apply your regexp handler to the entire al node, just
its first child (if that is a text node)

<xsl:template match="al">
 <xsl:variable name="first-string"
 <xsl:variable name="rest" select="

    <xsl:when test="matches($first-string,'\d.*')">
            <xsl:analyze-string select="." regex="^\d+\. ">
                <nr><xsl:value-of select="."/></nr>
                <al><xsl:copy-of select="."/><xsl:copy-of select="$rest"/>
<!-- you hardly _ever_ want to copy descendant::node() as you will get
    an exponention explosion in the size of the output, you just want
    child nodes, or as here the current node -->
        <xsl:copy-of select="."/>

This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

 XSL-List info and archive:

Current Thread