xml - 各种 XML 定义的示例
问题描述
在阅读XML 规范时,它提到了以下定义:
Names and Tokens
[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[5] Name ::= NameStartChar (NameChar)*
Literals
[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' | "'" ([^%&'] | PEReference | Reference)* "'"
[10] AttValue ::= '"' ([^<&"] | Reference)* '"'| "'" ([^<&'] | Reference)* "'"
[11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
[12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
什么是名称、实体、属性、SystemLiteral 和 Pubid 的示例(?)
例如在下面:
<Item id="123">Hello<Item/>
是Item
名称还是实体值?我会假设123
或"123"
将是 Att(ribute)Value。这两个都对吗?其他人的例子是什么?
从规范中说:
文字数据是任何带引号的字符串,不包含用作该字符串分隔符的引号。文字用于指定内部实体的内容 (EntityValue)、属性的值 (AttValue) 和外部标识符 (SystemLiteral)。
因此,我认为Item
将是EntityValue,123
将是AttrValue:那么 PubID 和 SystemLiteral 的示例是什么?最后,为什么不EntityValue
排除<
和>
字符?
解决方案
您的 XML 示例解析如下:
<Item id="123">Hello<Item/>
是一个元素:
<Item id="123">
是一个STag:Hello
是content ,在这个例子中是CharData 。<Item/>
是一个ETag:Item
是一个名称。
您的示例中没有以下构造:
- EntityValue
示例:"2020"
在<!ENTITY year "2020">
- PubidLiteral
示例:"-//W3C//DTD HTML 4.01//EN"
in<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
) - SystemLiteral
示例:"../img/logo.gif"
在<!ENTITY logo SYSTEM "../img/logo.gif" NDATA gif >
有关如何使用、和的更多上下文,请参阅第4.2 节实体声明。EntityValue
PubidLiteral
SystemLiteral
推荐阅读
- ubuntu - 我如何尝试打开腻子控制台/命令提示符
- python - 计算以度为单位(顺时针)到弧度(逆时针)的角度
- excel - 将数据从单元格移动到现有行的末尾
- regex - 正则表达式从逗号分隔文件中提取前两个字段
- ansible - Ansible,pg_hba.conf 配置与来自主机文件的 IP
- java - 手牌和扑克牌之间的 Dack/Card 阵列复制
- php - 如何将 PHP 类数据传递给 $this 中的另一个类?
- c# - 如何在等待 Web 响应时更新 Windows 窗体文本框值
- kubernetes - 无法在 gcp 入口中打开 swagger 文档
- sql-server - SQL Server SQLCMD 模式 :setvar 的大小限制是多少?