[xsl] Identify node with variable and replace its value / mode problem

Subject: [xsl] Identify node with variable and replace its value / mode problem
From: Andreas Gehret <andreas@xxxxxxxxxxxxxx>
Date: Fri, 09 Jan 2004 18:34:04 +0100
Hi there,

I want to replace certain node values in elements that are identified by an id passed as an parameter. I know I can not use a variable in a match, so I try to use apply-templates with select and mode.
The pattern seems to be ok, the first example is doing well except I can not pass a variable.
Using an apply-templates replaces ALL titles - and using apply-templates with a mode just copies the file...
Any ideas? Your help is appreciated.


This is working, but I can't pass the parameter:

<xsl:template match="node()|@*">
<xsl:copy>
  <xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>


<xsl:template match="/newspage/news[@id='1']/title"> <title>replace title</title> </xsl:template>


This is supposed to work, but it replaces ALL titles...


<xsl:template match="node()|@*">
<xsl:copy>
  <xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>


<xsl:apply-templates select="/newspage/news[@id='1']/title"/>


<xsl:template match="title">
<title>replace title</title>
</xsl:template>


Just copies file:


<xsl:template match="node()|@*">
<xsl:copy>
  <xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>


<xsl:apply-templates select="/newspage/news[@id='1']/title" mode="replace" />


<xsl:template match="title" mode="replace">
<title>replace title</title>
</xsl:template>

P.S. Sorry, made a mistake when posting this message last night to an other thread.



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread