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

Re: xsl 2.0 recursive functions and return value

Subject: Re: xsl 2.0 recursive functions and return value
From: Joern Nettingsmeier <nettings@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 26 Feb 2006 21:53:53 +0100
recursion return value
Michael Kay wrote:
how can i get the following to work:


<xsl:function name="r2c:hasTextContent" as="xs:boolean"> <xsl:param name="node"/> <xsl:for-each select="$node/*"> <xsl:choose> <!--ignore!--> <xsl:when test="r2c:isOutputNode(.)"/> <!--gotcha!--> <xsl:when test="r2c:isLeafNode(.)"> <xsl:value-of select="true()"/> </xsl:when>

Use xsl:sequence here! xsl:value-of creates a text node. You're converting a boolean to a string, wrapping the string in a text node, then because an xs:boolean is required, the text node is atomized, and the string "true" is converted back to a boolean.

of course. it was supposed to be a sequence, but old habits...


Try:

<xsl:function name="r2c:hasTextContent()" as="xs:boolean">
  <xsl:param name="node" as="node()"/>
  <xsl:sequence select="some $x in $node/*[not(r2c:isOutputNode(.)]
satisfies
     (r2c.isLeafNode($x) or r2c.hasTextContent($x))"/>
</xsl:function>

wow. quantifiers! cool. i hadn't yet noticed they exist.



please no more spoilers, your books on xsl2/xpath2 are scheduled to arrive on tuesday :-D



thanks a lot!


jvrn


-- jvrn nettingsmeier

home://germany/45128 essen/lortzingstr. 11/
http://spunk.dnsalias.org
phone://+49/201/491621

if you are a free (as in "free speech") software developer
and you happen to be travelling near my home, drop me a line
and come round for a free (as in "free beer") beer. :-D

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.