- From: C. M. Sperberg-McQueen <cmsmcq@acm.org>
- Date: Wed, 14 Jan 2009 11:14:41 -0700
- To: Jeff Young <jey@adobe.com>
- Cc: "C. M. Sperberg-McQueen" <cmsmcq@acm.org>, "www-xml-schema-comments@w3.org" <www-xml-schema-comments@w3.org>
On 13 Jan 2009, at 07:01 , Jeff Young wrote: > I have an application-specific attribute that I need to store on a > schema component. The XMLSchema spec states that non-schema > namespaced attributes are allowed on the <appinfo> tag, but several > books on the subject suggest that this isn’t the case. > > So, for the case where I want to store foo:myAttr on a schema > component, should I use: > > <xs:annotation> > <xs:appinfo xmlns:foo=”http://whatever” foo:myAttr=”someValue”/> > </xs:annotation> > > or the more verbose: > > <xs:annotation> > <xs:appinfo> > <foo:myHolder xmlns:foo=”http://whatever” > myAttr=”someValue”/> > </xs:appinfo> > </xs:annotation> > > I prefer the former (which doesn’t require the somewhat artificial > construction of a holder element), but I’d rather do the latter if > it represents the intended (or universally practiced) usage. Tests with xmllint, MSV, Saxon, Xerces C, and Xerces J seem to suggest that none of them have any problem with the first form (or even with <xs:annotation xmlns:foo="http://whatever" foo:myAttr="someValue"). Which is what I would have expected. For that matter, it's not required to put the foreign attribute in an annotation element; you can write <xs:element xmlns:foo="..." foo:myAttr="someValue"> ... </xs:element> without damaging the conformance of your schema document. What books said what things that suggest foreign attributes are not legal, or not accepted, or not good practice? It may be true that some implementations provide imperfect access to such annotations in the form of foreign attributes; if your code will depend on knowing the value of foo:myAttr for the governing type definition or the governing element declaration, you may want to check to ensure that you can get at that information through the interfaces provided by the processors you are using or might use in future. I hope this helps. -- C. M. Sperberg-McQueen, W3C XML Activity http://www.w3.org/People/cmsmcq http://cmsmcq.com/mib/ http://www.balisage.net/
Received on Wednesday, 14 January 2009 18:14:49 UTC