Subject: Re: [xsl] Identity transform on node-set loaded with document() From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Thu, 2 Aug 2007 09:05:16 +0100 |
On 8/2/07, Matt Poff <matt.poff@xxxxxxxxxxxxxxx> wrote: > I've been away from XSLT a while and am stumbling on how to implement > the following: > > My transform imports, using document(), an HTML snippet contain a > populated <head></head> tag. I want to copy this into one of several > result trees I am outputting as is *except* the <title/> tag needs to > be populated with a value. > > Initially I created a named template and sent the loaded node-set to it, > then realised I probably needed an identity transform but all of the > identity transform examples I've found seem to be set-up to operate on > the master document only. What's the best way to carry out this task? > Can I do an identity transform with a named template? > > I'm sure there's a fairly simple solution but it's passing me by. Create the new <head> by using a mode, and store it in a variable to make it easy to copy to all of the places that its needed: <xsl:variable name="newHead"> <xsl:apply-templates select="doc('head.xml')" mode="processHead"/> </ <xsl:template match="@*|node()" mode="processHead"> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="processHead"/> </ </ <xsl:template match="title" mode="processHead"> <title>My new title</title> </ and then just copy it where you need it eg: <xsl:copy-of select="$newHead"/> cheers andrew -- http://andrewjwelch.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Identity transform on nod, Mukul Gandhi | Thread | RE: [xsl] Identity transform on nod, Michael Kay |
Re: [xsl] XML with Default Namespac, Karl Stubsjoen | Date | RE: [xsl] Identity transform on nod, Michael Kay |
Month |