所以在我们编写 XML Schema 之前,很多教程都使用这个:
<?xml version='1.0'?>
或
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<data-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
我的问题是,这部分是做什么用的?该网站具体是什么,我们为什么要使用它?还有其他方法可以做到这一点吗?
如果有帮助,我这样做是为了将 Excel 工作表转换为 XML。
最佳答案
<?xml version='1.0'?>
是一个 XML declaration并且不是特定于 XSD,而是一般的 XML 文档。
[Definition: XML documents should begin with an XML declaration which specifies the version of XML being used.]
由于 XSD 是一个 XML 文档,它也可能有一个 XML 声明。
这是 XML 声明 ( XMLDecl
) 的 BNF,带有指向其组成部分定义的链接:
XMLDecl ::= '<?xml'
VersionInfo
EncodingDecl
?
SDDecl
?
S
? '?>'
注意: Only one XML declaration is permitted in well-formed XML, and it must be at the top if anywhere .如果您违反此要求,您将看到如下错误:
The processing instruction target matching "[xX][mM][lL]" is not allowed.
你必须fix the problem在您的 XML 将是 well-formed 之前.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
是 namespace特殊申报 XML Schema instance namespace 强>。作为命名空间URI,其目的是为了便于控制组件名称的分组。 An XML namespace URI does not have to be retrievable .
另见
xsi
特别是。 ( xsi:type
、 xsi:nil
、 xsi:schemaLocation
和 xsi:noNamespaceSchemaLocation
)https://stackoverflow.com/questions/35835870/