Getting started on XSD
UPDATE: My excuses to VS.NET 2003, I just did not find some of the features of the schema editor and xml editor. Joshua Flanagan thanks for pointing this out!
Although I'm working with XML for years and years, have used DTD's and schema's and on a global level know quite well where to apply which technology I never really wrote my own XSD. Most of the time someone else in the project did this part.
OK, so I was constructing my first schema for a configuration file format for a tool I'm working on: the MacawSharePointSkinner (a tool to modify the looks of SharePoint without having to dig into the almost non-existent SharePoint way of changing the SharePoint looks).
I started out with VS.NET's schema designer. This sucks big time It is “sub-optimal“
Terriblesub-optimal documentation- no possibility to set attribute values like minOccurs and maxOccurs through the designer F4 -> properties
- no functionality to derive a schema from an existing XML file
- no functionality to generate a test XML document based on the defined schema
- no functionality to generate documentation for the schema
- no functionality to check my text XML document against the schema Automatically done when referencing the schema
Yesterday at TechEd Europe I walked into Altova XmlSpy in the exhibition hall, just a few hours after a stressful night with VS.NET. I explained what I needed, and they demonstrated their tool. I loved it! Today I fired up the full-functional demo copy and tried to get started.Still some trouble but I did get much further.. my schema is finished! Love the tool
What I missed in XmlSpy is good documentation on XSD itself, for example I could not get the following defined:
:
<foo a=“x“/>
<bar a=“x“>u</bar>
<bar a=“y“>v</bar>
<bar a=“z“>w</bar>
:
Where foo and bar can be used mixed.
- xs:sequence defines a fixed sequence
- xs:all does only allow minOccurs=0 maxOccurs=1, not maxOccurs=unbounded
It is just not possible to define this in schema (as far as I know), the tools says that something is wrong when trying those alternatives, but don't tell you why...
After searching for some good documentation for starters I came up with the following links to be read in sequence, although the first article was good enough for me to finish my schema:
- XSD Schema Tricks and Tips by Kurt Cagle - http://www.vbxml.com/xml/articles/xsd/default.asp
- XML Schema Part 0:Primer - http://www.w3.org/TR/xmlschema-0/