Jump to content

Comlextype with attribute and elements.


Recommended Posts

I have the following XML file that I have issues with validating a specific part of.

<params>  <param @type="int">intType</param>  <param @type="char" length="5">tagString</param></params>

I try the following schema to identify it but have issues with mixing attribute and restrictions.

	<!--	Complextype matching the "param".	-->	<xs:complexType name="paramtype">		<xs:restriction base="xs:string">			<xs:pattern value="[a-z]+([A-Z][a-z]*)*" />		</xs:restriction>				<xs:attribute name="type" type="xs:string" use="required" />		<xs:attribute name="arraySize" type="xs:string" />		<xs:attribute name="length" type="xs:string" />	</xs:complexType>		<!--	Complextype matching the "params".	-->	<xs:complexType name="paramstype">		<xs:sequence>			<xs:element name="param" maxOccurs="unbounded" type="paramtype"/>		</xs:sequence>	</xs:complexType>

It complains on the following part:

msggen.xsd:89: element restriction: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}complexType': The content is not valid. Expected is (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))).WXS schema msggen.xsd failed to compile
I have tried some combinations before and after the restriction part but still don't get it to work. I have tried the examples but all the examples on wc3 as well as the book I have is either element or attribute, not combined.
Link to post
Share on other sites

I managed to make it validate with the following complextype:

	<xs:complexType name="paramtype" mixed="true">		<xs:attribute name="type" type="xs:string" use="required" />		<xs:attribute name="arraySize" type="xs:string" />		<xs:attribute name="length" type="xs:string" />	</xs:complexType>

Problem here is that I cannot validate the element now.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...