Advanced xsd for xml with multiple namespaces

Hey, I'm trying to open my XML schema for different namespaces, this seems to work, but all the elements of the default namespace are now invalid.

Thanks in advance. I try to achieve the same schema extension mechanism as in Spring (iE: spring - beans.2.5.xsd), they open the definition beanalso for ##other, and it works!

I added an example of these three files for easy access to the zip archive and uploaded it to rapidshare with one click.

What is 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>

order 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> 

Error

Invalid content was found starting with element 'bar'. One of '{foo, bar, baz, WC[##other:"http://www.example.org/schema/list"]}' is expected

+3
source share
2 answers

, . , xsd , .:)

elementFormDefault="qualified" <xs:schema> example-list.xsd, . , .

+3

, custom-example-list.xsd. "eek" .

xmlns:balvi="http://www.example.org/schema/custom" xmlns="http://www.example.org/schema/custom" .

: , , , . , , , , ##other, . . , .

, , . , , . , , .

0

Source: https://habr.com/ru/post/1732532/


All Articles