xsl-list
[Top] [All Lists]

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

2007-03-20 06:23:40
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


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