XML简易教程之四

来源:互联网 时间:2008-09-05 17:19:00 

实体

有五种预定义的XML实体,HTML编码者应该熟悉。XML文档中的字符&、<、>、"和'被分别表示为&、@lt;、>、"和&apos;。

XML很大程度上扩展了实体的功能 - 允许在DTD中定义实体以便在文档的其余部分使用。例如,我在XML文档中需要频繁使用词组"Wired Digital",可以在DTD中这样表示:

<!ENTITY wd "Wired Digital">

这样当我使用这个词组时,可以敲入&wd;。于是可以避免拼错和重复敲入相同的信息。实体可以起到字处理器中宏的作用。

被替换的文本可以任意长,但是如果真是很长,可能要把信息存储在另一个文件中。可以通过外部实体参考来实现 - 在实体名和文件的URL中使用关键字SYSTEM:

<!ENTITY text SYSTEM "http://my.url.here">

这些特征功能强大,但有一个缺点:在一个DTD内不能被扩展。为了实现扩展功能,需要一个称为参数实体的特殊工具。它在实体定义中通过在实体名前插入"%"实现。一旦被定义,参数定义可以通过用百分号和分号包围参数名来实现。

为什么这么做?看看下面的代码:


<!ELEMENT vCard (%prop.man;, (%prop.id; | %prop.del; |

%prop.tel; | %prop.geo; | %prop.org; |

%prop.exp; | %prop.sec;)*)>


这段代码来自一个公用的XML名片草稿。当定义根元素时,作者发现更容易把信息分离到不同的参数实体中。如果看看其中的一个实体表现,我们就会知道为什么了。看看下面的prop.id实体:


<!ENTITY % prop.id "

(nickname | photo | bday)">


如果每个实体都用这么长的字符串表示,元素定义将很难阅读。

现在可以读一些DTD了。

Jay Greenspan ISO-8859-1 Entities
Named
Entity Numeric
Entity Glyph Description
&#00;-
unused
horizontaltab
linefeed
unused
space
! ! exclamationmark
" " " doublequotationmark
# # numbersign
$ $ dollarsign
% % percentsign
& & & amperstand
' ' apostrophe
( ( leftparenthesis
) ) rightparenthesis
* * asterisk
+ + plussign
, , comma
- - hyphen
. . period(fullstop)

Named
Entity Numeric
Entity Glyph Description

/ / solidus(slash)
0-
9 digits0-9
: : colon
; ; semicolon
< < < less-thansign
= = equalssign
> > > greater-thansign
? ? questionmark
@ @ commercialat
A-
Z letters A-Z
[ ][ leftsquarebracket
\ \ reversesolidus(backslash)
] ] rightsquarebracket
^ ^ caret
_ _ horizontalbar(underscore)
` ` acuteaccent
a-
z letters a-z
{ { leftcurlybrace
| | verticalbar

Named
Entity Numeric
Entity Glyph Description
} } rightcurlybrace
~ ~ tilde
-
Ÿ unused
    non-breakingspace
&iexcl; &iexcl; invertedexclamation
&cent; &cent; centsign
&pound; &pound; poundsterling
¤ ¤ generalcurrencysign
&yen; &yen; yensign
&brvbar; &brvbar; brokenverticalbar
§ § sectionsign
¨ ¨ umlaut(dieresis)
&copy; &copy; &copy; copyright
&ordf; &ordf; feminineordinal
&laquo; &laquo; leftanglequote, guillemotleft
&not; &not; notsign
&shy; &shy; softhyphen
&reg; &reg; registeredtrademark
&macr; &macr; macronaccent

Named
Entity Numeric
Entity Glyph Description
° ° degreesign
± ± plusorminus
&sup2; &sup2; superscripttwo
&sup3; &sup3; superscriptthree
&acute; &acute; acuteaccent
&micro; &micro; microsign
&para; &para; paragraphsign
· · middledot
&cedil; &cedil; cedilla
&sup1; &sup1; superscriptone
&ordm; &ordm; masculineordinal
&raquo; &raquo; rightanglequote, guillemotright
&frac14; &frac14; one-fourth
&frac12; &frac12; one-half
&frac34; &frac34; three-fourths
&iquest; &iquest; invertedquestionmark
&Agrave; &Agrave; &Agrave; uppercaseA, graveaccent
&Aacute; &Aacute; &Aacute; uppercaseA, acuteaccent
&Acirc; &Acirc; &Acirc; uppercaseA, circumflexaccent

Named
Entity Numeric
Entity Glyph Description
&Atilde; &Atilde; &Atilde; uppercaseA, tilde
&Auml; &Auml; &Auml; uppercaseA, dieresisorumlautmark
&Aring; &Aring; &Aring; uppercaseA, ring
&AElig; &AElig; &AElig; uppercaseAEdipthong(ligature)
&Ccedil; &Ccedil; &Ccedil; uppercaseC, cedilla
&Egrave; &Egrave; &Egrave; uppercaseE, graveaccent
&Eacute; &Eacute; &Eacute; uppercaseE, acuteaccent
&Ecirc; &Ecirc; &Ecirc; uppercaseE, circumflexaccent
&Euml; &Euml; &Euml; uppercaseE, dieresisorumlautmark
&Igrave; &Igrave; &Igrave; uppercaseI, graveaccent
&Iacute; &Iacute; &Iacute; uppercaseI, acuteaccent
&Icirc; &Icirc; &Icirc; uppercaseI, circumflexaccent
&Iuml; &Iuml; &Iuml; uppercaseI, dieresisorumlautmark
&ETH; &ETH; &ETH; uppercaseEth, Icelandic
&Ntilde; &Ntilde; &Ntilde; uppercaseN, tilde
&Ograve; &Ograve; &Ograve; uppercaseO, graveaccent
&Oacute; &Oacute; &Oacute; uppercaseO, acuteaccent
&Ocirc; &Ocirc; &Ocirc; uppercaseO, circumflexaccent
&Otilde; &Otilde; &Otilde; uppercaseO, tilde

Named
Entity Numeric
Entity Glyph Description
&Ouml; &Ouml; &Ouml; uppercaseO, dieresisorumlautmark
× × multiplysign
&Oslash; &Oslash; &Oslash; uppercaseO, slash
&Ugrave; &Ugrave; &Ugrave; uppercaseU, graveaccent
&Uacute; &Uacute; &Uacute; uppercaseU, acuteaccent
&Ucirc; &Ucirc; &Ucirc; uppercaseU, circumflexaccent
&Uuml; &Uuml; &Uuml; uppercaseU, dieresisorumlautmark
&Yacute; &Yacute; &Yacute; uppercaseY, acuteaccent
&THORN; &THORN; &THORN; uppercaseTHORN, Icelandic
&szlig; &szlig; &szlig; lowercasesharps, German(szligature)
à à à lowercasea, graveaccent
á á á lowercasea, acuteaccent
&acirc; &acirc; &acirc; lowercasea, circumflexaccent
&atilde; &atilde; &atilde; lowercasea, tilde
&auml; &auml; &auml; lowercasea, dieresisorumlautmark
&aring; &aring; &aring; lowercasea, ring
&aelig; &aelig; &aelig; lowercaseaedipthong(ligature)
&ccedil; &ccedil; &ccedil; lowercasec, cedilla
è è è lowercasee, graveaccent

Named
Entity Numeric
Entity Glyph Description
é é é lowercasee, acuteaccent
ê ê ê lowercasee, circumflexaccent
&euml; &euml; &euml; lowercasee, dieresisorumlautmark
ì ì ì lowercasei, graveaccent
í í í lowercasei, acuteaccent
&icirc; &icirc; &icirc; lowercasei, circumflexaccent
&iuml; &iuml; &iuml; lowercasei, dieresisorumlautmark
&eth; &eth; &eth; lowercaseeth, Icelandic
&ntilde; &ntilde; &ntilde; lowercasen, tilde
ò ò ò lowercaseo, graveaccent
ó ó ó lowercaseo, acuteaccent
&ocirc; &ocirc; &ocirc; lowercaseo, circumflexaccent
&otilde; &otilde; &otilde; lowercaseo, tilde
&ouml; &ouml; &ouml; lowercaseo, dieresisorumlautmark
÷ ÷ divisionsign
&oslash; &oslash; &oslash; lowercaseo, slash
ù ù ù lowercaseu, graveaccent
ú ú ú lowercaseu, acuteaccent
&ucirc; &ucirc; &ucirc; lowercaseu, circumflexaccent

Named
Entity Numeric
Entity Glyph Description
ü ü ü lowercaseu, dieresisorumlautmark
&yacute; &yacute; &yacute; lowercasey, acuteaccent
&thorn; &thorn; &thorn; lowercasethorn, Icelandic
&yuml; &yuml; &yuml; lowercasey, dieresisorumlautmark 

标签:
0
投稿

猜你喜欢

  • 浏览器 cookie 限制

    2008-05-23 13:09:00
  • 又一个仿alert提示效果

    2007-12-24 17:34:00
  • 在MySQL中获得更好的全文搜索结果

    2008-05-09 10:38:00
  • 激发你的灵感:50个优秀的Favicons设计

    2007-10-21 19:52:00
  • 网页设计软件FrontPage快捷键一览

    2008-02-24 16:55:00
  • 微软补丁KB967723造成MySQL频繁无法连接

    2009-11-03 14:28:00
  • Safari显示网页字体为超级无敌难看的宋体的原因

    2008-04-20 16:49:00
  • 如何解决AJAX中跨域访问出现'没有权限'的错误

    2008-09-11 17:20:00
  • CSS制作滑动折叠的文字效果

    2008-12-01 13:10:00
  • Sub-Pixel Bug?!

    2010-03-24 18:09:00
  • CSS浏览器兼容问题整理(IE6.0、IE7.0 与FireFox)

    2008-10-27 13:45:00
  • SQLServer中用T—SQL命令查询一个数据库中有哪些表的sql语句

    2012-07-11 15:28:50
  • 网页设计:把导航系统做薄

    2007-12-28 12:02:00
  • Windows下MySQL安全权限设置方法

    2009-07-30 08:32:00
  • ASP分页函数

    2009-07-06 12:41:00
  • XPath 11个实例

    2008-09-05 15:06:00
  • 一行代码给你的WordPress Blog添加下雪效果

    2008-12-14 09:43:00
  • SQLServer中字符串左对齐或右对齐显示的sql语句

    2012-06-06 19:36:45
  • PHP获取特殊时间戳的方法整理

    2023-05-25 00:47:36
  • Unobtrusive的Web开发

    2007-11-23 13:13:00
  • asp之家 网络编程 m.aspxhome.com