[Home] [By Thread] [By Date] [Recent Entries]
At 2007-11-30 22:13 +0000, Mark Anderson wrote:
Is there a way to say "just copy everything to the destination XML, but any instance of <a></a> will have its contents replaced"? It is called "the identity template" and looks like this: <xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>In that template, the priority of both matches is negative 1. Matches such as match="a" have a priority of zero, so are higher. When you add more to this, the priority is .5 (more nuanced with XSLT 2.0), so is higher still. For example This is a very common pattern and I have the template as part of my unedited raw stylesheet that I use to start new stylesheets. I hope this helps. . . . . . . . . . Ken T:\ftemp>type mark.xml
<test>
<a>A</a>
<b>B</b>
<c>C</c>
<d>D</d>
<e>E</e>
<f>F</f>
<g>G</g>
</test>
T:\ftemp>type mark.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:template match="a"> <xsl:copy>12345</xsl:copy> </xsl:template> <xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template></xsl:stylesheet> T:\ftemp>xslt mark.xml mark.xsl con <?xml version="1.0" encoding="utf-8"?><test> <a>12345</a> <b>B</b> <c>C</c> <d>D</d> <e>E</e> <f>F</f> <g>G</g> </test> T:\ftemp> -- Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008 World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and 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 Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|

Cart



