|
Subject:
|
XSL Transformation for empty space
|
|
Posted By:
|
ashokhr
|
Post Date:
|
10/10/2006 2:05:43 AM
|
Hi Friends,
I have problem in displaying data in html which contain numeric space character in XML
Here is my XML.
<Context> <BrickletContentOne> </BrickletContentOne> <BrickletLinksOne>BrickletLinksOne</BrickletLinksOne> </Context>
In Above XML I have <BrickletContentOne> which contain which represent empty space.
I am using XSL to print the element value in html like this.
<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:tns="http://www.w3.org/1999/xhtml"> <xsl:output method="html" /> <xsl:template match="/" > <xsl:apply-templates select="Context" /> </xsl:template> <xsl:variable name="strBValue" select="/Context/BrickletContentOne" /> <xsl:variable name="tempStrValue" select="$strBValue" /> <xsl:template match="Context"> <table> <tr> <xsl:apply-templates select="BrickletContentOne" /> </tr> <tr> <xsl:apply-templates select="BrickletLinksOne" /> </tr> </table> </xsl:template> <xsl:template match="BrickletContentOne">
<xsl:value-of disable-output-escaping="yes" select="$tempStrValue" /> </xsl:template> </xsl:stylesheet>
when I do XSLTransformation I am getting output like this instead of empty space.
<table> <tr>????????</tr> <tr>BrickletLinksOne</tr> </table>
I want OutPut like this
<table> <tr></tr> <tr>BrickletLinksOne</tr> </table>
Is there any way to overcome this issue in XSL.
Thanks Ashok
|
|
Reply By:
|
bonekrusher
|
Reply Date:
|
10/10/2006 3:05:54 AM
|
I would try:
<xsl:template match="BrickletContentOne">
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>
Good Luck
|
|
Reply By:
|
mhkay
|
Reply Date:
|
10/10/2006 3:14:05 AM
|
First, get rid of that ridiculous disable-output-escaping="yes". The element in question doesn't contain any characters that need to be escaped, but if it did, it would be quite wrong not to escape them.
I suspect that the spaces in the source document are actually non-breaking spaces (xA0). If your source document is encoded in iso-8859-1 and you're looking at it using software that only understands iso-8859-1, then the output document will contain the non-breaking-spaces encoded in UTF-8, which means they will display incorrectly if you look at them using software that doesn't understand UTF-8. Either get yourself a text editor that understands UTF-8, or produce the output in a different encoding, e.g. by writing <xsl:output encoding="iso-8859-1"/>.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
ashokhr
|
Reply Date:
|
10/10/2006 4:09:26 AM
|
Thanks Michael and team,
Sir the element look like this '#160;' I tried using <xsl:output method="html" encoding="iso-8859-1" /> even then I am not able to get blank can you please try the same.
Thanks Ashok
|