Hey, im trying to open my XML schema for different namespaces, this seems to work but all the default namespace elements now are invalid.
Thank you in advance. I’m trying to achieve the same schema extension mechanism as done in Spring (i.E.: spring-beans.2.5.xsd) they open the bean definition also for ##other and this works!
I added an example of these three files for easy access to a zip archive and uploaded it to the one-click-hoster rapidshare.
Whats my fault?
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>
The error
Invalid content was found starting with element 'bar'. One of '{foo, bar, baz, WC[##other:"http://www.example.org/schema/list"]}' is expected
Wow, that was a hard one. It’s been a long time since I had to just keep making random-ish changes to xsd and validate to see what happens. 🙂
Add
elementFormDefault="qualified"as an attribute to your<xs:schema>tag inexample-list.xsdand it all validates. I’m still a bit confused as to why that is needed.