Text Handling

Displaying simple text works the same way in XHTML as it does in HTML: You just place the text directly in a document. XHTML elements that display text have mixed-content models, so they can contain both text and other elements, as in this example we saw earlier:

 <?xml version="1.0"?>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">     <head>         <title>             Welcome to my page         </title>     </head>     <body bgcolor="white" text="black" link="red" alink="blue"         vlink="green">  Welcome to my XHTML document.   Want to check out more about XHTML?   Go to   <a href="http://www.w3c.org">W3C</a>.  </body> </html> 

The text in this document is displayed directly in the browser, as you see in Figure 16-3. It's up to you to format the text the way you want it. In early versions of HTML, you used elements such as <b> (bold), <i> (italics), and <u> (underline) to format text; as formatting has become more sophisticated, though, the emphasis has switched to using stylesheets.

As you know, XML has five predefined entity references, and they stand for characters that can be interpreted as markup or other control characters :

  • &amp; becomes the & character.

  • &apos; becomes the ' character.

  • &gt; becomes the > character.

  • &lt; becomes the < character.

  • &quot; becomes the " character.

A great many more character entities exist in HTML 4.0, and they're supported in XHTML as well. You can find them in Table 16-1.

Table 16-1. Character Entities in XHTML (Support Varies by Browser)
Entity Numerical Does This  
Aacute &#193; Latin capital letter A with acute accent
aacute &#225; Latin small letter a with acute accent
Acirc &#194; Latin capital letter A with circumflex
acirc &#226; Latin small letter a with circumflex
acute &#180; Acute accent
AElig &#198; Latin capital letter AE
aelig &#230; Latin small letter ae
Agrave &#192; Latin capital letter A with grave accent
agrave &#224; Latin small letter a with grave accent
alefsym &#8501; Alef symbol; first transfinite cardinal
Alpha &#913; Greek capital letter alpha
alpha &#945; Greek small letter alpha
amp &#38; Ampersand
and &#8743; Logical and
ang &#8736; Angle
Aring &#197; Latin capital letter A with ring above
aring &#229; Latin small letter a with ring above
asymp &#8776; Almost equal to; asymptotic to
Atilde &#195; Latin capital letter A with tilde
atilde &#227; Latin small letter a with tilde
Auml &#196; Latin capital letter A with dieresis (umlaut)
auml &#228; Latin small letter a with dieresis (umlaut)
bdquo &#8222; Double low-9 quotation mark
Beta &#914; Greek capital letter beta
beta &#946; Greek small letter beta
brvbar &#166; Broken bar; broken vertical bar
bull &#8226; Bullet; black small circle
cap &#8745; Intersection; cap
Ccedil &#199; Latin capital letter C with cedilla
ccedil &#231; Latin small letter c with cedilla
cedil &#184; Cedilla
cent &#162; Cent sign
Chi &#935; Greek capital letter chi
chi &#967; Greek small letter chi
circ &#710; Modifier letter circumflex accent
clubs &#9827; Black club suit; shamrock
cong &#8773; Approximately equal to
copy &#169; Copyright sign
crarr &#8629; Downward arrow with corner leftward
cup &#8746; Union; cup
curren &#164; Currency sign
Dagger &#8225; Double dagger
dagger &#8224; Dagger
darr &#8595; Downward arrow
dArr &#8659; Downward double arrow
deg &#176; Degree sign
Delta &#916; Greek capital letter delta
delta &#948; Greek small letter delta
diams &#9830; Black diamond suit
divide &#247; Division sign
Eacute &#201; Latin capital letter E with acute accent
eacute &#233; Latin small letter e with acute accent
Ecirc &#202; Latin capital letter E with circumflex
ecirc &#234; Latin small letter e with circumflex
Egrave &#200; Latin capital letter E with grave accent
egrave &#232; Latin small letter e with grave accent
empty &#8709; Empty set; null set; diameter
emsp &#8195; Em space
ensp &#8194; En space
Epsilon &#917; Greek capital letter epsilon
epsilon &#949; Greek small letter epsilon
equiv &#8801; Identical to
Eta &#919; Greek capital letter eta
eta &#951; Greek small letter eta
ETH &#208; Latin capital letter ETH
eth &#240; Latin small letter eth
Euml &#203; Latin capital letter E with dieresis (umlaut)
euml &#235; Latin small letter e with dieresis (umlaut)
euro &#8364; Euro sign
exist &#8707; There exists
fnof &#402; Latin small with hook; function
forall &#8704; For all
frac12 &#189; Vulgar fraction one half
frac14 &#188; Vulgar fraction one quarter
frac34 &#190; Vulgar fraction three quarters
frasl &#8260; Fraction slash
Gamma &#915; Greek capital letter gamma
gamma &#947; Greek small letter gamma
ge &#8805; Greater than or equal to
gt &#62; Greater-than sign
hArr &#8660; Left/right double arrow
harr &#8596; Left/right arrow
hearts &#9829; Black heart suit; valentine
hellip &#8230; Horizontal ellipsis; three-dot leader
Iacute &#205; Latin capital letter I with acute accent
iacute &#237; Latin small letter i with acute accent
Icirc &#206; Latin capital letter I with circumflex
icirc &#238; Latin small letter i with circumflex
iexcl &#161; Inverted exclamation mark
Igrave &#204; Latin capital letter I with grave accent
igrave &#236; Latin small letter i with grave accent
image &#8465; Blackletter capital I; imaginary part
infin &#8734; Infinity
int &#8747; Integral
Iota &#921; Greek capital letter iota
iota &#953; Greek small letter iota
iquest &#191; Inverted question mark
isin &#8712; Element of
Iuml &#207; Latin capital letter I with dieresis (umlaut)
iuml &#239; Latin small letter i with dieresis (umlaut)
Kappa &#922; Greek capital letter kappa
kappa &#954; Greek small letter kappa
Lambda &#923; Greek capital letter lambda
lambda &#955; Greek small letter lambda
lang &#9001; Left-pointing angle bracket ; bra
laquo &#171; Left-pointing double-angle quotation mark
lArr &#8656; Leftward double arrow
larr &#8592; Leftward arrow
lceil &#8968; Left ceiling; apl upstile
ldquo &#8220; Left double quotation mark
le &#8804; Less than or equal to
lfloor &#8970; Left floor; apl downstile
lowast &#8727; Asterisk operator
loz &#9674; Lozenge
lrm &#8206; Left-to-right mark
lsaquo &#8249; Single left-pointing angle quotation mark
lsquo &#8216; Left single quotation mark
lt &#60; Less-than sign
macr &#175; Macron; spacing macron
mdash &#8212; Em dash
micro &#181; Micro sign
middot &#183; Middle dot
minus &#8722; Minus sign
Mu &#924; Greek capital letter mu
mu &#956; Greek small letter mu
nabla &#8711; Nabla; backward difference
nbsp &#160; No-break space; nonbreaking space
ndash &#8211; En dash
ne &#8800; Not equal to
ni &#8715; Contains as member
not &#172; Not sign
notin &#8713; Not an element of
nsub &#8836; Not a subset of
Ntilde &#209; Latin capital letter N with tilde
ntilde &#241; Latin small letter n with tilde
Nu &#925; Greek capital letter nu
nu &#957; Greek small letter nu
Oacute &#211; Latin capital letter O with acute accent
oacute &#243; Latin small letter o with acute accent
Ocirc &#212; Latin capital letter O with circumflex
ocirc &#244; Latin small letter o with circumflex
OElig &#338; Latin capital ligature OE
oelig &#339; Latin small ligature oe
Ograve &#210; Latin capital letter O with grave accent
ograve &#242; Latin small letter o with grave accent
oline &#8254; Overline; spacing overscore
Omega &#937; Greek capital letter omega
omega &#969; Greek small letter omega
Omicron &#927; Greek capital letter omicron
omicron &#959; Greek small letter omicron
oplus &#8853; Circled plus; direct sum
or &#8744; Logical or; vee
ordf &#170; Feminine ordinal indicator
ordm &#186; Masculine ordinal indicator
Oslash &#216; Latin capital letter O with stroke
oslash &#248; Latin small letter o with stroke
Otilde &#213; Latin capital letter O with tilde
otilde &#245; Latin small letter o with tilde
otimes &#8855; Circled times; vector product
Ouml &#214; Latin capital letter O with dieresis (umlaut)
ouml &#246; Latin small letter o with dieresis (umlaut)
para &#182; Pilcrow sign
part &#8706; Partial differential
permil &#8240; Per mille sign
perp &#8869; Up tack; orthogonal to; perpendicular
Phi &#934; Greek capital letter phi
phi &#966; Greek small letter phi
Pi &#928; Greek capital letter pi
pi &#960; Greek small letter pi
piv &#982; Greek pi symbol
plusmn &#177; Plus or minus sign
pound &#163; Pound sign
Prime &#8243; Double prime; seconds; inches
prime &#8242; Prime; minutes; feet
prod &#8719; N-ary product; product sign
prop &#8733; Proportional to
Psi &#936; Greek capital letter psi
psi &#968; Greek small letter psi
quot &#34; Quotation mark; APL quote
radic &#8730; Square root; radical sign
rang &#9002; Right-pointing angle bracket; ket
raquo &#187; Right-pointing double-angle quotation mark
rArr &#8658; Rightward double arrow
rarr &#8594; Rightward arrow
rceil &#8969; Right ceiling
rdquo &#8221; Right double quotation mark
real &#8476; Blackletter capital R; real part symbol
reg &#174; Registered sign
rfloor &#8971; Right floor
Rho &#929; Greek capital letter rho
rho &#961; Greek small letter rho
rlm &#8207; Right-to-left mark
rsaquo &#8250; Single right-pointing angle quotation mark
rsquo &#8217; Right single quotation mark
sbquo &#8218; Single low-9 quotation mark
Scaron &#352; Latin capital letter S with caron
scaron &#353; Latin small letter s with caron
sdot &#8901; Dot operator
sect &#167; Section sign
shy &#173; Soft hyphen
Sigma &#931; Greek capital letter sigma
sigma &#963; Greek small letter sigma
sigmaf &#962; Greek small letter final sigma
sim &#8764; Tilde operator
spades &#9824; Black spade suit
sub &#8834; Subset of
sube &#8838; Subset of or equal to
sum &#8721; N-ary summation
sup &#8835; Superset of
sup1 &#185; Superscript 1
sup2 &#178; Superscript 2
sup3 &#179; Superscript 3
supe &#8839; Superset of or equal to
szlig &#223; Latin small letter sharp s
Tau &#932; Greek capital letter tau
tau &#964; Greek small letter tau
there4 &#8756; Therefore
Theta &#920; Greek capital letter theta
theta &#952; Greek small letter theta
thetasym &#977; Greek small letter theta symbol
thinsp &#8201; Thin space
THORN &#222; Latin capital letter THORN
thorn &#254; Latin small letter thorn
tilde &#732; Small tilde
times &#215; Multiplication sign
trade &#8482; Trademark sign
Uacute &#218; Latin capital letter U with acute accent
uacute &#250; Latin small letter u with acute accent
uArr &#8657; Upward double arrow
uarr &#8593; Upward arrow
Ucirc &#219; Latin capital letter U with circumflex
ucirc &#251; Latin small letter u with circumflex
Ugrave &#217; Latin capital letter U with grave accent
ugrave &#249; Latin small letter u with grave accent
uml &#168; Dieresis (umlaut)
upsih &#978; Greek upsilon with hook symbol
Upsilon &#933; Greek capital letter upsilon
upsilon &#965; Greek small letter upsilon
Uuml &#220; Latin capital letter U with dieresis (umlaut)
uuml &#252; Latin small letter u with dieresis
weierp &#8472; Script capital P; power set
Xi &#926; Greek capital letter xi
xi &#958; Greek small letter xi
Yacute &#221; Latin capital letter Y with acute accent
yacute &#253; Latin small letter y with acute accent
yen &#165; Yen sign; Yuan sign
Yuml &#376; Latin capital letter Y with dieresis
yuml &#255; Latin small letter y with dieresis
Zeta &#918; Greek capital letter zeta
zeta &#950; Greek small letter zeta
zwj &#8205; Zero width joiner
zwnj &#8204; Zero width nonjoiner

As I mentioned, as in HTML, XHTML supports various text-formatting tags, such as <b> for bold text, <i> for italic text, and <u> for underlined text. I'll take a look at them briefly because they're still very popular.



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net