xsl-list
[Top] [All Lists]

RE: Element selection based on different overlapping descendant subsets

2006-02-02 02:33:53

Thank you Andrew, Michael and David

Yes, I mean all descendants.

This:

<xsl:choose>
  <xsl:when test="every $d in .//* satisfies $d[self::ROW or self::CELL or
self::A]">
    <xsl:call-template name="Mtable" />
  </xsl:when>
  <xsl:when test="every $d in .//* satisfies $d[self::X or self::Y or... ]">
    <xsl:call-template name="Xtable" />
  </xsl:when>
  ...
</xsl:choose>

is certainly a lot cleaner than what I was doing - but it still gets
unwieldy when I put in all the possible element names that these tables
really do cover. Is there a shortcut for the predicate of $d in the above so
that I could e.g. have a series of sequence variables defined - something
along these lines:

<xsl:variable name="Mlist" select="'ROW', 'CELL', 'A',..." />
<xsl:variable name="Xlist" select="'X', 'Y', 'Z',..." />
<xsl:variable name="Zlist" select="'ROW', 'CELL', 'A', 'STUFF', 'POINT',
'LEX', 'HEX', 'REX',..." />
... etc.

and test for which (if any) of these sequences it is true that every
descendant's name is in it, like so:

<xsl:when test="every $d in .//* satisfies $d[self::name() is in $Mlist">
  <xsl:call-template name="Mtable" />
</xsl:when>
... etc.

That expression doesn't work, but is there something like it that does?

Cheers
Trevor
 
------------------------------

Date: Wed, 1 Feb 2006 12:10:53 -0000
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] Element selection based on different overlapping
descendant subsets

I can define a set M of element names and if 
every descendant
of a particular <TABLE> is in this set then it is an 
M-TABLE, 

Define each known table type as a key:

<xsl:key name="m-table" match="table[.//ROW][.//CELL][.//A]"
use="generate-id()"/>


The approach using keys is a good idea, but I don't think Andrew's key
definition actually captures the requirement as stated.

In 2.0 it's:

match="TABLE[every $d in .//* satisfies $d[self::ROW or self::CELL or
self::A]]"

which translates into the 1.0

match="TABLE[not(.//*[not(self::ROW or self::CELL or self::A)])]

Michael Kay
http://www.saxonica.com/

------------------------------



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