• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Keeping blank spaces using XML and XSL

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to get the blank spaces in my XSl's and i have declared it by using entitiy as below:
<?xml version='1.0'?>
<!DOCTYPE xsl:stylesheet
[<!ENTITY nbsp " ">]>
After declaring i have used it in my code like for example as
<tr><td > </td></tr>
So in the output iam getting the blank spaces but the problem is iam also getting some junk character as "�" this.Can anyone tell what is wrong and where am i suppposed to correct and would be very thankful is you would let me know the answer as soon as possible.
Thanks,
Rajitha.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of hard-coding a whitespace character, I recommend that you use one of the xml/xsl vocabularies that deal with whitespace.
Here are some options -

  • Use <xsl:text> in the stylesheet.
    The content of <xsl:text> elements is copied directly to the result tree; whitespace is preserved by default.
    <xsl:text>Literal result text that can have embeded spaces</xsl:text>
  • In the XML document, use <xml:space> attribute has the value preserve, it is preserved.

  • Control the default stripping rules with <xsl :preserve-space> and <xsl:strip-space> -
    ie., -
    [1] If a text node contains non-whitespace characters, it is preserved
    [2] If a text node occurs inside an element listed in <xsl :preserve-space>, it is preserved
    [3] If the nearest ancestor xml:space attribute has the value preserve, it is preserved
    [4] Otherwise it is stripped (discarded from the tree before any transformation begins)

  • Hope that helps!
    ------------------
    Ajith Kallambella M.
    Sun Certified Programmer for the Java�2 Platform.
    IBM Certified Developer - XML and Related Technologies, V1.
    [This message has been edited by Ajith Kallambella (edited February 12, 2001).]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try using <xsl utput method="xml" indent="yes" encoding="UTF-8"/xsl...>
this will indent u'r o/p and the encoding may be the problem of the junk characters.
[This message has been edited by Ajith Kallambella (edited February 12, 2001).]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic