M
miroslaw.rusin
Challange no 2
We have 2 transitions:
1) <b> -> <strong>
2) <u> -> <strike>
How to make it work so if <u> is inside the <b> tag, it is also
processed?
An example:
Input:
<b>B <u>U1</u> </b>
<u>U2</u>
Gives (not what we want):
<strong>B U1 </strong>
<strike>U2</strike>
Should give (that we want):
<strong>B <strike>U1</strike> </strong>
<strike>U2</strike>
My transformation for the moment looks like this:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
<xslutput method="xml" indent="yes" />
<xsl:template match="/" >
<xsl:text disable-output-escaping="yes"><!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</xsl:text>
<xsl:apply-templates select="@* | node()" />
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="b">
<strong><xsl:value-of select="." /></strong>
</xsl:template>
<xsl:template match="u">
<strike><xsl:value-of select="." /></strike>
</xsl:template>
</xsl:stylesheet>
Any idea?
We have 2 transitions:
1) <b> -> <strong>
2) <u> -> <strike>
How to make it work so if <u> is inside the <b> tag, it is also
processed?
An example:
Input:
<b>B <u>U1</u> </b>
<u>U2</u>
Gives (not what we want):
<strong>B U1 </strong>
<strike>U2</strike>
Should give (that we want):
<strong>B <strike>U1</strike> </strong>
<strike>U2</strike>
My transformation for the moment looks like this:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
<xslutput method="xml" indent="yes" />
<xsl:template match="/" >
<xsl:text disable-output-escaping="yes"><!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</xsl:text>
<xsl:apply-templates select="@* | node()" />
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="b">
<strong><xsl:value-of select="." /></strong>
</xsl:template>
<xsl:template match="u">
<strike><xsl:value-of select="." /></strike>
</xsl:template>
</xsl:stylesheet>
Any idea?