XML 是一种编程语言吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13665671/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 13:48:28  来源:igfitidea点击:

Is XML a programming language?

xml

提问by Arturs Vancans

I often hear when people list the programming languages they know, they mention XML.

我经常听到当人们列出他们知道的编程语言时,他们提到了 XML。

But is it even a programming language?

但它甚至是一种编程语言吗?

I consider XML as a "dataset" similar to JSON.

我认为 XML 是类似于 JSON 的“数据集”。

Moreover, I have seen companies requiring knowledge of XML but... what is much to know there?

此外,我看到一些公司需要 XML 知识,但是……有什么需要了解的?

采纳答案by Nowhere man

A programming language?

一种编程语言?

First, XMLis a format to represent data. It has originally be designed for this data to be essentially text documents or messages, but nothing prevents you from representing any data you wish, including programs. There at least three big examples of programs expressed in XMLthat come to mind:

首先,XML是一种表示数据的格式。它最初是为这些数据设计的,本质上是文本文档或消息,但没有什么可以阻止您表示您希望的任何数据,包括程序。至少可以想到三个用XML表示的程序示例:

  1. XSLTis a Turing-completelanguage whose only standard format is in XML, whose essential purpose is data transformations.
  2. ANTis a task manager, used mostly for compilation management, whose tasks are described in XML.
  3. GCC-XMLis a format that GCC can use to output the result of its parsing of a source code.
  1. XSLT是一种图灵完备语言,其唯一的标准格式是 XML,其基本目的是数据转换。
  2. ANT是一个任务管理器,主要用于编译管理,其任务用XML描述。
  3. GCC-XML是一种格式,GCC 可以使用它来输出其解析源代码的结果。

On a more esoteric note, you could cite o:XML, a full-fledged XMLprogramming language.

在更深奥的说明中,您可以引用o:XML,这是一种成熟的XML编程语言。

So as any XML, DTDor Schema semantically extends XMLitself, you could technically argue that XML itself, through some of its extensions, isa programming language.

因此,由于任何XMLDTD或 Schema 在语义上扩展了XML本身,从技术上讲,您可以认为 XML 本身,通过它的一些扩展,一种编程语言。

Is there much to know?

有很多东西要知道吗?

Second, XML is a vast nebula of specifications, and most people only barely scratch the surface. Most people don't even imagine the corner cases in XML itself, let alone what's in XML Namespaces, XML Schema, XML Information Set, XQuery, XPath, XSLT, XSL-FO, XML Canonicalization, XML Signature, Efficient XML Interchange, XML Linking, etc.

其次,XML 是一个庞大的规范星云,大多数人只触及皮毛。大多数人甚至无法想象 XML 本身的极端情况,更不用说 XML 命名空间、XML 架构、XML 信息集、XQuery、XPath、XSLT、XSL-FO、XML 规范化、XML 签名、高效的 XML 交换、XML 链接中的内容, 等等。

So, yeah, I'd say there's plenty to know...

所以,是的,我想说有很多东西要知道......

回答by Mark Reed

XML is not a programming language.

XML 不是一种编程语言。

There are programming languages that use XML syntax, notably XSL.

有使用 XML 语法的编程语言,特别是 XSL。

There is a lot to learn about XML, however. The rules of its syntax, how namespaces and DTDs and schemas work, etc. Also, programmers using XML need to how to interact with documents via the DOM and XPath even if the language they're using is not itself XML-based.

然而,关于 XML 有很多东西需要学习。其语法规则、名称空间和 DTD 以及模式如何工作等。此外,使用 XML 的程序员需要如何通过 DOM 和 XPath 与文档交互,即使他们使用的语言本身不是基于 XML 的。

回答by Guvante

XML isn't a programming language anymore than HTML is, however tons of people will also list HTML as a programming language, so it isn't surprising.

XML 不再像 HTML 那样是一种编程语言,但是很多人也会将 HTML 列为一种编程语言,所以这并不奇怪。

what is much to know there?

有什么需要知道的?

XML has unique quirks about it, even though the libraries are quite powerful, knowing how to work with the libraries and knowing how to handle odd things the library cannot is very important.

XML 有其独特的怪癖,尽管库非常强大,但知道如何使用库以及知道如何处理库无法处理的奇怪事情非常重要。

For instance, the following would give you an "unexpected token at 0 : '&'" error, even though anyone with any XML experience would know what the problem really is. If you didn't know anything about XML it would look like garbage.

例如,以下内容会给您一个“0 处的意外标记:'&'”错误,即使任何具有 XML 经验的人都知道问题究竟是什么。如果您对 XML 一无所知,它看起来就像是垃圾。

<Root>
    <Leaf />
</Root>

回答by Michael Kay

XML is not a programming language.

XML 不是一种编程语言。

How much is there to know? Just browse the questions on StackOverflow that are tagged as XML questions.

有多少要知道?只需浏览 StackOverflow 上标记为 XML 问题的问题即可。

回答by Lightness Races in Orbit

No.

不。

It does not define ways to express computer programs.

它没有定义表达计算机程序的方式。

It is a markup language, that defines ways to express data. When you say it's "similar" to JSON, you're correct — it's an equivalent thing.

它是一种标记语言,定义了表达数据的方式。当你说它与 JSON “相似”时,你是对的——它是等价的。

People say a lot of things about XML and, usually, when you see a company requiring "knowledge of XML" it's only because they were part of the ridiculous XML "craze" in the management world in the mid-2000s and haven't even moved on from thatyet. You can't really "know" all that much about XML, and it's unsuitable for a ton of things that management will insist XML is the job for, just because it's a buzzword.

人们对 XML 说了很多,通常,当您看到一家公司需要“XML 知识”时,那只是因为它们是 2000 年代中期管理界可笑的 XML“热潮”的一部分,甚至还没有从移动的那个呢。关于 XML,您不可能真正“了解”那么多,而且它不适合管理人员坚持 XML 是其工作的大量事情,仅仅因为它是一个流行词。

回答by Dean

XML is not a programming language.

XML 不是一种编程语言。

I agree with Wikipedia here: "A programming language is a notation for writing programs, which are specifications of a computation or algorithm."

我同意维基百科的说法:“编程语言是编写程序的符号,它是计算或算法的规范。”

There are programming languages whose syntax is in XML Yet, this doesn't make XML a programming language on its own. That's like saying plain text is a programming language because there are programming languages that can be expressed in plain text.

有些编程语言的语法是 XML 格式的。然而,这并不能使 XML 本身成为一种编程语言。这就像说纯文本是一种编程语言,因为有些编程语言可以用纯文本表示。

In other words, XML itself doesn't provide "specifications of a computation or algorithm".

换句话说,XML 本身不提供“计算或算法的规范”。