[xsl] How to express this complexe select pattern in apply-templates

Subject: [xsl] How to express this complexe select pattern in apply-templates
From: "E100 SFYang" <SFYang@xxxxxxxxxxxxx>
Date: Fri, 21 Dec 2001 16:24:38 +0800
Hi, xslt listers,

I want to reach the **row**  node which one of child node name is param1
and the value is
param2, for example : once the row of the node name p1 and x1 is found ,
then the corresponding sibling node p2, and p3 can be accessed.
I come up the following xsl list , which works, but it seems cumbersome
to me to use
three templates to reach the right row node because I could not figure
out how to write the correct pattern for following
expression . 

<xsl:apply-templates select="/rows/row[of which any one of child nodes
name='param1' and value ='param2']"/>???  <== how to express this
condition pattern?

Any suggestion to the patter of this select attr is appreciated.
Thanks and have a merry holiday.

***  xml ****
<rows>
<row>
<p1>x1</p1>
<p2>x2</p2>
<p3>x3</p3>
</row>
<row>
<p1>x3</p1>
<p2>x4</p2>
<p3>x5</p3>
</row>
..
</rows>

**  xsl ***    
<?xml version="1.0" encoding="big5" ?> 
<?xml version="1.0" ?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

<xsl:param name="param1" select="'p1'" />
<xsl:param name="param2" select="'x1'"/>
<xsl:param name="hd" select="';p2;p3;'"/>

<xsl:template match="/">
<xsl:apply-templates select="//row"/>
</xsl:template>

<xsl:template match="row">
<xsl:apply-templates select="*[name()=$param1 and .=$param2]"/>
</xsl:template>

<xsl:template match="*">
<xsl:variable name="x" select="parent::*"/>
<xsl:apply-templates select="$x" mode="xx"/>
</xsl:template>

<xsl:template match="row" mode="xx">
<xsl:for-each select="*[contains($hd,concat(';',name(),';'))]">
<xsl:value-of select="name()"/><xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread