Re: [xsl] Universally quantified test of child attribute presence/absence

Subject: Re: [xsl] Universally quantified test of child attribute presence/absence
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 20 Mar 2007 14:21:34 +0100
Yves Forkl wrote:


Like I (partially) wrote, I prefer to leave the condition equalling this third case implied in my xsl:otherwise clause, while explicitly testing for the other two cases using xsl:when.


Just a thought, based on what I think to grasp from what you want to do:


<!-- holds a sequence to two numbers, one with @my.. one with all-->
<xsl:variable name="mytest" select="count(*/@my_atrribute), count(*)" as="xs:integer+" />


<!-- choosing between the four possible scenarios. Note: order is important! -->
<xsl:choose>
<xsl:when test="$mytest[1] = $mytest[2]">
<!-- every child has @my_attribute -->
</xsl:when>
<xsl:when test="$mytest[1]">
<!-- some childs has @my_attribute -->
</xsl:when>
<xsl:when test="$mytest[2]">
<!-- no childs have @my_attribute -->
</xsl:when>
<xsl:otherwise>
<!-- no childs at all -->
</xsl:otherwise>
<xsl:choose>



As I said, just a thought, and perhaps way easier to write down and/or to understand. Like Larry Wall said: there's more than one way to do it.


Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

Current Thread