Reputation: 1313
I have an XML schema fragment that goes like this:
<xsd:complexType name="CustomStreamHandlerConfig">
<xsd:complexContent>
<xsd:extension base="AbstractStreamHandlerConfig">
<xsd:choice>
<xsd:sequence>
<xsd:element name="class" type="xsd:string" />
<xsd:group ref="CustomParameters" />
<xsd:group ref="NextElements" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:element name="config-file" type="xsd:anyURI" />
</xsd:choice>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Basically, this schema allows an XML fragment to describe a CustomStreamHandlerConfig
with some parameters (class, custom parameters, etc.) or with a configuration file URI.
The CustomParameters
group allows a list of single-params
elements in any number and a list of multiple-params
in any number:
<xsd:group name="CustomParameters">
<xsd:sequence>
<xsd:element name="single-params" type="KeyValue" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="multiple-params" type="KeyMultipleValues" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:group>
The KeyValue
and KeyMultipleValues
complex types go like this:
<xsd:complexType name="KeyValue">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="key" type="xsd:string" use="required" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="KeyMultipleValues">
<xsd:sequence>
<xsd:element name="value" minOccurs="2" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="key" type="xsd:string" use="required" />
</xsd:complexType>
When I try to assemble an XML fragment that represents a CustomStreamHandlerConfig
:
<custom-stream-retriever>
<class>MyCustomStreamHandler</class>
<single-params key="single-key">single-value</single-params>
<mutiple-params key="multiple-key"> <!-- Invalid content -->
<value>multiple-value</value>
<value>multiple-value</value>
</mutiple-params>
</custom-stream-retriever>
I get an cvc-complex-type.2.4.a: Invalid content was found starting with element 'mutiple-params'.
error.
The thing is, when I inspect the list of expected elements, I find: One of '{..., "SomeNamespace":multiple-params, ...}' is expected.
I compared SomeNamespace
(example namespace name) to the targetNamespace
in my schema file, and they are both the same. I must also precise that the xsd:schema
tag has elementFormDefault="qualified"
.
Why is the XML file refusing mutiple-params
elements?
Upvotes: 0
Views: 1869
Reputation: 21658
Not sure if this is a trick question, or a typo... your XSD describes a multiple-params
, while your XML employs a mutiple-params
- there's an l (lower case L) missing in the latter.
Upvotes: 2