Ricky Bobby
Ricky Bobby

Reputation: 7618

XSLT: replace text between two nodes

I'm new at XSLT, and I would like to know if there is a function to perform the following task:

Imagine I have the following xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<text> blabla ? blabl ?  abla ?  </text>

I would like to apply a template to replace each "?" with "." when I transform my xml. Here is the xslt template i would like to have:

<xsl:template match="text">
        <xsl:replace="? with ."/> //I know it doesn't work, I just want to know if there is a function to perform something like this
  </xsl:template>

Is it possible? I learned with the w3school tutorial, and there is nothing there to perform this task.(It's a very basic tutorial) Can you advise me a good tutorial or book to learn xsl.

Upvotes: 2

Views: 849

Answers (2)

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56212

translate function

Upvotes: 2

Tomalak
Tomalak

Reputation: 338376

Yes, this is possible. There are several generic solutions to do string replacement with XSLT here on StackOverflow, so I will not write another one and instead just link to some of them.

Instead of voting for this answer, please vote for the one that you ended up using/that helped you most.

Upvotes: 4

Related Questions