You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Qingxiang Ke <qk...@cisco.com> on 2000/03/21 04:39:48 UTC

Nonbreaking space

Hi,

I am using xsl java extension, I obtained a DocumentFragment and got the
Owner Document and create some elements inside the document, then I tried
to create a text node for a element. However, I couldn't put Nonbreaking
space before the text in the text node. 
for Example:
DocumentFragment resultTreeFragment is obtained as a function paramenter.

Document factory = resultTreeFragment.getOwnerDocument();
Element select = factory.createElement("Select");
Element option = factory.createElement("option");
select.appendChild(option);
option.appendChild(factory.createTextNode("&#160;&#160;&#160;Beginning of
the Text");

The output to html actually escape '&' in "&#160;" and I got in result
document is "&amp;#160;&amp;#160;&amp;#160;" instead of nonbreaking space I
want. Then I tried to use &nbsp; didn't work either, After both failure,  I
tried to put the full text including those nonbreaking spaces in a CData
section, but the the full CData section was implanted into html without any
conversion and caused the full text disappear in browser.

I am using Lotus 0.20, which is a wrapper around Xalan 0.20 and using
XML4J2.0.15. 

Could someone help?

Thanks.

Qingxiang

Re: Nonbreaking space

Posted by Klaus Malorny <Kl...@knipp.de>.
Qingxiang Ke wrote:
> 
> Hi,
> 
> I am using xsl java extension, I obtained a DocumentFragment and got the
> Owner Document and create some elements inside the document, then I tried
> to create a text node for a element. However, I couldn't put Nonbreaking
> space before the text in the text node.
> for Example:
> DocumentFragment resultTreeFragment is obtained as a function paramenter.
> 
> Document factory = resultTreeFragment.getOwnerDocument();
> Element select = factory.createElement("Select");
> Element option = factory.createElement("option");
> select.appendChild(option);
> option.appendChild(factory.createTextNode("&#160;&#160;&#160;Beginning of
> the Text");
> 
> Could someone help?
> 
> Thanks.
> 
> Qingxiang


try


option.appendChild(factory.createTextNode("\u00A0\u00A0\u00A0Beginning of
  the Text"));

this should work (theoretically). You don't need to take care about the correct
XML/HTML representation of characters - this is a task for the output
generator.

regards,

Klaus Malorny


___________________________________________________________________________
     |       |
     | knipp |                   Knipp  Medien und Kommunikation GmbH
      -------                           Technologiepark
                                        Martin-Schmeisser-Weg 9
                                        44227 Dortmund
     Dipl. Inf. Klaus Malorny           Germany
     Klaus.Malorny@knipp.de             Tel. +49 231 9703-0  Fax. -200