saxon-help

Hi,
I want to be able to take a node and replace any occurences of a string with
my own string
For Example:
I want to be able to take any of these documents:
<element>
<innerElement>
<innerElement2>replaceMe</innerElement2>
</innerElement>
</element>
<different>
<different3>
<different45>replaceMe</different45>
</different3>
</different>
and create these respectively:
<element>
<innerElement>
<innerElement2>replaced</innerElement2>
</innerElement>
</element>
<different>
<different3>
<different45>replaced</different45>
</different3>
</different>
Is this possible, any ideas?
--
View this message in context: http://www.nabble.com/String-replace-in-a-node-tf3142332.html#a8709219
Sent from the saxon-help mailing list archive at Nabble.com.

RoshanP wrote:
> Hi,
>
> I want to be able to take a node and replace any occurences of a string with
> my own string
>
> For Example:
> I want to be able to take any of these documents:
>
> <element>
> <innerElement>
> <innerElement2>replaceMe</innerElement2>
> </innerElement>
> </element>
>
> <different>
> <different3>
> <different45>replaceMe</different45>
> </different3>
> </different>
>
> and create these respectively:
>
> <element>
> <innerElement>
> <innerElement2>replaced</innerElement2>
> </innerElement>
> </element>
>
> <different>
> <different3>
> <different45>replaced</different45>
> </different3>
> </different>
>
>
> Is this possible, any ideas?
>
This is a very generic XSLT question that is better asked on the XSLT
mailing list. This list is for Saxon specific questions.
That said, use the following (together with a copy template and your
other templates):
<xsl:template match="innerElement2">
<xsl:copy>
<xsl:text>replaced</xsl:text>
</xsl:copy>
</xsl:template>
or, if you need to do more complex replacements, use the replace() function.
A simple guide for XSLT can be found on http://www.w3schools.com where this
principle of matching templates is explained.
-- Abel

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

CountryState

JavaScript is required for this form.

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details