Sombir Kumar
Sombir Kumar

Reputation: 1881

Replace <span> tag with another <span> using XSLT

I am using a Skin file(.htm) and and transforming it with XSLT.
I have:

<span>Home: </span>

in skin file at many places throughout the document.

and I want to change all these values by XSLT with :

<span>Fixe: </span>

I searched a lot but couldn't find the solution.

Because my XSLT contains:

<xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />

and whatever solution I found, their XSLT contains method="xml".
Also I am using version 1.0.

Upvotes: 1

Views: 199

Answers (1)

zx485
zx485

Reputation: 29022

As @michael.hor257k pointed out, the <xsl:output method="..." attribute is not relevant to the input. It merely affects - as the name implies - the output format.

On the other hand, if your input is HTML (like indicated by your file extension .htm), your question is wrongly tagged and the following answer may be useless for you.


So a solution to your problem - assuming your input is XML - is globally replacing all span nodes:

<xsl:template match="//span[text() = 'Home: ']">
  <span><xsl:text>Fixe: </xsl:text></span>
</xsl:template>   

Upvotes: 1

Related Questions