Subject: Re: Counting the number of elements within and outputting a variable holding analyze-string results wrapped by elements in a for-each
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Mon, 30 Nov 2009 14:47:36 +0100
|
Alex Muir wrote:
<xsl:variable name="varAnalyzeStr" as="node()*">
<xsl:analyze-string select="parent::node()/content/text()"
regex="Y(\d+)Y">
<xsl:matching-substring>
<xsl:element name="section">
<xsl:attribute name="href" select="regex-group(1)"/>
</xsl:element>
Here you construct a 'section' element with 'href' attribute but not
content.
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:variable>
<xsl:choose>
<xsl:when test="not(empty($varAnalyzeStr))">
<xsl:element name="">
<xsl:attribute name="Count" select="count($varAnalyzeStr)"/>
<xsl:for-each select="$varAnalyzeStr">
<xsl:value-of select="."/>
Here you do value-of of those empty 'section' element. Maybe you want
xsl:copy-of select="." to copy those elements to the result tree.
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/
|