This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Replacing Question
- From: Jeff Beadle <Jbeadle at manh dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 15 Mar 2002 10:16:35 -0500
- Subject: RE: [xsl] Replacing Question
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hey JB,
Here's a pattern based approach:
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="Type">
<xsl:copy>
<xsl:choose>
<xsl:when test="Name_of_Data/@Data_Key='test'">
<xsl:copy>
<Data>200</Data>
<xsl:copy-of select="Name_of_Data"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
or, to be very specific:
<xsl:template match="/">
<xsl:apply-templates select="//Type[Name_of_Data/@Data_Key='test']"/>
</xsl:template>
<xsl:template match="Type[Name_of_Data/@Data_Key='test']">
<xsl:copy>
<Data>200</Data>
<xsl:copy-of select="Name_of_Data"/>
</xsl:copy>
</xsl:template>
anyway, hope this helps.
-Jeff
-----Original Message-----
From: Joeri Belis [mailto:joeri.belis@nollekens.be]
Sent: Friday, March 15, 2002 8:34 AM
To: XSL-List@lists.mulberrytech.com
Subject: [xsl] Replacing Question
hi, ( I am new to the XSLT env., so this may look trivial to you but no to
me )
This is an XML
<Type>
<Data>100</Data>
<Name_of_Data Data_Key="test"/>
<Type>
How would i replace the data "text" 100 => 200 based on the fact that i want
to search on the name of the data
being the Data_key "test".
The output result should be
<Type>
<Data>200</Data>
<Name_of_Data Data_Key="test"/>
<Type>
Thanks,
JB
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list