Reputation: 6008
I'm using XSLT and having great success, just got a couple of problems.
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Entity 'Aring' not defined in Entity
Basically for some non-standard characters I am getting the above type of error. I really want to fix this once and for all. I know about character mapping but I cannot possibly write down every possible combination of special characters.
Upvotes: 0
Views: 2119
Reputation: 65313
Note that there is also a DOMDocument::loadHTML
function, which treats the document as HTML, and which won't trip up on these entities.
Upvotes: 0
Reputation: 117403
Å is not a standard XML entity. In order to support it in your XML document, your XML parser needs to be DTD-aware and the document must have a DOCTYPE declaration which either defines that entity or refers to a DTD that defines that entity. An XHTML DTD, for example, defines Å to mean Å.
It is correct for your DOM XML parser to throw an error when it sees a named entity that it is not already aware of, and the parser is either not DTD-aware or there is no DOCTYPE declaration for what that entity means. XML itself defines the entities <, >, &, and ". These are the named entities that can be safely used in any XML application.
If you are writing the document yourself, then just don't use Å - use a numeric equivalent instead or, assuming you're using Unicode, just use the character literal.
If you need to be able to parse XML documents from other people containing any other named entity, and the documents don't have a DOCTYPE, then as Frank mentioned you will need to fix the document yourself by inserting a correct DOCTYPE after the XML declaration.
Upvotes: 0
Reputation: 56604
When used without a DTD, XML only supports a very limited number of named entities. (<
, >
, &
, and "
, as I recall.) To include other out-of-charset characters without using a DTD, simply refer to them with a numeric entity instead.
For example, Å
corresponds to Unicode character U+00C5, "Latin Capital Letter A With Ring Above". You can therefore use Å
(leading zeroes can be omitted) to include it in your document. If you're on Windows, the Character Map tool (on XP: Start > Programs > Accessories > System Tools) is a big help.
Upvotes: 1
Reputation: 39366
Include a DTD that defines the entities, like this one
Here's a post at PHP.net that hints at how to succesfully include it.
The DTD above should probably cover you; Å is an HTML entity, and the DTD above covers all HTML 4.01 entities.
Upvotes: 1