[xsl] Putting characters in an element

Subject: [xsl] Putting characters in an element
From: Harm Kok <h.kok@xxxxxxxxxxxxxxx>
Date: Thu, 02 Oct 2003 14:47:54 +0200

I am having the following problem. I would like to put a list number in a seperate element and preserve the other in-line elements.

<?xml version="1.0"?>
<al>1. This is some very <emphasis>important</emphasis> tekst.</al>
<al>2. And a second line</al>
<al>And a last line</al>

desired output:
<li><li.nr>1.</li.nr><al>This is some very <emphasis>important</emphasis> tekst.</al></li>
<li><li.nr>2.</li.nr><al>And a second line</al></li>
<al>And a last line</al>

I can use XSLT 2 for the solution, but even with this I have not been able to solve the problem.
I have tried the following solution. It works perfectly with strings, but the inline element <emphasis> is not copied to the output.

<xsl:template match="al">
   <xsl:param name="first-string">
       <xsl:value-of select="substring-before(., ' ')"/>

   <xsl:when test="matches($first-string,'\d')">
           <xsl:analyze-string select="." regex="^\d\. ">
               <nr><xsl:value-of select="."/></nr>
               <al><xsl:copy-of select="."/>
       <al><xsl:copy-of select="descendant::node()"/></al>

How can I achieve this without nodes in stead of strings (in XSLT1.0 or XSLT2.0)?



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

Current Thread