嘿,我试图为不同的名称空间打开XML模式,这似乎可行,但是所有默认名称空间元素现在都无效.
先感谢您.我正在尝试实现与Spring相同的架构扩展机制(即:spring-beans.2.5.xsd),它们也为## other打开了bean定义,这可行!
我添加了一个example of these three files,可以轻松访问zip存档,并将其上传到一键式托管Rapidshare.
我怎么了
example-list.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.example.org/schema/list"
xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/schema/list">
<xs:import namespace="http://www.w3.org/XML/1998/namespace" />
<xs:complexType name="ExampleListModelType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="ExampleListGroup" />
</xs:choice>
</xs:complexType>
<xs:group name="ExampleListGroup">
<xs:choice>
<xs:element name="foo" type="xs:string" />
<xs:element name="bar" type="xs:string" />
<xs:element name="baz" type="xs:string" />
<xs:any namespace="##other" processContents="strict" />
</xs:choice>
</xs:group>
<xs:element name="action-list" type="ExampleListModelType" />
</xs:schema>
custom-example-list.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.org/schema/custom" elementFormDefault="qualified"
targetNamespace="http://www.example.org/schema/custom">
<xs:element name="eek" type="xs:string" />
</xs:schema>
example-list.xml
<?xml version="1.0" encoding="UTF-8"?>
<action-list xmlns="http://www.example.org/schema/list"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:custom="http://www.example.org/schema/custom"
xsi:schemaLocation="
http://www.example.org/schema/list example-list.xsd
http://www.example.org/schema/custom custom-example-list.xsd">
<custom:eek></custom:eek>
<bar></bar>
</action-list>
错误
发现无效的内容以元素“ bar”开头.预期为“ {foo,bar,baz,WC [## other:“ http://www.example.org/schema/list”]}“之一
解决方法:
哇,真是辛苦.自从我不得不继续对xsd进行随机更改并验证看看会发生什么以来已经很长时间了.