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

RE: Flexible schema definition help


definition help
Eric,
In your anyType definition, you allow for any attribute and any element.
Then, in your other definitions, you extend anyType to allow other
attributes and other elements.

That's not going to work, because the base anyType already allows whatever
attributes and elements you were going to add anyway.
So, you won't be getting any validation.

For a working example of allowing any foreign attributes, see the XForms 1.0
Schema in http://www.w3.org/TR/xforms -- I think Micah Dubinko was
responsible for the construction of the attributeGroup that does this.  A
key point is to do  <xsd:anyAttribute namespace="##other"/>  -- that will
restrict the attributes in your namespace to the listed set, but allow any
other attributes from other namespaces.  Of course, in your extensions you
won't be able to then specify which foreign attributes to allow as you've
allowed them all, but at least you get validation of your namespace's
attributes.  You might find using attributeGroups easier than using type
extension; if your types really aren't related, but just all happen to allow
foreign attributes, it's much clearer what's going on.

There's a similar thing to do with xsd:any for elements, where you will need
to specify namespace="##other".  But watch out -- ordering matters here.
Attributes, fortunately, are unordered, but with sequences of child
elements, you will run into the XML Schema deficiencies in the area of
unordered choices / ordered sequences -- some things you might want to
express aren'f possible in XML Schema without resorting to a combinatorial
listing, and that's really painful.  Read up on sequence, choice, and
minOccurs and maxOccurs.  See the XForms Schema for some examples, or look
at Zvon.org for a discussion of some of those issues.

-----Original Message-----
From: Eric Dalquist [mailto:edalquist@u...] 
Sent: Monday, September 13, 2004 11:06 AM
To: xml-dev@l...
Subject:  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

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.