Category Archives: Technology

XML Schemas and ANY

I was tasked with creating an XML schema with extensibility, both from the application perspective and from the “we don’t have the requirements finished yet” perspective.

My solution was a simple key-value pair approach within a generic array. It could work:
<xs:element name="person">
 <xs:complexType>
  <xs:sequence>
   <xs:element name="attrKey" type="xs:string"/>
   <xs:element name="attrVal" type="xs:string"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

But then someone mentioned the use of the “any” element. I had never heard of it.

Turn out you can make a smarter extensible document by using the any element (from http://www.w3schools.com/schema/schema_complex_any.asp):

<xs:element name="person">
 <xs:complexType>
  <xs:sequence>
   <xs:element name="firstname" type="xs:string"/>
   <xs:element name="lastname" type="xs:string"/>
   <xs:any minOccurs="0"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

Boy that’s smart stuff. I like it! Now, to just see if we can implement it in time! 🙂

Advertisements

Not Another Technology Blog

Well, sorry to disappoint. Actually, this blog – I’m hoping – will be a place for ideas and pieces of information that I have rattling around in my head to go and rest.

The more I look at technology related things, the more I realize that I like technology. I never considered myself a geek, but then I find myself “geeking out” about something cool.

And if that’s not the definition of “geek”, maybe I don’t know what is. 🙂

So hold on – this could be good, helpful, great, useful. Or it could not really be much good at all. We shall see!