Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 10th, 2006, 02:05 AM
Registered User
 
Join Date: Oct 2006
Location: Bangalore, Karnataka, India.
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


Reply With Quote
  #2 (permalink)  
Old October 10th, 2006, 03:05 AM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
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



Reply With Quote
  #3 (permalink)  
Old October 10th, 2006, 03:14 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
  #4 (permalink)  
Old October 10th, 2006, 04:09 AM
Registered User
 
Join Date: Oct 2006
Location: Bangalore, Karnataka, India.
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:18 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.