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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Flexible schema definition help

[ Lists Home | Date Index | Thread Index ]

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@unicon.net] 
Sent: Monday, September 13, 2004 11:06 AM
To: xml-dev@lists.xml.org
Subject: [xml-dev] 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




 

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

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