# Friday, 17 October 2003

I’m sure everyone knew about this but me, but I was impressed.  I needed to attach some extra data to an XML Schema document so that it would be available to a code generator I’m writing.  You can put whatever extra attributes you want in an XSD document (which is how MS does it with SQLXML, for example) and no one will be bothered. 

However, I needed some full on elements to express the extra data I needed to carry. Luckily for me, the clever people at the W3C thought of this, and gave us the annotation element.  I knew you could put documentation inside an annotation element, but I’d never noticed the appInfo element before. 

Inside an appInfo, you can put whatever you want to, and attach it to just about any place in your schema file.  Very cool. 

 

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:my="myNamespace" elementFormDefault="qualified" attributeFormDefault="unqualified">

     <xs:element name="root element">

          <xs:annotation>

               <xs:documentation>some documentation</xs:documentation>

               <xs:appinfo>

                    <my:whatever>some app specific data</my:whatever>

               </xs:appinfo>

          </xs:annotation>

     </xs:element>

</xs:schema>

 

On a completely different note, I’m amazed to see that WordML actually serializes the little red “you misspelled something again” bar into the XML.  Just in case you want to style it into a mistake somewhere else?

Work | XML