Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2006, 02:05 AM
Registered User
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL Transformation for empty space

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


 
Old October 10th, 2006, 03:05 AM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

I would try:

Code:
<xsl:template match="BrickletContentOne">
    <xsl:value-of select="normalize-space(.)"/>
</xsl:template>

Good Luck



 
Old October 10th, 2006, 03:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old October 10th, 2006, 04:09 AM
Registered User
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help in XSL Transformation -Urgent ysrsridhar XSLT 2 November 11th, 2008 04:03 AM
xsl transformation ... rajesh_css XSLT 5 September 30th, 2008 12:37 AM
XSL-Transformation atulshin XSLT 4 September 15th, 2008 06:37 AM
XSL transformation problem kawal.singh XSLT 2 December 5th, 2006 05:58 AM
XSL transformation Thodoris XML 0 May 20th, 2004 08:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.