Well, I come to the end of this little series. In this entry, I will show you some of the XSL I wrote to format my Word document from the XML file. It's not too hard to follow, but I will focus only on the most interesting parts. I have trimmed out some things so that it is shorter by taking out some of the content and putting in a comment.

This stylesheet goes through the source XML and looks only for tasks where the Note element contains the word "Kunicki".

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
xmlns:w="
http://schemas.microsoft.com/office/word/2003/wordml"
xmlns:tns="OutlookTaskExporter">
    <xsl:template match="/">
        <xsl:processing-instruction name="mso-application">progid="Word.Document"</xsl:processing-instruction>
        <w:wordDocument>
            <xsl:apply-templates/>
        </w:wordDocument>
    </xsl:template>
    <xsl:template match="tns:Tasks">
   <w:styles>
  <xsl:comment>Word style stuff goes here</xsl:comment>
 </w:styles>
 <w:docPr> 
  <xsl:comment>I trimmed out the document-wide behaviors here</xsl:comment>
 </w:docPr>
 <w:body>
  <wx:sect>
   <wx:sub-section>
    <wx:sub-section>
     <xsl:apply-templates select="tns:SummaryInfo"/>
             <xsl:apply-templates select="tns:Task[contains(tns:Notes,'Kunicki')]"/>     
    </wx:sub-section>
   </wx:sub-section>
      </wx:sect>
    </w:body>
    </xsl:template>
    <xsl:template match="tns:SummaryInfo">
  <xsl:comment>I trimmed out some WordML output here</xsl:comment>
    </xsl:template>
    <xsl:template match="tns:Task">
    <wx:sub-section>
        <w:p>
      <w:pPr>
   <w:pStyle w:val="Heading3"/>
   <w:rPr>
    <w:b w:val="off"/>
   </w:rPr>
  </w:pPr>
            <w:r>
                <w:t>
                    <xsl:value-of select="@Subject"/>
                </w:t>
            </w:r>
    <w:r>
   <w:rPr>
    <w:b w:val="off"/>
    <w:color w:val="3366FF"/>
   </w:rPr>
   <w:t> (Percent Complete= <xsl:value-of select="@PercentComplete"/>)</w:t>
  </w:r>      
        </w:p>       
        <xsl:apply-templates select="tns:Notes"/>       
      </wx:sub-section>
    </xsl:template>
    <xsl:template match="tns:Notes">
 <w:tbl> 
  <xsl:comment>Table WordML output goes here</xsl:comment>
 </w:tbl>
    </xsl:template>
</xsl:stylesheet>

the main thing to keep in mind is that Word 2003 is (fortunately) not terribly forgiving about ill-formed XML. If you have errors in your output, Word won't be happy. If you are wondering how to get going with WordML, check out the Office Developer Center (http://msdn.microsoft.com/office) and check out the section on XML. Also, Oleg's blog is really, really good (http://www.tkachenko.com/blog/).

Rock thought for the day: In lists of the best guitarists of all-time, Billy Corgan is regularly overlooked. He is amazing. If you are unconvinced, check out "Why Am I So Tired" on the EarPhoria album. It is a 15 minute solo essentially, not all fireworks, just great guitar layering.

Rock on!