Reputation: 315
I'm new to XSD and can't figure out why my XSD isn't validating. I'm getting the following errors:
s4s-elt-invalid-content.1: The content of 'parametersInfo' is invalid. Element 'complexType' is invalid, misplaced, or occurs too often.
cvc-complex-type.2.4.d: Invalid content was found starting with element 'exception'. No child element is expected at this point.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<service id="IServiceREST">
<inherit>
<parent>Remote</parent>
</inherit>
<package>com.module</package>
<include>java.rmi.Remote</include>
<include>java.net.*</include>
<include>java.io.*</include>
<abstract_method id="getContent">
<visibility>public</visibility>
<parameters>
<argument type="URL">url</argument>
<argument type="int">timeout</argument>
</parameters>
<throw>
<exception>MalformedURLException</exception>
<exception>IOException</exception>
</throw>
<return>String</return>
</abstract_method>
<abstract_method id="deleteUser">
<visibility>public</visibility>
<parameters>
<argument type="String">username</argument>
</parameters>
<return>void</return>
</abstract_method>
</service>
XSD:
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="serviceInfo">
<xs:sequence>
<xs:element name="inherit" type="inheritInfo" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="package" type="xs:string" />
<xs:element name="include" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="abstract_method" type="abstract_methodInfo" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute type="xs:string" name="id" />
</xs:complexType>
<xs:complexType name="inheritInfo">
<xs:sequence>
<xs:element type="xs:string" name="parent" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="abstract_methodInfo">
<xs:sequence>
<xs:element type="xs:string" name="visibility" minOccurs="0" maxOccurs="1"/>
<xs:element type="parametersInfo" name="parameters" />
<xs:element type="throwInfo" name="throw" minOccurs="0" maxOccurs="unbounded"/>
<xs:element type="xs:string" name="return" minOccurs="1" />
</xs:sequence>
<xs:attribute type="xs:string" name="id" />
</xs:complexType>
<xs:complexType name="throwInfo">
<xs:sequence>
<xs:element type="xs:string" name ="exception" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="parametersInfo">
<xs:complexType type="xs:string" name="argument">
<xs:sequence>
<xs:element name="URL" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="timeout" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:complexType>
<xs:element name="service" type="serviceInfo"/>
</xs:schema>
Am I missing something? I wanted to make it easier by using complex types and referencing them to break it down...
Upvotes: 0
Views: 249
Reputation: 25054
Your declaration of type parametersInfo
reads
<xs:complexType name="parametersInfo">
<xs:complexType type="xs:string" name="argument">
<xs:sequence>
<xs:element name="URL" type="xs:string"
minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="timeout" type="xs:integer"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:complexType>
The XSD complexType
element cannot appear as a child of complexType
. I don't know what you were trying to do, but this is not the way to do it.
You may need to work through a tutorial or two on XSD.
Upvotes: 0