我对xml命名空间的问题很少,我将用这三段代码解释:
1 - 非常简单的XML架构:
<?xml version="1.0" encoding="US-ASCII"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.library.com"
targetNamespace="http://www.library.com"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<element name="Book" type="tns:BookType" />
<complexType name="BookType">
<sequence>
<element name="Title" type="string" />
<element name="Author" type="string" />
</sequence>
</complexType>
</schema>
2 - 使用新创建的xml架构的XML:
<?xml version="1.0" encoding="US-ASCII"?>
<Book xmlns:xsi="http://www.wc3.org/2001XMLSchema-instance"
xsi:schemaLocation="http://www.library.com ex9.xsd"
xmlns="http://www.library.com">
<Title>Scherlock Holmes</Title>
Author>Arthur Conan Doyle</Author>
</Book>
3 - 与上述两个没有关系的另一个片段代码:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
....
</beans>
<attribute>
,<complexType>
,<sequence>
等元素?答案 0 :(得分:2)
schemaLocation
是必要的,因为它们的定义是隐含的
XML Schema Recommendation。xs:attribute
等等。http://www.w3.org/2001/XMLSchema-instance
是一个
内置命名空间,由定义为的组件组成
已经暗示了XML Schema Recommendation。