views:

3398

answers:

9
A: 

Are you using the » symbol directly or are you defining it as » ? If you're using the escaped symbol, did you forget the semicolon?

Zxaos
I am defining it as ». Double checked and no I didn;t forget the semicolon just missed when I pasted into here.
BillZ
+1  A: 

did you specify a doc type for your file ?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

I think you might get such errors if you forget to specify it.

Also sometimes the entities work if you specify them by number instead of name.

&#187; &#171; instead of &raquo; and &laquo;
Pat
that's an HTML DOCTYPE.
Camilo Martin
No, that's an XHTML Doctype. XHTML is an XML application and it defines `»`.
David Dorward
+12  A: 

You are trying to use an HTML entity in a non-HTML or non-XHTML document. These entities are declared in the document's Document Type Definition (DTD).

You should use the numerical Unicode version of the entity reference. For example, in the case of &raquo; you should use &#187;

Alternatively, you can define them in your XML document's DTD:

<!ENTITY entity-name "entity-value">
<!ENTITY raquo "&#187;">

Otherwise, if your document is UTF-8, I believe you can just use the actual character directly in your XML document.

»
Joe Lencioni
Definitely use unicode characters or unicode entity references if you can. Named character references should be avoided in XML.
James Sulak
It's quite possible that the OP doesn't have a DTD for his XML. Even then, your answer could be used inside an internal subset if the user wanted. However, you are right that the simple answer is UTF-8 and just use the character.
Nic Gibson
+1  A: 

This is an issue because not all HTML entities are XML entity. You can import the DTD of HTML into your document as Pat suggested, or do one of the following:

Replace all the occurances of the special character with the numeric entity code:

&raquo; becomes &#187;

Wrap all occurances of the special characters in a CDATA Tag

<![CDATA[&raquo;]]>

Define entitys at the top of your document

<!DOCTYPE ROOT_XML_ELEMENT [ <!ENTITY raquo "&#187;"> ]>
Rontologist
A: 

Joe

When I use the unicode version shows a square.

Putting the entity decalration into the xml doc produces a "Cannot have a DTD declaration outside of a DTD." error. I suppose this is expected.

When I use '' to include the dtd externally it doesn't seem to have any effect.

I am wondering if this is maybe a server issue. I am developing this locally and using Baby Web Server.

BillZ
if you get square, then you're not declaring encoding properly or have wrong encoding of the file.Make sure you always use UTF-8 and if possible, send Content-Type:application/xml;charset=UTF-8 HTTP header. If that's not possible, add <?xml version="1.0" encoding="UTF-8"?> to the document.
porneL
+1  A: 
Robert Rossney
I wonder why it has been downvoted. It is a perfectly correct answer.
bortzmeyer
A: 

simply replace your HTML entity &raquo; with the numeric reference &#187; which is good in any XML and HTML.

Ben Bryant
A: 

I found myself googling for such info a lot, so decided to post a matrix on my own site for the simple purpose of quickly being able to do a lookup:

http://martinkool.com/characters

Use the &#...; form indeed.

Martin Kool
A: 

If you want the output document to contain the named HTML entity &raquo; rather than the numeric reference, add the following elements to your stylesheet (XSLT2.0 only):

<xsl:output use-character-maps="raquo.ent"/>
<xsl:character-map name="raquo.ent">
    <xsl:output-character character="&#187;" string="&amp;raquo;"/>
</xsl:character-map>
BungleFeet