aspose file tools*
The moose likes XML and Related Technologies and the fly likes The entity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "The entity "nbsp" was referenced, but not declared" Watch "The entity "nbsp" was referenced, but not declared" New topic
Author

The entity "nbsp" was referenced, but not declared

kapil Gupta
Ranch Hand

Joined: Dec 17, 2001
Posts: 89
Hi,
Am converting HTML content to XML. While conversion, I recveive following error if my html contains a space ( ) character.

How can I resolve this issue?
Thanks.
kapil
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

That depends on how you are doing the conversion. Would you like to provide some information about that?
kapil Gupta
Ranch Hand

Joined: Dec 17, 2001
Posts: 89
I am very sorry for the late reply. Am using XSLT to transform HTML to XML. The web based UI allows user to enter content from a rich text editor and on submission am converting it to XML.

The error occurs while parsing the html content.
I was able to suppress the error by replacing nbsp with its ascii code #160; but if there are more than one html space character, it results in only one white space in XML.
What is the correct way to handle html space character?
Thanks,
Kapil

[ March 23, 2007: Message edited by: kapil Gupta ]

[ March 23, 2007: Message edited by: kapil Gupta ]

[ March 23, 2007: Message edited by: kapil Gupta ]
[ March 23, 2007: Message edited by: kapil Gupta ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

You already found out one of the correct ways: use   for a non-breaking space. The entity   isn't one of XML's predefined entities, so if you want to use it in an XML document then you have to provide a DTD that declares what it means. That's another correct way.
pete reisinger
Ranch Hand

Joined: Dec 30, 2009
Posts: 46
prepend:

<?xml version="1.0"?>
<!DOCTYPE some_name [
<!ENTITY nbsp "&#160;">
]>

then parse the string
This will replace all nbsp entities for the xml ones
Syera Syailendra
Greenhorn

Joined: Aug 15, 2013
Posts: 1
hi all i have same problem how to fix it?



The entity "a.performance.timing" was referenced, but not declared

anyone can help me please email me
my address here http://syerasite.com

Thank you


i love javascripts
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The entity "nbsp" was referenced, but not declared