假设我有以下
XML模式文件和以下
XML文档文件.我有两个问题,
>由于XML Schema文件中没有指定目标名称空间,因此Information元素中的命名空间是什么?
>在XML文档文件中,使用“信息”时,它属于哪个命名空间?请注意,在这种情况下,我没有从XML文档文件中引用XML Schema文件.
XML Schema文件:
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="Information" type="xs:string"/> </xs:schema>
XML文档文件:
<?xml version="1.0" encoding="utf-8"?> <Information>Hello XML</Information>
提前致谢,
乔治
解决方法
Information元素将不在命名空间中.要将它放在默认命名空间中,您必须在标记中指定该命名空间.
<Information xmlns="http://www.mydefaultnamespace.com">
No Namespace
No namespace exists when there is no default namespace in scope. A {default namespace} is one that is declared explicitly using xmlns. When a {default namespace} has not been >declared at all using xmlns,it is incorrect to say that the elements are in {default >namespace}. In such cases,we say that the elements are in {no namespace}. {no namespace} >also applies when an already declared {default namespace} is undeclared.
这是一个非常全面的命名空间资源: