XSD, breakroom phosphate

|

I woke up this morning just before 5. I thought 'Great! Now I can get started on some work!' Five hours later, I woke up (again) with nary an atom of work (I'm too tired, but insert your own chemistry joke here - to get you started, imagine what the properties of 'work tri-oxide' or 'employee-lounge monosulfate' might be) got done.

However, I was considering looking at Lisp today, so it's a good thing this entry got my parenthesis-typing fingers warmed up.

Yesterday I learned my way around generating XSD documents which, I must say, is a complete waste of time. If you're doing anything more than returning a simple document that hardly ever changes it's okay, but like hell I'm re-writing the damn thing every time there's a new product offering. Regardless, it's something new to learn, and that is after all why I'm on this earth. That and periodically making smart remarks.

XSD is an interesting concept - it's certainly easier to deal with than DTD, and if I have to write one of these for every service I generate, here's hoping that DTDs die a quick death. For the uninitiated, 'XSD' stands for 'eXtensible Schema Definition', and is essentially a way to indicate to the outside world what some XML document will look like. A simple example might help muddy the waters:

An XML doc that looks like this:

<cow>
   <stomach>
     grass
   </stomach>
</cow>

could be defined in an XSD like this:

<schema>
  <xs:element name="cow">
     <xs:complexType>
       <xs:sequence>
         <xs:element name="stomach" type="xs:string"/>
       </xs:sequence>
     </xs:complexType>
  </xs:element>
</schema>

Note to perfectionists - yes, the XML declaration line, namespace, etc is missing.

As you can see, the XSD is concerned with what tags go where and what is valid data for those tags to contain. Since the <stomach> tag says that it contains a string, a document with a number instead of a string will cause validation to fail. This is a very simple example - XSD allows you to do spectacularly stupidly complex things. Since I've only had one Amp so far today, I'm not going into it any further. The point is, there seem to be plenty of things that can generate a sample XML file given an XSD, but all the things that will generate an XSD given an XML doc seem to cost money. I'm not in favor of this, and my try my hand at writing one one of these days.

About this Entry

This page contains a single entry by Philip Ratzsch published on March 22, 2008 9:41 AM.

Five Years. was the previous entry in this blog.

Ruby session error and leaving for Utah is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.