[Home] [By Thread] [By Date] [Recent Entries]
At 2006-07-20 15:41 -0400, Steve wrote:
How do I <xsl:apply-templates select="$variable/Records/Record[1]" /> only those records which are neccesary="yes" ?
I hope this helps. . . . . . . . . . . Ken t:\ftemp>type blah.xml <?xml version="1.0" encoding="US-ASCII"?> <activities> <activity necessary="no">Baseball</activity> <activity necessary="no">Shopping</activity> <activity necessary="yes">Writing</activity> </activities> t:\ftemp>type steve3.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"><xsl:output method="text"/> <xsl:key name="activities" match="activity" use="@necessary"/> <xsl:key name="records" match="Record" use="activity"/> <xsl:template match="/">
<xsl:variable name='records'>
<Records>
<Record>
<activity>Baseball</activity>
<hours>36</hours>
</Record>
<Record>
<activity>Shopping</activity>
<hours>39</hours>
</Record>
<Record>
<activity>Writing</activity>
<hours>3</hours>
</Record>
</Records>
</xsl:variable> <xsl:apply-templates
select="key('records',
key('activities',
'yes',
document('blah.xml')),
$records)"/>
</xsl:template><xsl:template match="Record">
<xsl:value-of select="'Activity: ',activity,', hours=',hours"
separator=""/>
<xsl:text>
</xsl:text>
</xsl:template></xsl:stylesheet> t:\ftemp>xslt2 steve3.xsl steve3.xsl con Activity: Writing, hours=3 t:\ftemp> -- Registration open for UBL training: Montrial, Canada 2006-08-07 Also for XSL-FO/XSLT training: Minneapolis, MN 2006-07-31/08-04 Also for UBL/XML/XSLT/XSL-FO training: Varo,Denmark 06-09-25/10-06 World-wide corporate, govt. & user group UBL, XSL, & XML training. 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 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|

Cart



