【发布时间】:2016-05-12 12:59:59
【问题描述】:
好的,我有这个文件:
<?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">
这告诉我们在这里我们覆盖了这个特定元素的默认命名空间。顺便说一句,这是最让我困惑的地方,因为既然它是默认命名空间,为什么我们需要在这里声明命名空间?
是啊……
我是否正确理解/阅读了代码,如果没有,请告诉我为什么以及本文档中有多少不同的命名空间?
提前感谢大家。
【问题讨论】:
-
不清楚为什么
<annotationBody xmlns="urn:Annotation">有多余的默认命名空间声明,但是是的,你正确理解了这个 XML 命名空间 AFAICS
标签: xml xsd namespaces xml-namespaces