理解 XML CharData EBNF [英] Understanding XML CharData EBNF

查看:23
本文介绍了理解 XML CharData EBNF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下EBNF规则表示为

The following EBNF rule expressed as

CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*) 

我真的很难理解.有人可以举几个有效和无效字符串的例子.对规则中所表达的内容进行简要说明也会非常有帮助.虽然也许要求有点多.如果您有一段有趣的 C++ 代码片段可以帮助发现这种情况,那也将是非常好的.

is really hard for me to understand. Can someone give a few examples of valid and invalid strings. A brief explanation of the what is being expressed in the rule would also be very helpful. Although perhaps asking a little much. It would also be ultra nice if you have an interesting snippet of c++ code lying around that'll help catch this occurrence.

推荐答案

CharData,

[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)

表示XML字符数据可以由除

means that XML character data can consist of any characters except

  • <,开始标记(标签、注释、XML 声明、CDATA 部分和 PI)
  • &,开始实体引用,
  • 字符串,]]>,结束 CDATA 部分.
  • <, which begins markup (tags, comments, XML declarations, CDATA sections, and PIs)
  • &, which begins entity references,
  • the string of characters, ]]>, which ends a CDATA section.

转义:

  • 在字符数据中将 < 转义为 &lt;.
  • 在字符数据中将 & 转义为 &amp;.
  • ]]> 不能出现在字符数据中;没有转义形式.
  • Escape < as &lt; in character data.
  • Escape & as &amp; in character data.
  • ]]> cannot appear in character data; there is no escaped form.

另见:

这篇关于理解 XML CharData EBNF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆