xsl-list
[Top] [All Lists]

RE: Changing a node value for a variable

2002-11-26 07:40:59
Hi,

Since a variable may contain a node set, is it possible to 
modify the value
of one node in the variables nodes.

No, but you can make a copy of the node-set bound to the variable and changed 
it when copying.

Example:
<foo>
  <data1>Tom</data1>
  <data2>Jones</data2>
</foo>

to

<foo>
  <data1>Bridget</data1>
  <data2>Jones</data2>
</foo>

make a identity transformation, where you have

<xsl:template match="data1/text()[. = 'Tom']">Bridget</xsl:template>

or is it possible to add a new child node?

Example:
<foo>
  <data1>Tom</data1>
  <data2>Jones</data2>
</foo>

to

<foo>
  <data1>Tom</data1>
  <data2>Jones</data2>
  <data3>Bridget</data3>
</foo>

again, write an identity transformation with

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

Cheers,

Jarno - Apoptygma Berzerk: Nearer

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



<Prev in Thread] Current Thread [Next in Thread>