Entity Reference Name Can Not Contain Character ='
Utilise Character and Entity References
Non all characters are bachelor on the keyboard! This hack shows y'all how to represent such characters in an XML document by using decimal and hexadecimal character references, and how to represent entities by using entity references .
In XML, character and entity references are formed by surrounding a numerical value or a name with &
and ;
—for example, ©
is a decimal character reference and ©
is an entity reference. This hack shows you how to use both.
Character References
According to the third and latest edition of the XML 1.0 specification (http://www.w3.org/TR/REC-xml/), XML processors must take over one,000,000 hexadecimal characters (http://www.w3.org/TR/REC-xml/#charsets). Information technology's possible that you won't be able to find all those characters on your keyboard! Don't worry. You can use graphic symbol references instead.
Yous can reference characters using either decimal or hexadecimal numbers. Which i you use is a matter of style. The certificate Namen.xml uses both (Example one-v); it contains some German names enclosed in German language tags.
Case i-5. Namen.xml
<?xml version="1.0" encoding="UTF-viii"?> <?xml-stylesheet href="Namen.css" type="text/css"?> <Namen xml:lang="de"> <Proper name> <Vorname>Marie</Vorname> <Nachname>Müller</Nachname> <Geschlecht>♀</Geschlecht> </Name> <Name> <Vorname>Klaus</Vorname> <Nachname>Grandüller</Nachname> <Geschlecht>♂</Geschlecht> </Name> </Namen>
On lines 7 and viii are the decimal character references ü
and ♀
, respectively. The first ane refers to the letter of the alphabet u with an umlaut (ü) and the 2d 1 is a female sign. Lines 12 and 13 utilize the hexadecimal character references ü
(ü) and ♂
(male sign), respectively. You can run into how these character references are rendered in Opera in Figure 1-half-dozen.
Figure i-6. Namen.xml in Opera, styled by Namen.css
Entity References
XML has 5 predefined entities, listed in Table i-one. These predefined entities can be used where the equivalent literal character is forbidden. For case, an aspect value cannot comprise a less-than sign (<
), because it looks too much like the outset of a tag to an XML parser. No trouble: you lot can use <
instead. Too, you cannot use an ampersand in parsed character data, the text content of an element. Why? Again, it looks like the beginning of a grapheme or entity reference to an XML parser. Again, no problem: y'all can use &
instead.
Table 1-one. XML predefined entities
Entity reference | Description |
---|---|
| Less-than sign or open angle bracket ( |
| Greater-than sign or shut bending subclass ( |
| Ampersand ( |
| Apostrophe or single quote (') |
| Quote or double quote (") |
The following certificate, copy.xml in Example one-six, uses a predefined entity and too declares and references a new entity.
Case 1-6. re-create.xml
<?xml version="i.0" encoding="UTF-eight"?> <?xml-stylesheet href="copy.css" type="text/css"?> <!DOCTYPE time [<!ENTITY re-create "©">]> <!-- a time instant --> <time timezone="PST"> <60 minutes>11</hour> <minute>59</infinitesimal> <second>59</second> <meridiem>p.m.</meridiem> <atomic signal="true"/> <copyright>© O'Reilly & Associates</copyright> </time>
The entity copy
is declared in the document type announcement on line iii. The keyword is ENTITY
; it is followed past the entity name re-create
; and this is followed past the value or content of the entity in quotes, "©
". (This entity comes standard in HTML and XHTML.) Line 12 of this document references the entity declared on line 3 (©
) and also references the XML i.0 predefined entity for an ampersand (&
). Open this document in Firefox (it is styled past the CSS stylesheet copy.css) and it will appear like Figure 1-7.
Figure 1-7. copy.xml in Firefox
Character references provide a convenient means to access a very large number of characters. Entities [Hack #25] are too a user-friendly means to store information and access information technology elsewhere, fifty-fifty multiple times if necessary.
figueroathallusithe.blogspot.com
Source: https://www.oreilly.com/library/view/xml-hacks/0596007116/ch01s05.html
0 Response to "Entity Reference Name Can Not Contain Character ='"
Postar um comentário