Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Identity transform on node-set loaded with document()

From: "Andrew Welch" <andrew.j.welch@--------->
To:
Date: 8/2/2007 8:06:00 AM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent