OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Flexible schema definition help

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: Flexible schema definition help
  • From: Eric Dalquist <edalquist@unicon.net>
  • Date: Mon, 13 Sep 2004 11:06:19 -0700
  • User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040707 Thunderbird/0.7.2 Mnenhy/0.6.0.104

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>




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS