Altova Mailing List Archives
>xmlschema-dev Archive Home
>Thread Prev - Understanding anyAttribute namespace="##any" and anyAttribute namespace="##local"
>Thread Next - Re: Understanding anyAttribute namespace="##any" and anyAttribute namespace="##local"
Re: Understanding anyAttribute namespace="##any" and anyAttribute namespace="##local"
To: "W. Eliot Kimber" <ekimber@---------------.--->
Date: 11/2/2004 9:44:00 AM
"W. Eliot Kimber" <ekimber@i...> writes: > I'm trying to understand how anyAttribute works and I'm getting a > result that seems to be incorrect but I'm sure it's my lack of > understanding. > > What I have in my schema is this declaration: > > <xs:complexType name="metadata"> > <xs:choice maxOccurs="unbounded" minOccurs="0"> > <xs:element name="metadata" type="mtbitopic:metadata"/> > <xs:element name="metadataitem" type="mtbitopic:metadataitem"/> > <xs:any namespace="##other"/> > </xs:choice> > <xs:anyAttribute namespace="##local"/> > </xs:complexType> > > Note the "##local" for anyAttribute. The attributeFormDefault is set > to "unqualified". > > In my instance governed by this schema, I have this markup: > > <metadata foo="bar"/> > > However, when I validate the document, both oXygen and Stylus Studio > report that the attribute "foo" is not allowed for the element > metadata. > > What basic but subtle aspect of XSD am I missing here. You need <xs:anyAttribute namespace="##local" processContents="lax"/> The default for processContents is 'strict', which in turn means "any unprefixed attribute, provided I can find a top-level declaration for it". With that change, XSV is happy with your example. > Also, is there a way to say that you want to allow any qualified or > unqualified attributes? It doesn't appear to be the case but I have > such a hard time decoding the spec itself that I'm not sure what the > actual syntax of the namespace= attribute is, so I'm going off what > I've learned from the various tutorials I could find online. Yes, use namespace="##any". ht -- Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh Half-time member of W3C Team 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440 Fax: (44) 131 650-4587, e-mail: ht@i... URL: http://www.ltg.ed.ac.uk/~ht/ [mail really from me _always_ has this .sig -- mail without it is forged spam] From ekimber@i... Tue Nov 02 21:32:40 2004 Received: from bart.w3.org ([128.30