Subject: Re: xsl:variable and match From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 12 May 2000 18:19:01 +0200 |
Can I use a variable in the match part of xsl:template?
<xsl:variable name="x" select="/ROWSET/REPLACE/@EL"/> <xsl:template match="/ROWSET/{$x}"> <NEWELEMENT><xsl:apply-templates/></NEWELEMENT> </xsl:template>
T:\ftemp>type test.xml <?xml version="1.0"?> <test> <a>This is a</a> <b>This is b</b> <c>This is c</c> <d>This is d</d> </test> T:\ftemp>type test.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--push all children for illustration--> <xsl:template match="/test"> <xsl:apply-templates/> </xsl:template>
<!--only interested in the ones indicated by the operator--> <xsl:template match="*[name(.)=$which]" priority="1"> <xsl:value-of select="."/> </xsl:template>
<!--eat all other output--> <xsl:template match="*|text()" priority="0"/>
T:\ftemp>xt test.xml test.xsl which=a This is a T:\ftemp>xt test.xml test.xsl which=c This is c T:\ftemp>
-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Web site: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-04-7 Next instructor-led training: 2000-05-11/12,2000-05-15, - 2000-06-12,2000-06-13,2001-01-27
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
xsl:variable and match, Ross Cormier | Thread | RE: xsl:variable and match, Kay Michael |
XMLSchema support, Maksim Zhizhkun | Date | RE: number question, Kay Michael |
Month |