I believe the three below are syntactically correct; but which are permitted according to conventions (especially in the enterprise)?
The first one below is used in most examples I've seen (e.g. JAXB), but it's verbose:
<xs:annotation>
<xs:appinfo>
<myinfo>don't panic</myinfo>
</xs:appinfo>
</xs:annotation>
This second one below is allowed because any attributes are permitted on <appinfo>
(that aren't in xml schema's own namespace). It's shorter, and seems reasonable - but is it conventional?
<xs:annotation>
<xs:appinfo myinfo="don't panic"/>
</xs:annotation>
This last one below is my favourite, because it's so short and doesn't clutter up the schema. I'm sure it's legal, because like <appinfo>
, any attributes are permitted on an <annotation>
(again, provided non-xml schema namespaced). But it encodes application info without using an <appinfo>
, so I'm afraid it would be frowned upon. Would it be?
<xs:annotation myinfo="don't panic"/>
Many thanks for your comments!
Interesting examples of a somewhat "standard" usage of <xs:appinfo>
are at http://docstore.mik.ua/orelly/xml/schema/ch14_02.htm and at http://docstore.mik.ua/orelly/xml/schema/ch15_01.htm#ch15-77057
Note that <xs:appinfo>
should contain information to be processed by an application, not human readable notes (use <xs:documentation>
for this).
I don't think that you are hearing anything because I don't think that these annotations are that commonly used, and the whole point of the spec is to allow anyone to put anything that helps them in there.
The only convention I've seen is XHTML documentation, which of course doesn't look like any of your options.
You might look into whether processing libraries like Apache XmlSchema treat all of your options equivalently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With