[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Flexible schema definition help

  • To: xml-dev@l...
  • Subject: Flexible schema definition help
  • From: Eric Dalquist <edalquist@u...>
  • 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

layout.xsd
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.