[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Counting the number of elements within and outputt

Subject: Re: Counting the number of elements within and outputting a variable holding analyze-string results wrapped by elements in a for-each
From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx>
Date: Mon, 30 Nov 2009 14:47:18 +0100
Re:  Counting the number of elements within and outputt
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
Lvsungen und Training, FrameScript, XML/XSL, Unicode
Blog: http://cap-studio.de/ - Tel. +49 (9131) 28747

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.