|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Putting characters in an element
Hi,
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. input: <?xml version="1.0"?> <root> <al>1. This is some very <emphasis>important</emphasis> tekst.</al> <al>2. And a second line</al> <al>And a last line</al> </root> 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. Stylesheet:
<xsl:template match="al">
<xsl:param name="first-string">
<xsl:value-of select="substring-before(., ' ')"/>
</xsl:param> <xsl:choose>
<xsl:when test="matches($first-string,'\d')">
<li>
<xsl:analyze-string select="." regex="^\d\. ">
<xsl:matching-substring>
<nr><xsl:value-of select="."/></nr>
</xsl:matching-substring>
<xsl:non-matching-substring>
<al><xsl:copy-of select="."/>
</al>
</xsl:non-matching-substring>
</xsl:analyze-string>
</li>
</xsl:when>
<xsl:otherwise>
<al><xsl:copy-of select="descendant::node()"/></al>
</xsl:otherwise>
</xsl:choose>
</xsl:template>How can I achieve this without nodes in stead of strings (in XSLT1.0 or XSLT2.0)? Regards, Harm XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








