[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Flexible schema definition help
I'd like to create an XML schema that will ensure a certain simple structure exists in the document but allows for any other elements or attributes. I've attached an invalid XSD which is close to what I want. If I remove the anyType complex type and it's references the XSD is then valid and will validate my XML document correctly but there is no allowance for any elements or attributes beyond what is defined in the XSD. I'd rather have the XSD define a set of required elements and their structure but allow for any other elements and attributes in the document. I hope that description make sence and any help is very much appreciated. Thank you, Eric Dalquist PS: The error Oxygen is giving me with the attached XSD is: E cos-nonambig: WC[##any] and "":folder (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles. layout.xsd 24:39 <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- | Top level layout element. Since this is the only stand alone element tag | it has to be the root of the document. +--> <xs:element name="layout" type="layoutType"/> <!-- | Defines the layout complex type. Requires exactly one folder sub element | of folderType to be present. +--> <xs:complexType name="layoutType"> <xs:choice> <xs:element minOccurs="1" maxOccurs="1" name="folder" type="folderType"/> <xs:element minOccurs="0" maxOccurs="unbounded" name="extension" type="anyType"/> </xs:choice> </xs:complexType> <!-- | Defines the folder complex type. Extends nodeType and allows folder and | portlet elements as child elements in any order and number. +--> <xs:complexType name="folderType"> <xs:complexContent> <xs:extension base="nodeType"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="folder" type="folderType"/> <xs:element name="portlet" type="portletType"/> </xs:choice> </xs:extension> </xs:complexContent> </xs:complexType> <!-- | Defines the portlet complex type. Extends nodeType and adds portlet | specific attribute requirements to the type. +--> <xs:complexType name="portletType"> <xs:complexContent> <xs:extension base="nodeType"> <xs:attribute name="windowID" type="xs:string" use="required"/> </xs:extension> </xs:complexContent> </xs:complexType> <!-- | Base type for folders and portlets. Defines attributes which are common | to both entities. +--> <xs:complexType name="nodeType"> <xs:complexContent> <xs:extension base="anyType"> <xs:attribute name="ID" type="xs:string" use="required"/> <xs:attribute name="hidden" type="xs:boolean" use="required"/> <xs:attribute name="unremovable" type="xs:boolean" use="required"/> <xs:attribute name="immutable" type="xs:boolean" use="required"/> <xs:attribute name="name" type="xs:string" use="required"/> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="anyType"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:any/> </xs:choice> <xs:anyAttribute/> </xs:complexType> </xs:schema>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|