XSLT character encoding - entity undefined

I am using XSLT and have great success, I have several problems.

Warning: DOMDocument :: loadXML () [domdocument.loadxml]: Entity 'Aring' not defined in Entity

Basically for some non-standard characters I get the above error type. I really want to fix this once and for all. I know about character collation, but I cannot write down every possible combination of special characters.

0


a source to share


4 answers


Include a DTD that defines entities like this

Here's a post on PHP.net that hints on how to successfully enable it.



The above DTD should probably cover you; & Amp; Aring; is an HTML entity, and the DTD above covers all HTML 4.01 entities.

+1


a source


When used without a DTD, XML only supports a very limited number of named objects. ( <

, >

, &

, And "

, as I recall.) To turn the other characters outside the encoding without using the DTD, simply refer to them instead of a numeric object.



For example, Å

matches the Unicode character U + 00C5, "Latin capital letter A with ring above." So you can use Å

(leading zeros can be omitted) to include it in your document. If you are on Windows it is very helpful to use the Symbol Map tool (in XP: Start> Programs> Accessories> System Tools).

+1


a source


& Aring; is not a standard XML object. To support it in your XML document, your XML parser must be DTD-aware, and the document must have a DOCTYPE declaration that either defines this object or refers to a DTD that defines this object. For example, the XHTML DTD defines & Aring; to denote & # xC5 ;.

It is correct for your DOM XML parser to throw an error when it sees a named object that it doesn't already know about, and the parser is either not DTD knowledge, or there is no DOCTYPE declaration for what that object means. XML itself defines entities & lt ;, & amp ;, ". These are named objects that can be safely used in any XML application.

If you're writing the document yourself, just don't use & Aring; - use a numeric equivalent instead, or, assuming you are using Unicode, just use a character literal.

If you need to parse other people's XML documents that contain any other named object and the documents do not have a DOCTYPE, then, as Frank said, you need to fix the document yourself by inserting the correct DOCTYPE after the XML declaration.

0


a source


Note that there is also a function DOMDocument::loadHTML

that treats the document as HTML and that it will not try to activate these objects.

0


a source







All Articles