xml语法 [英] xml syntax

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

问题描述

您好,


我一直在阅读有关xml等的内容,但xml是否有bnf可以使用它?如果

没有,解析器如何工作,如果有,有人可以指向bnf

可能在哪里?


谢谢。


-g

Hello,

I''ve been reading about xml, etc. but does xml have a bnf to go with it? If
not, how do the parsers work, if yes, can someone point me to where the bnf
might be?

Thanks.

-g

推荐答案



Geoff写道:

Geoff wrote:

我一直在阅读有关xml等的内容,但xml是否有bnf可以使用它?
I''ve been reading about xml, etc. but does xml have a bnf to go with it?



否,XML定义了一种语法,它指定了什么是格式良好的语法。 XML

文档看起来像。然后,基于此的XML Schema或DTD允许

开发人员在一组文档中定义元素集及其嵌套规则

。这指定文件

根据该模式有效。可以看起来像。 DTD是一个比Schema更旧的

标准,并且有很多重叠 - 但是不能完全忽略




BNF在DTD水平附近。然而,BNF也太过分了,而且EBNF定义太不一致,在这里很有用。

它们只是不用于XML工作。


它也是XML的一个基本部分(与SGML相反)

格式良好。是重要的,并且是有效的而不是那么的。这是通过解析它来处理XML工具的常见做法,即使他们没有DTD就可以使用它们 - 如果你不这样做的话不知道DTD,那么你

甚至无法判断XML是否有效。然而,它仍然是一个实用的
XML文档,你可以在它上面做有用的工作。


如果你正在寻找有趣的新模式语言看看,对BNF的
偏好,然后看看Relax NG。

No, XML defines a syntax, which specifies what a "well formed" XML
document looks like. Then XML Schema or DTD on top of this allows the
developer to define the set of elements and their nesting rules
permitted within a set of documents. This specifiies what a document
"valid according to that schema" can look like. DTD is an older
standard than Schema, and there''s a lot of overlap -- neither can be
completely ignored though.

BNF is somewhere around the DTD level. However BNF is also far too
trivial, and EBNF is too inconsistently defined, to be useful here.
They''re just not used in XML work.

It''s also a fundamental part of XML (in contrast to SGML) that
"well-formed" is important and that being "valid" rather less so. It''s
common practice for tools to work with XML by parsing it, even though
they don''t have the DTD --- and if you don''t know the DTD, then you
can''t even tell if XML is valid or not. However it''s still a practical
XML document and you can do useful work on it.

If you''re looking for interesting new schema languages to look at, in
preference to BNF, then look hard at Relax NG.


Andy Dingley写道:
Andy Dingley wrote:

Geoff写道:
Geoff wrote:

>我一直在阅读关于xml等等但是xml有一个不知道怎么回事?
>I''ve been reading about xml, etc. but does xml have a bnf to go with it?



否,XML定义了一种语法,它指定了什么是格式良好的语法。 XML

文档看起来像。


No, XML defines a syntax, which specifies what a "well formed" XML
document looks like.



对于该语法,有一个EBNF语法,请参阅
http://www.w3.org/TR/REC-xml/#sec-notation

EBNF规则在Rec中定义。


我不知道任何官方的EBNF作品来源。

// Magnus

And for that syntax there is an EBNF grammar, see
http://www.w3.org/TR/REC-xml/#sec-notation.

The EBNF rules are defined in context in the Rec.

I don''t know of any official source of the EBNF productions alone.
// Magnus




Magnus Henriksson写道:

Magnus Henriksson wrote:

EBNF规则在Rec中的上下文中定义。
The EBNF rules are defined in context in the Rec.



必须质疑任何规范语言的正式价值,每次使用时都必须重新定义
! XML规范中的EBNF也不包括

,就像XML语法及其所有规则的完整陈述一样。

One has to question the formal value of any specification language that
has to be re-defined every time you use it! Nor is the EBNF included
in the XML specification anything like a complete statement of XML
syntax and all its rules.


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

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