该文档中有多少个不同的 XML 命名空间?
How many different XML Namespaces are in this document?
好的,我有这个文件:
<?xml version="1.0" encoding="utf-8"?>
<md:madcow xmlns:md="urn:Annotation"
xsi:schemaLocation="urn:Annotation D:\projects\DELOS\Annotation.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns ="urn:Annotation"
kind="withContent" media="text">
<md:metadata>
<md:author>ferro697702212</md:author>
<md:title> Eine weitere Annotation </md:title>
<md:creationDate>18/11/2009 10.26.09</md:creationDate>
<md:modificationDate>18/11/2015 10.26.09</md:modificationDate>
<md:sourceHttp>687474703a2f2f7777772e676f6f676c652e69742f</md:sourceHttp>
<md:type>example</md:type>
<md:public>true</md:public>
</md:metadata>
<annotationBody xmlns="urn:Annotation">
<contents id="1">
<textContent>Das ist ein Beispieltext für eine Annotation</textContent>
<attachments>
<attachedImage> file:://A/B/C</attachedImage>
</attachments>
</contents>
<contents id="2">
<md:textContent> Eine weitere Annotation </md:textContent>
<attachments>
<attachedAudio>http://www.h_da.de/xml/test.mp3</attachedAudio>
</attachments>
</contents>
<textSelection>
<path>BODY/CENTER/FORM/TABLE[2]/TBODY/TR[2]/TD/FONT/LABEL[3],23,6</path>
<contentRef>1</contentRef>
</textSelection>
</annotationBody>
</md:madcow>
这是我的问题:
此文档中有多少种不同的 XML 命名空间?
据我所知,第一个是:
xmlns:md="urn:Annotation"
这意味着这是第一个。
那么我有:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
这是第二个
那么我们有:
xsi:schemaLocation="urn:Annotation D:\projects\DELOS\Annotation.xsd"
它告诉我们 xsi 命名空间的模式定义在哪里。
那么我们有:
xmlns="urn:Annotation"
这告诉我们默认命名空间是什么。
最后我们有:
<annotationBody xmlns="urn:Annotation">
这告诉我们,在这里我们覆盖了这个特定元素的默认命名空间。顺便说一句,这是最让我困惑的地方,因为既然它是默认命名空间,我们到底为什么需要这里的命名空间声明?
所以是的...
我 understand/read 代码是否正确,如果不正确,您能告诉我为什么以及该文档中有多少不同的名称空间吗?
在此先感谢大家。
本文档中有两个不同的命名空间,分别是urn:Annotation
和http://www.w3.org/2001/XMLSchema-instance
。
urn:Annotation
被提到了 3 次,它既是文档的默认命名空间,也与 md
命名空间 prefix 相关联。命名空间 prefixes 是任意的,仅在定义它们的元素内有意义。
这意味着以下三个元素中的每一个都在相同的命名空间中并且携带完全相同的信息内容:
<Element xmlns="urn:example"/>
<a:Element xmlns:a="urn:example"/>
<b:Element xmlns:b="urn:example"/>
在您的特定文档中,存在一定程度的冗余,因为默认命名空间不需要重新- 在 annotationBody
元素中赋值。我们也真的 不需要 md
前缀。
这份文件载有完全相同的信息:
<?xml version="1.0" encoding="utf-8"?>
<madcow
xsi:schemaLocation="urn:Annotation D:\projects\DELOS\Annotation.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns ="urn:Annotation"
kind="withContent" media="text">
<metadata>
<author>ferro697702212</author>
<title> Eine weitere Annotation </title>
<creationDate>18/11/2009 10.26.09</creationDate>
<modificationDate>18/11/2015 10.26.09</modificationDate>
<sourceHttp>687474703a2f2f7777772e676f6f676c652e69742f</sourceHttp>
<type>example</type>
<public>true</public>
</metadata>
<annotationBody>
<contents id="1">
<textContent>Das ist ein Beispieltext für eine Annotation</textContent>
<attachments>
<attachedImage> file:://A/B/C</attachedImage>
</attachments>
</contents>
<contents id="2">
<md:textContent> Eine weitere Annotation </md:textContent>
<attachments>
<attachedAudio>http://www.h_da.de/xml/test.mp3</attachedAudio>
</attachments>
</contents>
<textSelection>
<path>BODY/CENTER/FORM/TABLE[2]/TBODY/TR[2]/TD/FONT/LABEL[3],23,6</path>
<contentRef>1</contentRef>
</textSelection>
</annotationBody>
</madcow>
How many different XML Namespaces are in this document?
None。
正如@Damien_The_Unbeliever 正确指出的那样,文档中出现了两个不同的名称空间 URI:urn:Annotation
和 http://www.w3.org/2001/XMLSchema-instance
。但是这些名称空间不是 "in" 文档,它们在文档之外。这就是命名空间的全部意义所在,它们不是文档的本地内容。
如果我没记错的话,文档包含 4 个命名空间声明,代表 3 个不同的命名空间绑定到 2 个不同的命名空间。
好的,我有这个文件:
<?xml version="1.0" encoding="utf-8"?>
<md:madcow xmlns:md="urn:Annotation"
xsi:schemaLocation="urn:Annotation D:\projects\DELOS\Annotation.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns ="urn:Annotation"
kind="withContent" media="text">
<md:metadata>
<md:author>ferro697702212</md:author>
<md:title> Eine weitere Annotation </md:title>
<md:creationDate>18/11/2009 10.26.09</md:creationDate>
<md:modificationDate>18/11/2015 10.26.09</md:modificationDate>
<md:sourceHttp>687474703a2f2f7777772e676f6f676c652e69742f</md:sourceHttp>
<md:type>example</md:type>
<md:public>true</md:public>
</md:metadata>
<annotationBody xmlns="urn:Annotation">
<contents id="1">
<textContent>Das ist ein Beispieltext für eine Annotation</textContent>
<attachments>
<attachedImage> file:://A/B/C</attachedImage>
</attachments>
</contents>
<contents id="2">
<md:textContent> Eine weitere Annotation </md:textContent>
<attachments>
<attachedAudio>http://www.h_da.de/xml/test.mp3</attachedAudio>
</attachments>
</contents>
<textSelection>
<path>BODY/CENTER/FORM/TABLE[2]/TBODY/TR[2]/TD/FONT/LABEL[3],23,6</path>
<contentRef>1</contentRef>
</textSelection>
</annotationBody>
</md:madcow>
这是我的问题:
此文档中有多少种不同的 XML 命名空间?
据我所知,第一个是:
xmlns:md="urn:Annotation"
这意味着这是第一个。
那么我有:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
这是第二个
那么我们有:
xsi:schemaLocation="urn:Annotation D:\projects\DELOS\Annotation.xsd"
它告诉我们 xsi 命名空间的模式定义在哪里。
那么我们有:
xmlns="urn:Annotation"
这告诉我们默认命名空间是什么。
最后我们有:
<annotationBody xmlns="urn:Annotation">
这告诉我们,在这里我们覆盖了这个特定元素的默认命名空间。顺便说一句,这是最让我困惑的地方,因为既然它是默认命名空间,我们到底为什么需要这里的命名空间声明?
所以是的...
我 understand/read 代码是否正确,如果不正确,您能告诉我为什么以及该文档中有多少不同的名称空间吗?
在此先感谢大家。
本文档中有两个不同的命名空间,分别是urn:Annotation
和http://www.w3.org/2001/XMLSchema-instance
。
urn:Annotation
被提到了 3 次,它既是文档的默认命名空间,也与 md
命名空间 prefix 相关联。命名空间 prefixes 是任意的,仅在定义它们的元素内有意义。
这意味着以下三个元素中的每一个都在相同的命名空间中并且携带完全相同的信息内容:
<Element xmlns="urn:example"/>
<a:Element xmlns:a="urn:example"/>
<b:Element xmlns:b="urn:example"/>
在您的特定文档中,存在一定程度的冗余,因为默认命名空间不需要重新- 在 annotationBody
元素中赋值。我们也真的 不需要 md
前缀。
这份文件载有完全相同的信息:
<?xml version="1.0" encoding="utf-8"?>
<madcow
xsi:schemaLocation="urn:Annotation D:\projects\DELOS\Annotation.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns ="urn:Annotation"
kind="withContent" media="text">
<metadata>
<author>ferro697702212</author>
<title> Eine weitere Annotation </title>
<creationDate>18/11/2009 10.26.09</creationDate>
<modificationDate>18/11/2015 10.26.09</modificationDate>
<sourceHttp>687474703a2f2f7777772e676f6f676c652e69742f</sourceHttp>
<type>example</type>
<public>true</public>
</metadata>
<annotationBody>
<contents id="1">
<textContent>Das ist ein Beispieltext für eine Annotation</textContent>
<attachments>
<attachedImage> file:://A/B/C</attachedImage>
</attachments>
</contents>
<contents id="2">
<md:textContent> Eine weitere Annotation </md:textContent>
<attachments>
<attachedAudio>http://www.h_da.de/xml/test.mp3</attachedAudio>
</attachments>
</contents>
<textSelection>
<path>BODY/CENTER/FORM/TABLE[2]/TBODY/TR[2]/TD/FONT/LABEL[3],23,6</path>
<contentRef>1</contentRef>
</textSelection>
</annotationBody>
</madcow>
How many different XML Namespaces are in this document?
None。
正如@Damien_The_Unbeliever 正确指出的那样,文档中出现了两个不同的名称空间 URI:urn:Annotation
和 http://www.w3.org/2001/XMLSchema-instance
。但是这些名称空间不是 "in" 文档,它们在文档之外。这就是命名空间的全部意义所在,它们不是文档的本地内容。
如果我没记错的话,文档包含 4 个命名空间声明,代表 3 个不同的命名空间绑定到 2 个不同的命名空间。