Scrier Posted June 30, 2011 Share Posted June 30, 2011 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 compileI 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 More sharing options...
Scrier Posted June 30, 2011 Author Share Posted June 30, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.