[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [Fwd: [Fwd: Re: [xml-dev] Flexible schema definition help]]
Of interest - I know this is something that we needed for the XSD of CAM itself. DW =================== 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 ----------------------------------------------------------------- The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative of OASIS <http://www.oasis-open.org> The list archives are at http://lists.xml.org/archives/xml-dev/ To subscribe or unsubscribe from this list use the subscription manager: <http://www.oasis-open.org/mlmanage/index.php>
--- Begin Message ---
- From: "David RR Webber (XML eBusiness)" <w3c@drrw.info>
- To: david@drrw.info
- Date: Tue, 14 Sep 2004 08:08:56 -0400
Of interest.--- Begin Message ------ End Message ---
- From: "Klotz, Leigh" <Leigh.Klotz@pahv.xerox.com>
- To: "'Eric Dalquist'" <edalquist@unicon.net>, "'xml-dev@lists.xml.org'" <xml-dev@lists.xml.org>
- Date: Mon, 13 Sep 2004 13:53:40 -0700
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 ----------------------------------------------------------------- The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative of OASIS <http://www.oasis-open.org> The list archives are at http://lists.xml.org/archives/xml-dev/ To subscribe or unsubscribe from this list use the subscription manager: <http://www.oasis-open.org/mlmanage/index.php>--- End Message ---
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]