non-breakable space

View: New views
5 Messages — Rating Filter:   Alert me  

non-breakable space

by Jabba Laci :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'd like to produce the following XHTML output:

<xforms:label>Address: </xforms:label>

How to prevent that JDOM changes & to & ?

Thanks,

Laszlo
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: non-breakable space

by Tatu Saloranta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--- On Tue, 12/2/08, Jabba Laci <jabba.laci@...> wrote:

> From: Jabba Laci <jabba.laci@...>
> Subject: [jdom-interest] non-breakable space
> To: "jdom" <jdom-interest@...>
> Date: Tuesday, December 2, 2008, 4:31 PM
> Hi,
>
> I'd like to produce the following XHTML output:
>
> <xforms:label>Address: </xforms:label>
>
> How to prevent that JDOM changes & to & ?

You don't. Just stick the non-breaking space character itself in content, and JDOM will escape it properly. Code for the character is 160, so in Java string constant it'd be something like "Address:\u00A0".

Hope this helps,

-+ Tatu +-



     
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: non-breakable space

by Jabba Laci :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I added the character '\u00A0' to the end of the string, but as a
result I get "Address: " instead of "Address: ". When I verify it
in a browser, I have a funny character ("Address:Â") at the place of
the space.

Laszlo

>> I'd like to produce the following XHTML output:
>>
>> <xforms:label>Address: </xforms:label>
>>
>> How to prevent that JDOM changes & to & ?
>
> You don't. Just stick the non-breaking space character itself in content, and JDOM will escape it properly. Code for the character is 160, so in Java string constant it'd be something like "Address:\u00A0".

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

RE: non-breakable space

by rolf.lear :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can also do...

Element label = new Element("label", xformsnamespace);
label.addContent("Address:");
label.addContent(new EntityRef("nbsp"));

Rolf

-----Original Message-----
From: jdom-interest-bounces@...
[mailto:jdom-interest-bounces@...] On Behalf Of Jabba Laci
Sent: Tuesday, December 02, 2008 6:32 PM
To: jdom
Subject: [jdom-interest] non-breakable space

Hi,

I'd like to produce the following XHTML output:

<xforms:label>Address: </xforms:label>

How to prevent that JDOM changes & to & ?

Thanks,

Laszlo
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

 
--------------------------------------------------------------------------
This email and any files transmitted with it are confidential and proprietary to Algorithmics Incorporated and its affiliates ("Algorithmics"). If received in error, use is prohibited. Please destroy, and notify sender. Sender does not waive confidentiality or privilege. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. Algorithmics does not accept liability for any errors or omissions. Any commitment intended to bind Algorithmics must be reduced to writing and signed by an authorized signatory.
--------------------------------------------------------------------------


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: non-breakable space

by Tatu Saloranta :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--- On Wed, 12/3/08, Jabba Laci <jabba.laci@...> wrote:

> From: Jabba Laci <jabba.laci@...>
> Subject: Re: [jdom-interest] non-breakable space
> To: "jdom interest" <jdom-interest@...>
> Date: Wednesday, December 3, 2008, 9:27 AM
> Hi,
>
> I added the character '\u00A0' to the end of the string, but as a
> result I get "Address: " instead of

That's fine, there's nothing wrong in including character as is.
HTML does not require escaping, it just allows it.

However:

> "Address: ". When I verify it in a browser, I have a funny character
> ("Address:Â") at the place of the space.

Sounds like you have incorrect encoding specified; such that content is in Latin1, but page claims to be UTF-8, or vice versa. Nbsp byte itself is expressed differently in different encodings: as a 2-byte sequence in UTF-8, as a single byte in Latin1.

Alternatively, it is possible to make JDOM outputter escape all kinds of characters, for example anything outside of ascii range (char > 127). But you really should fix encoding problems for the page as that is one of most common problems with web page generation, and will eventually cause problems with other characters (accented ones etc).

Hope this helps,

-+ Tatu +-



     

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...