Java Reference
In-Depth Information
an uppercase or lowercase letter for each h . As a result, Σ , Σ ,
and Σ are also valid representations of the Greek capital letter sigma.
• A character entity reference refers to a character via the name of an entity
(aliaseddata)thatspecifiesthedesiredcharacterasitsreplacementtext.Char-
acter entity references are predefined by XML and have the format & name ; ,
where name istheentity'sname.XMLpredefinesfivecharacterentityreferen-
ces: &lt; ( < ), &gt; ( > ), &amp; ( & ), &apos; ( ' ), and &quot; ( " ).
Consider <expression>6 < 4</expression> .Youcouldreplacethe < with
numericreference &#60; ,yielding <expression>6 &#60; 4</expression> ,
orbetteryetwith &lt; ,yielding <expression>6 &lt; 4</expression> .The
second choice is clearer and easier to remember.
Suppose you want to embed an HTML or XML document within an element. To
maketheembeddeddocumentacceptabletoanXMLparser,youwouldneedtoreplace
each literal < (start of tag) and & (start of entity) character with its &lt; and &amp;
predefined character entity reference, a tedious and possibly error prone undertak-
ing—youmightforgettoreplaceoneofthesecharacters.Tosaveyoufromtediumand
potentialerrors,XMLprovidesanalternativeintheformofaCDATA(characterdata)
section.
A CDATA section isasectionofliteralHTMLorXMLmarkupandcontentsurroun-
ded by the <![CDATA[ prefix and the ]]> suffix. You do not need to specify pre-
definedcharacterentityreferenceswithinaCDATAsection,asdemonstratedin Listing
10-4 .
Listing 10-4. Embedding an XML document in another document's CDATA section
<?xml version="1.0"?>
<svg-examples>
<example>
The following Scalable Vector Graphics document de-
scribes a blue-filled and
black-stroked rectangle.
< ![CDATA[ <svg
width="100%"
height="100%"
ver-
sion="1.1"
xmlns="http://www.w3.org/2000/svg">
<rect width="300" height="100"
style="fill:rgb(0,0,255);stroke-width:1;
stroke:rgb(0,0,0)"/>
Search WWH ::




Custom Search