xsl-list
[Top] [All Lists]

[xsl] How to use the same expression in a match and a select test

2007-12-03 06:22:00
I have a stylesheet with a template and a for-each statement.
Both select their elements by an expression which differs only in one
part from each other.

The template is:

<xsl:template match="*[not(self::blockquote|self::center|self::BODY|
self::body|self::div|self::dl|self::dt|self::HEAD|self::head|self::HTML|
self::img|self::h1|self::h2|self::h3|self::h4|self::h5|self::h6|
self::hr|self::html|self::idx:*|self::form|
self::mbp:*[not(self::mbp:nu)]|self::mmc:*|self::ol|self::p|self::table|
self::td|self::th|self::tr|
self::ul)][preceding-sibling::node()[1][name()=name(current()) and
string-join(@*,'xx') = string-join(current()/@*,'xx')]]"
/>

The for-each select is:

<xsl:for-each select="following-sibling::node()[1][not(self::blockquote|
self::center|self::BODY|self::body|self::div|self::dl|self::dt|
self::HEAD|self::head|self::HTML|self::img|self::h1|self::h2|self::h3|
self::h4|self::h5|self::h6|self::hr|self::html|self::idx:*|self::form|
self::mbp:*[not(self::mbp:nu)]|self::mmc:*|self::ol|self::p|self::table|
self::td|self::th|self::tr|self::ul)] [name()=name(current()) and
string-join(@*,'xx') = string-join(current()/@*,'xx')]">

How can I reduce the redundancy and use the same expression in both
statements, like in this pseudo code:

<xsl:template
match="*[$NO_BLOCK_ELEMENTS][preceding-sibling::node()[1][name()=name(current())
 and $SAME_ATTRIBUTES]]"
/>

<xsl:for-each select="following-sibling::node()[1][$NO_BLOCK_ELEMENTS]
[name()=name(current()) and $SAME_ATTRIBUTES]">



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