In XSLT, some characters are not allowed in certain contexts. For example, you cannot use the less than sign (<) and the ampersand (&) in the text between tags or in an attribute value. The XSLT transformation engine will give you error if those characters are used incorrectly. To solve the problem, you can specify character entities to replace the special characters.
A character entity is a string of characters that represents other characters. Character entities are either named or numbered. A named entity begins with an ampersand (&) followed by the name or characters, and ends with a semicolon (;). For example, <
represents the left angle bracket character (<). Numbered entities also start and end the same way, except that a hash sign (#) and a number specifies the character.
XSLT has the following five predefined entities:
Character |
Entity Code |
---|---|
< (less-than) |
< |
& (ampersand) |
& |
> (greater-than) |
> |
" (quote) |
" |
(apostrophe) |
' |
If you use other character entities in an XSL file, you need to define them in the DTD section of the XSL file. Dreamweaver provides several default entity definitions that you can see at the top of an XSL file created in Dreamweaver. These default entities cover a broad selection of the most commonly used characters.
Dreamweaver checks the XSL file for undefined entities when you preview your XSL file in a browser. If it finds an undefined entity, Dreamweaver notifies you in a message box.
If you preview an XML file attached to an XSLT file or if you preview a server-side page with an XSLT transformation, the server or browser (instead of Dreamweaver) notifies you of an undefined entity. The following is an example of a message you may get in Internet Explorer when you request an XML file transformed by an XSL file with a missing entity definition:
Reference to undefined entity 'auml'. Error processing resource 'http://localhost/testthis/list.xsl'. Line 28, Position 20 <p class="test">ä</p> -------------------^
To correct the error in your page, youll need to add the entity definition to your page by hand.
This web page contains the 252 allowed entities in HTML 4 and XHTML 1.0.
For example, if the character entity Egrave is missing, search for "Egrave" on the W3C web page. You will find the following entry:
<!ENTITY Egrave CDATA "È" -- latin capital letter E with grave, U+00C8 ISOlat1 -->
In the example, Egrave
is the entity name, and È
is the entity code.
<!ENTITYentityname
"entitycode
;">
In the example, you would enter the following entity tag:
<!ENTITY Egrave "È">
If you repeatedly use the same character entities, you may want to permanently add their definitions in the XSL files Dreamweaver creates by default when you use File > New.
Configuration/DocumentTypes/MMDocumentTypeDeclarations.xml
<documenttypedeclaration id="mm_xslt_1">
<!ENTITYentityname
"entitycode
;">