XML_介绍

这篇翻译不完整。请帮忙从英语翻译这篇文章

Summary: This article introduces the 'eXtensible Markup Language' (XML) and tells of it's uses.XML是一种类似于HTML的标记语言。它代表可扩展标记语言并且是一个W3C推荐的规范作为一种通用标记语言。这意味着,与其他标记语言不同,XML未预定义,因此你必须定义自己的标记。该语言的主要目的是跨不同系统共享数据,如互联网。

有许多基于XML的语言;一些示例是  XHTMLMathMLSVGXULXBLRSS, 和 RDF。你也可以创建自己的。

 

什么是XML?

XML, 就是 Extensible Markup Language(可扩展标记语言), 是 W3C 推荐参考 通用标记语言. XML 同样也是SGML的子类.

许多语言都是基于XML, 如 XHTML, MathML, SVG, XUL, RSS, 还有 RDF.

为什么HTML会没有用

HTML标记是一种相对固定的语言,同时它也是以呈现数据为唯一目的,与之相反,XML是可以由用户自定义的,同时它是以存储数据为目的的。

HTML 可以归结为以下三个方面:intelligence(智能),maintenance(可维护性),adaptation(适应性)。XML 也有类似的特性:intelligence, adaptation, maintenance, 和simplicity(简洁)。

XML 不同于HTML,HTML 是显示标记,而XML 是通用标记。这两点可以在XSLT中融合在一起。

"正确的" XML (有效且格式良好)

For an XML document to be correct it must be a well-formed document, conforming to all of XML's syntax rules, and valid, conforming to a specific language's rules. An example of a document that is not well formed is one with an element that has an opening tag with no closing tag and is not self-closing.

 

XML 示例

There are two different ways that XML can be used for presentation, and this can range from transforming to HTML, to creating PDF or image codes.

One way to have have a style on a XML page is to use CSS with the xml stylesheet declaration.

<?xml-stylesheet type="text/css" href="stylesheet.css"?>

Or with the powerful XSLT, which is capable of transforming XML markup into any number of things, the possibilities are almost endless.

<?xml-stylesheet type="text/xsl" href="transform.xsl"?>

建议

研读其它XML指南,补充你自己的语法规则,记住这些指南简略的地介绍那些新的XML或者标识语言知识。

为了更好地理解XML,你应该去学习HTML标识语言,或者去阅读大量的指南,这些内容可在developer.mozilla.org中找到。

Displaying XML

XML is usually used for descriptive purposes, but there are ways to display XML data. If you don't define a specific way for the XML to be rendered, the raw XML is displayed in the browser.

One way to style XML output is to specify CSS to apply to the document using the xml-stylesheet processing instruction.

<?xml-stylesheet type="text/css" href="stylesheet.css"?>

There is also another more powerful way to display XML: the Extensible Stylesheet Language Transformations (XSLT) which can be used to transform XML into other languages such as HTML. This makes XML incredibly versatile.

<?xml-stylesheet type="text/xsl" href="transform.xsl"?>

Recommendations

This article is obviously only a very brief introduction to what XML is, with a few small examples and references to get you started. For more details about XML, you should look around on the Web for more in-depth articles.

Learning the HyperText Markup Language (HTML) will help you better understand XML.

See also

The Using XML article above is a great resource on information for transforming and creating your own language.

文档标签和贡献者

 最后编辑者: xgqfrms-GitHub,