is there neat xpath expression count string tokens of set of nodes? eg;
<set> <hi>hello, there, world</hi> <hi>foo, bar</hi> </set> the answer want above example value 5. first <hi> has 3 tokens. second <hi> has 2 tokens.
the <set> may contain number of <hi> nodes, each of may contain number of tokens. token string separated comma followed space.
i've tried;
<xsl:value-of select="count(str:tokenize(/set//hi, ', '))"/> but returns number of tokens of first node, ie. 3.
i'm using xslt 1.0. (php libxml version 2.7.3)
this kind of thing that's easy in xpath 2.0, unfortunately requires work in xpath 1.0. there number of ways can step. 1 use:
<xsl:variable name="tmp"> <xsl:for-each select="//hi"> <xsl:value-of select="concat(., ', ')"/> </xsl:for-each> </xsl:variable> <xsl:value-of select="count(str:tokenize($tmp, ', '))"/>
Comments
Post a Comment