xsd - XML Schema For A Simple XML Goods-List -
I am trying to write schema which will validate the following XML:
Lt; Category type = "rifles" & gt; & Lt; Items & gt; & Lt; Name & gt; AK47 & lt; / Name & gt; & Lt; Description & gt; The main export of USSR is back in the day, and guerrilla's best friend is more than any other symbol on African flags. & Lt; / Description & gt; & Lt; Cost & gt; 4000 & lt; / Cost & gt; & Lt; Image & gt; Ak47.jpg & lt; / Image & gt; & Lt; Origin & gt; USSR & Lt; / Origins & gt; & Lt; Quantity & gt; 10000 & lt; / Quantity & gt; & Lt; / Item & gt; (Other item elements, tags with title titles and closing tags are omitted.)
and developed the following schemas:
& lt; Element name = "store" & gt; & Lt; ComplexType & gt; & Lt; Sequence & gt; & Lt; Element name = "category" maxOccurs = "unbounded" & gt; & Lt; ComplexType & gt; & Lt; SimpleContent & gt; & Lt; Extension base = "string" & gt; & Lt; Attribute name = "type" type = "string" /> & Lt; / Extension & gt; & Lt; / SimpleContent & gt; & Lt; Sequence & gt; & Lt; Element name = "item" maxOccurs = "unbounded" & gt; & Lt; ComplexType & gt; & Lt; Sequence & gt; & Lt; Element name = "name" type = "string" /> & Lt; Element name = "description" type = "string" / & gt; & Lt; Element name = "image" type = "string" /> & Lt; Element name = "cost" type = "number" /> & Lt; Element name = "provenence" type = "string" / & gt; & Lt; Element name = "quantity" type = "number" /> & Lt; / Sequence & gt; & Lt; / ComplexType & gt; & Lt; / Element & gt; & Lt; / Sequence & gt; & Lt; / ComplexType & gt; & Lt; / Element & gt; & Lt; / Sequence & gt; & Lt; / ComplexType & gt; & Lt; / Element & gt; Using the verifier on this, I get:
Schema Error: System.Xml.Schema.XmlSchemaException: A complex type of content model consisting of 'annotation' Should be (if present); After zero or one of the following: 'simple content', 'complex content', 'group', 'likes', 'sequence', or 'all'; After zero or more 'attribute' or 'attribute group'; After zero or one 'any specialty'
I know it may seem silly, but can someone tell me your error?
Try
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt ;! - Created with Liquid XML Studio - Developer Pro version 7.1.0.1135 (http://www.liquid-technologies.com) - & gt; & Lt; Xs: schema attribute default = "ineligible" elementFormat = "qualified" xmlns: xs = "http://www.w3.org/2001/XMLSchema" & gt; & Lt; Xs: element name = "range" & gt; & Lt; XS: complexType & gt; & Lt; XS: Sequence & gt; & Lt; Xs: element minOccurs = "0" maxOccurs = "unbounded" name = "item" & gt; & Lt; XS: complexType & gt; & Lt; XS: Sequence & gt; & Lt; Xs: element name = "name" type = "x: string" /> & Lt; Xs: element name = "description" type = "x: string" /> & Lt; Xs: element name = "cost" type = "xs: unsigned close" /> & Lt; Xs: element name = "image" type = "x: string" /> & Lt; Xs: element name = "genesis" type = "x: string" /> & Lt; Xs: element name = "volume" type = "xs: unsigned close" /> & Lt; / XS: sequence & gt; & Lt; / XS: complexType & gt; & Lt; / XS: element & gt; & Lt; / XS: sequence & gt; & Lt; Xs: attribute name = "type" type = "x: string" = "required" /> & Lt; / XS: complexType & gt; & Lt; / XS: element & gt; & Lt; / XS: Schema & gt;
Comments
Post a Comment