With WordML these are some elements that make up a table:
<tbl>
<tbl> represents a table. This is similar to HTML <TABLE>. A WordML <table> element exists, too. However, the <table> element is used for a Office Data Source Object.
<tblPr>
With the element <tblPr> table-wide properties such as the style and the width are defined.
<tblGrid>
The element <tblGrid> defines the grid layout of the table. In the example two columns with similar width are defined.
<tr>
<tr> is the row of a table
<tc>
<tc> is a column inside the row
This helps creating Word documents with WordML:
Create a document with Microsoft Word and save it as XML file. Check the XML source.
Using Visual Studio 2005, add the Word schemas to the XML file for Intellisense-support.
Check the documentation of the Office schemas.
The Office schemas (including documentation) can be found on the MSDN Website.
The XML Editor of Visual Studio 2005 shows the elements that are allowed according to the XML Schema. The editor not only shows the elements and attributes that are possible where the cursor is positioned, it also shows some documentation about the elements and attributes. The documentation can be written inside the schema with the <xsd:annotation> and <xsd:documentation> tags:
<xs:element name="Book" minOccurs="0" maxOccurs="unbounded"> <xs:annotation> <xs:documentation>Represents information about a book.</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="Title" type="xs:string"> <xs:annotation> <xs:documentation>Represents the title of a book.</xs:documentation> </xs:annotation> </xs:element> <!-- ... -->
Adding the processing instruction mso-application to the document allows the system to deal with the XML file as a Word document. The parser reads the progid for Word to display the Word icon, and to start Word when opening the file.
The elements <w:wordDocument> and <w:body> can be compared to the HTML tags <HTML> and <BODY>. <w:t> is the tag for a text output.
The schemas for Microsoft Office 2003 can be downloaded from the MSDN Website. The download is an installation package that includes schemas for Office 2003 as well as documentation. Referencing the schemas with the XML and XSLT editors of Visual Studio 2005 gives intellisense :-)
I've received a question how to convert multiple XML elements to a values for a single attribute. Here is the information about how this can be done with XSLT.
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- Demo Style sheet to convert multiple elements to a single attribute value --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <HTML> <HEAD> <xsl:element name="META"> <xsl:attribute name="name">keywords</xsl:attribute> <xsl:attribute name="content"> <xsl:for-each select="Article/Head/Keyword"> <xsl:value-of select="."/> <xsl:if test="position() != last()">, </xsl:if> </xsl:for-each> </xsl:attribute> </xsl:element> <TITLE> </TITLE> </HEAD> <BODY></BODY> </HTML> </xsl:template> </xsl:stylesheet>
<xsl:element> and <xsl:attribute> allows dynamic creation of elements and attributes. <xsl:element name="META"> defines the element <META>. <xsl:attribute name="name">keywords</xsl:attribute> results in <META name="keywords">. The content of the attribute content is created dynamically with a selection of each <Article><Head><Keyword> element, and in between of these values a semicolon is added. <xsl:if test=position() != last()"> checks if the <Keyword> element was not the last one, as with the last one no more semicolon is used.
I really like the XSLT editor and debugger of Visual Studio 2005. This makes it easy to create XSLT files.
Update:Bryan has another option to create the Meta tags: