0

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I'd say you are correct. The error says as much "found ... 'mutiple-params' ... expected multiple-params".
Yeah, that was it... My ctrl+space auto-complete in Eclipse must have been using a previous version of the XSD file because of a refresh issue.
Can't believe I didn't see the spelling difference though... Thanks a lot guys!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.