xsl-list
[Top] [All Lists]

Re: xsl 2.0 recursive functions and return value

2006-02-26 11:09:06
replying to myself here...

Joern Nettingsmeier wrote:
hi everyone!


i'm trying to write a branching recursive function, but i have a problem with the "xsl:sequence" being non-terminating.

how can i get the following to work:
<snip>

i could think of this solution:


<xsl:function name="r2c:__hasTextContent" as="xs:boolean?">
  <xsl:param name="node"/>
  <xsl:for-each select="$node/*">
    <xsl:choose>
      <xsl:when test="r2c:isOutputNode(.)"/>
      <xsl:when test="r2c:isLeafNode(.)">
        <xsl:sequence select="true()"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:sequence select="r2c:hasTextContent(.)"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
</xsl:function>

<xsl:function name="r2c:hasTextContent" as="xs:boolean">
  <xsl:param name="node"/>
  <xsl:choose>
    <xsl:when test="r2c:__hasTextContent($node)">
      <xsl:sequence select="true()"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:sequence select="false()"/>
    </xsl:otherwise>
  <xsl:choose>
</xsl:function>


but at a time where i'm still dancing in the courtyard chanting "no more ugliness in the world" after having discovered xsl 2.0, this one is a bit of a spoil. :(

is there a solution which, in addition to working, is actually beautiful?
(i know i could easily get rid of the wrapper in this case since the empty set evaluates to "false", but i'm looking for a general solution that will also apply to non-boolean functions.)


regards,

jörn


--
jörn 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

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>