I have a requirement that I need to handle B (Bold), I (Italic) and U (underline) tagtags. We are using XSLT and XPath. I
I have an RTF field named <text>......</text>.
I.
I entered some text in this RTF field and made it as boldBold and Italic The, 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>
<text>
<strong xmlns="http://www.w3.org/1999/xhtml">adasdasd</strong>
</text>
<text>
<em xmlns="http://www.w3.org/1999/xhtml">adsadas</em>
</text>
<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>
<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>
<text><strong>adasdasd</strong></text>
<text><em>adsadas</em></text>
<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.
1)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 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>
2)Enter a single word- Enter a single word
<text>
<div xmlns="http://www.w3.org/1999/xhtml" style="text-decoration: underline;">Welcome</div>
</text><br>
<text>
<div xmlns="http://www.w3.org/1999/xhtml" style="text-decoration: underline;">Welcome</div>
</text>
3)Enter text and press ENTER Key
- 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><br>
<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>
4)Enter text and press SHIFT + ENTER key
- Enter text and press SHIFT + ENTER key
<text>
huiuiioasiodio
<br xmlns="http://www.w3.org/1999/xhtml"></br>
iohoshiofhiohsd
<br xmlns="http://www.w3.org/1999/xhtml"></br>
<span xmlns="http://www.w3.org/1999/xhtml" style="text-decoration: underline;">iosiohfioio</span>
<br xmlns="http://www.w3.org/1999/xhtml"></br>
uisuidfuiuisdhf
</text><br>
<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>
<text><u>...</u></text><br>
How to acheiveachieve this. Can anyone help me
Suggestions Welcome.Thanks in Advance.?