[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to express this complexe select pattern in apply-t

Subject: How to express this complexe select pattern in apply-templates
From: "E100 SFYang" <SFYang@xxxxxxxxxxxxx>
Date: Fri, 21 Dec 2001 16:24:38 +0800
e100 param
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.