Jump to content

Comlextype with attribute and elements.


Scrier
 Share

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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...