Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conventions for annotating appinfo in xml-schema?

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!

like image 296
13ren Avatar asked Nov 10 '09 06:11

13ren


2 Answers

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).

like image 65
Pino Avatar answered Sep 18 '22 16:09

Pino


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.

like image 36
bmargulies Avatar answered Sep 21 '22 16:09

bmargulies