Outlook, .NET, and WordML- the FOURTH of a short series.

All right, it's time I quit answering email and get back to my blog (for those of you waiting for something from me- you now know why it has to wait!). In this entry, I will describe the XSD I use for this little sample, and then I will get into the manifest file itself (tomorrow is actually looking good for getting another entry out the door). In the last entry of the series (let's see how Tuesday goes first!) I want to walk through some of the XSL instructions in one of my style sheets.

OK- so, my little C# app extracts my tasks into an XML file. But, what if I wanted another system to produce a similar XML file? What if I wanted to reuse the rest of my solution for something other than my Outlook tasks? This is not hard to do, but the need for a schema becomes more apparent at this point. By having my XML file conform to a schema, I build some predictability and constraints into my solution. It helps things run smoother, and it makes them easier to understand. It makes it easier to glue it all together.
Here is my XSD:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:tns="OutlookTaskExporter"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="OutlookTaskExporter"
xmlns:xs="https://www.w3.org/2001/XMLSchema">
<xs:element name="Tasks">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="SummaryInfo" type="xs:string" />
<xs:element maxOccurs="unbounded" name="Task">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="category" type="xs:string" />
<xs:element name="Notes" type="xs:string" />
</xs:sequence>
<xs:attribute name="Subject" type="xs:string" use="required" />
<xs:attribute name="Due" type="xs:string" use="required" />
<xs:attribute name="PercentComplete" type="xs:unsignedByte" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Notice once again that I have used the same target namespace in this schema file. This is key, because I use it in my manifest file. Most of the things in my XSD here are pretty  straight-forward. I constrain what kinds of data can fit in the various elements of the XML file.

Rock thought for the day: I spent some time this weekend playing my guitar. I love my Washburn. Not as many newer guitarist go for Washburn it seems. I love the strat like anyone else, but this Washburn has warm pickups, and I get a nice range of voices from it. Also, I have small hands, so the thin neck makes the fingering much easier. Any other Washburn fans out there?

Rock on!