Alex,
Am 30.11.2009 um 14:35 schrieb Alex Muir:
I'm interested in counting the number of elements in the variable
$varAnalyzeStr holding analyze-string results wrapped by elements and
then output the elements within the $varAnalyzeStr in a for-each.
I've been able to count the number accurately however not output the
variable varAnalyzeStr as a series of section elements. Currently I'm
looping 15 times in the for each but no outputting any content.
What am I doing wrong and is there a better way to do this?
<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>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:variable>
this variable contains something like
<section href="123" />
<section href="456" />
<section href="789" />
i.e. empty elements, no text content. Your XSL tries to get "." from each
element, which is empty. Instead of xsl:value-of you should use xsl:copy-of.
And please give xsl:element a name.
<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="."/>
</xsl:for-each>
</xsl:element>
</xsl:when>
</xsl:choose>
- Michael Müller-Hillebrand
--
_______________________________________________________________
Michael Müller-Hillebrand: Dokumentations-Technologie
Adobe Certified Expert, FrameMaker
Lösungen und Training, FrameScript, XML/XSL, Unicode
Blog: http://cap-studio.de/ - Tel. +49 (9131) 28747
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--