OOXML Specification - WordprocessingML
website·Indexed 31 days ago
https://appraisys-docs.github.ioTechnical documentation for the Office Open XML (OOXML) specification, focusing on WordprocessingML. It provides detailed references for XML elements and attributes related to document structure, text formatting, tables, fonts, and headers/footers, including mappings to ODF and HTML/CSS properties.
What's inside OOXML Specification
- The AppraiSys system utilizes Office Open XML (OOXML) for DOCX document generation and the Syncfusion Document Format (SFDT), a JSON-based representation, for document manipulation. Developers and QA must understand the mapping between OOXML structures and SFDT to avoid document corruption and optimize performance.
Overview of DrawingML in OOXML
DrawingML is the XML language used to define graphical objects—including pictures, shapes, charts, and diagrams—and package-wide appearance characteristics (themes) within OOXML documents. It is not a standalone language but is embedded within wordprocessingML, spreadsheetML, and presentationML. While VML (Vector Markup Language) is still used for legacy components like certain text boxes in Microsoft Word, DrawingML is the modern standard intended to replace it. It is distinct from SVG, which is primarily used for web and desktop publishing.Understand XML Namespaces in OOXML
XML namespaces prevent naming conflicts when combining XML from different specifications by acting as 'last names' for elements. In Office Open XML (OOXML), namespaces are essential because the format combines multiple specifications such as WordprocessingML, DrawingML, and Relationships.Understand Pivot Table component relationships in SpreadsheetML
A Pivot Table in SpreadsheetML is composed of three primary interconnected parts. The worksheet containing the pivot table references thepivotTablepart. ThepivotTablepart references thepivotCacheDefinitionpart, which in turn references thepivotCacheRecordspart. Additionally, thepivotCacheDefinitionspecifies the original source data (e.g., a worksheet range).<!-- Worksheet -> pivotTable --> <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable" Target="../pivotTables/pivotTable1.xml"/> <!-- pivotTable -> pivotCacheDefinition --> <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" Target="../pivotCache/pivotCacheDefinition1.xml"/> <!-- pivotCacheDefinition -> pivotCacheRecords --> <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/spreadsheetml/2006/relationships/pivotCacheRecord" Target="pivotCacheRecords1.xml"/>Understand the SpreadsheetML cell styling architecture
Cell formatting is stored separately from the worksheet content in a styles part. It uses a system of collections and indices to minimize repetition:
- Base Collections:
<numFmts>,<fonts>,<fills>, and<borders>define all possible individual characteristics. - Cell XFs (
<cellXfs>): A collection of formatting groups. Each<xf>element contains indices (e.g.,fontId,fillId) pointing to the base collections. This represents direct formatting. - Cell Styles (
<cellStyleXfs>): Named styles. An<xf>in the<cellXfs>collection can reference a style via thexfIdattribute, which is an index into the<cellStyleXfs>collection. - Worksheet Reference: A cell in the worksheet references its formatting via the
sattribute (e.g.,<c r="A10" s="12">), which is a zero-based index into the<cellXfs>collection.
<!-- Styles Part Structure --> <stylesheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"> <numFmts/> <fonts/> <fills/> <borders/> <cellStyleXfs/> <cellXfs/> <cellStyles/> <dxfs/> <tableStyles/> </stylesheet>- Base Collections:
Compare OOXML and SFDT format characteristics
OOXML (Office Open XML) and SFDT (Syncfusion Document Format) differ fundamentally in their structure and storage:
OOXML:
- Format: ZIP archive containing XML files.
- Structure: Hierarchical XML elements using multiple namespaces (e.g.,
w:,r:,a:). - Relationships: Managed in separate
.relsfiles. - Images: Stored as binary files in
/word/media/.
SFDT:
- Format: Single JSON object.
- Structure: Nested JSON objects and arrays with no namespaces.
- Relationships: Embedded directly within the JSON.
- Images: Base64 encoded strings or inline URLs.
Implement Connector shapes in OOXML DrawingML
Connectors are specialized shapes used to link two other shapes (
<xdr:sp>or<p:sp>). Unlike standard shapes, connectors do not have a fixed position; their path is determined by the shapes they connect and the generating application. Connectors cannot contain text, so they omit the<txBody>element.Depending on the document type, different elements and namespaces are used:
- Spreadsheets: Use
<xdr:cxnSp>within the namespacexmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/speadsheetDrawing". Shapes are placed in a separate drawing part. - Presentations: Use
<p:cxnSp>within the namespacexmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main". Shapes are placed inline within a<p:spTree>or<p:grpSp>element.
- Spreadsheets: Use
Understand the WordprocessingML (OOXML) document hierarchy
Every Word document follows a strict structural hierarchy. Text cannot exist independently; it must be wrapped in a text element, which is inside a run, which is inside a paragraph, which is inside the body, which is inside the root document element.
Hierarchy:
w:document→w:body→w:p(Paragraph) →w:r(Run) →w:t(Text)<w:document> <w:body> <w:p> <w:r> <w:t>Hello</w:t> </w:r> </w:p> </w:body> </w:document>Define a picture using the DrawingML <pic> element
In OOXML, a picture is defined using the
<pic>element. A complete picture definition requires two parts: information about the image itself and information regarding its placement/positioning within the document. The namespace for the<pic>element varies by document type:- Word Processing:
xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" - Spreadsheets:
xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" - Presentations:
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"
Most visual properties (like fills and effects) use the main DrawingML namespace:
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main".<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"> <pic:nvPicPr> <pic:cNvPr id="0" name="Blue hills.jpg"/> <pic:cNvPicPr/> </pic:nvPicPr> <pic:blipFill> <a:blip r:embed="rId4" cstate="print"/> <a:stretch> <a:fillRect/> </a:stretch> </pic:blipFill> <pic:spPr> <a:xfrm> <a:off x="0" y="0"/> <a:ext cx="2438400" cy="1828800"/> </a:xfrm> <a:prstGeom rst="rect"> <a:avLst/> </a:prstGeom> </pic:spPr> </pic:pic>- Word Processing:
Understand the anatomy of a WordprocessingML (.docx) file
A WordprocessingML (.docx) file is a zip package following the Open Packaging Conventions. It contains various 'parts'—primarily UTF-8 or UTF-16 encoded XML files, but it can also include media files like images and video. To inspect the internal structure of a .docx file, rename the extension to .zip and unzip the archive.Understand OOXML element hierarchy categories
OOXML elements are categorized into three levels of hierarchy. Placing an element in the wrong category's container will cause document corruption.
- Block-Level Elements: Can appear directly in
w:body, table cells (w:tc), SDT content, or headers/footers. Examples includew:p(Paragraph),w:tbl(Table), and block-variantw:sdt(Content Control). - Inline Elements: Must appear inside paragraphs or inline containers. Examples include
w:r(Run),w:hyperlink, and inline-variantw:sdt. - Content Elements: Must appear inside runs (
w:r). Examples includew:t(Text),w:br(Line break),w:tab,w:drawing(Image), andw:sym(Symbol).
- Block-Level Elements: Can appear directly in
Understand SpreadsheetML package structure
A SpreadsheetML document is a package of XML files. The core content is primarily stored in worksheet parts (one per sheet) and asharedStringspart. In Microsoft Excel files, these are located within thexlfolder, with worksheets in aworksheetsub-folder. The workbook part does not contain data but stores spreadsheet properties and references to the individual worksheet parts.<workbook . . .> <workbookPr . . ./> <sheets> <sheet name="sheet1" r:id="rId1"> <sheet name="sheet2" r:id="rId2"> <sheet name="sheet3" r:id="rId3"> </sheets> </workbook>