I have a requirement that I need to handle B (Bold), I (Italic) and U (underline) tags. We are using XSLT and XPath.
I have an RTF field named <text>......</text>
.
I entered some text in this RTF field and made it Bold and Italic, the source xml for the bold and italic is as follows:
<text>
<strong xmlns="http://www.w3.org/1999/xhtml">adasdasd</strong>
</text>
<text>
<em xmlns="http://www.w3.org/1999/xhtml">adsadas</em>
</text>
I handled both Bold and Italic tag in this following way.
<xsl:template name="format" match="*[local-name()='strong'] | *[local-name()='em']">
<xsl:variable name="tagName" select="name()" />
<xsl:element name="{$tagName}" namespace="{$nSpace}">
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:element>
</xsl:template>
In the published file I'm getting the tag element as expected
<text><strong>adasdasd</strong></text>
<text><em>adsadas</em></text>
It is working fine for Bold and Italic.
But, I tried 4 ways for underline.
- Enter consecutive text in that RTF field
<text>Good Morning Have a nice <span xmlns="http://www.w3.org/1999/xhtml"
style="text-decoration: underline;">Day</span></text>
- Enter a single word
<text>
<div xmlns="http://www.w3.org/1999/xhtml" style="text-decoration: underline;">Welcome</div>
</text>
- Enter text and press ENTER Key
<text>
<p xmlns="http://www.w3.org/1999/xhtml">jhoiohad</p>
<p xmlns="http://www.w3.org/1999/xhtml">asuhdoahsoid</p>
<p xmlns="http://www.w3.org/1999/xhtml" style="text-decoration: underline;">ahsdhaoiodia</p>
<p xmlns="http://www.w3.org/1999/xhtml">asdasd</p>
</text>
- Enter text and press SHIFT + ENTER key
<text>
huiuiioasiodio
<br xmlns="http://www.w3.org/1999/xhtml">
iohoshiofhiohsd
<br xmlns="http://www.w3.org/1999/xhtml">
<span xmlns="http://www.w3.org/1999/xhtml" style="text-decoration: underline;">iosiohfioio</span>
<br xmlns="http://www.w3.org/1999/xhtml">
uisuidfuiuisdhf
</text>
I don't know how to handle for underline tag. Because different tag elements are generated. In the published file I need to get like this:
<text><u>...</u></text><br>
How to achieve this?
<u>
element was deprecated in HTML 4.01. (the<u>
element was used to define underlined text).<text>some text here...........</text>
. Because I'm not handling it in the xslt level...It should not affect other tags like<strong>
,<em>
etc...