Overview of WordprocessingML [Word 2003 XML Reference] -- Microsoft Office Word 2003 XML Software Development Kit
Overview of WordprocessingML [Word 2003 XML Reference]
Top-Level Elements, Namespace, Basic Document Structure
The top-level elements in a WordprocessingML document are:
- SmartTagType element describes a Smart Tag type used in the document.
- DocumentProperties element contains Office Document Properties.
- CustomDocumentProperties element contains Custom Office Document Properties.
- schemaLibrary element defines a collection of schemas that comprise a document's schema library.
- fonts element (wordDocumentElt complexType) contains font information
- frameset element (wordDocumentElt complexType) contains HTML Frameset definitions.
- styles element (wordDocumentElt complexType) contains style definitions.
- divs element contains HTML DIV information.
- shapeDefaults element contains drawing defaults.
- docOleData element contains supplemental data containing storages for OLE objects.
- docSuppData element contains supplemental data containing toolbar customizations, envelope data, and the Microsoft Visual Basic project.
- docPr element contains document options.
- shapeDefaults element contains the wrapper representing the shape defaults.
- bgPict element contains background picture information.
- body element contains the document body.
However, the simplest WordprocessingML document consists of just five elements (and a single namespace). The five elements are:
- wordDocument element: The root element for a WordprocessingML document.
- body element: The container for the displayable text.
- p element: A paragraph.
- r element: A contiguous set of WordprocessingML components with a consistent set of properties.
- t element: A piece of text.
The namespace for the root WordprocessingML Schema (also known as the XML Document 2003 Schema) is "http://schemas.microsoft.com/office/word/2003/wordml". This namespace is normally associated with the WordprocessingML elements by using a prefix of "w." The simplest possible WordprocessingML document looks as follows:
<?xml version="1.0"?>
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
<w:body>
<w:p>
<w:r>
<w:t>Hello, World.</w:t>
</w:r>
</w:p>
</w:body>
</w:wordDocument>
The following figure shows the resulting document, displayed in Microsoft Office Word 2003.
Tying the Document to Microsoft Office Word 2003
If you save a Microsoft© Office Word 2003 document with the .xml extension, Windows treats the file like any other XML file. When the user double-clicks the file, for example, opens it in the standard XML processor (such as Microsoft Internet Explorer). However, adding the mso-application processing instruction specifies Word as the preferred application for processing the file. As a result, Word opens the XML document when the user double-clicks the document's icon. The following example shows the sample document with the mso-application element added:
<?xml version="1.0"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">
<w:body>
<w:p>
<w:r>
<w:t>Hello, World.</w:t>
</w:r>
</w:p>
</w:body>
</w:wordDocument>
This topic is intended to serve as a brief introduction to WordprocessingML. For a complete overview, see "Overview of WordprocessingML" included in the Office 2003 XML Reference Schemas.
©2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp