Page 6 of 29PREVNEXT

Open XML II: Editing Documents in the XML

XML formatting for paragraph and portion of paragraph

The paragraph shown here, both as it appears in document.xml and when you open the document in Word, includes formatting for the entire paragraph as well as unique formatting for just part of the paragraph.

When just part of a paragraph has unique formatting, that part is separated out into its own run, as you see in the XML shown here.

  • The formatting that applies to the entire paragraph (the paragraph style in this case) is shown first.
  • Notice the attribute xml:space =“preserve” in the text tag for the first run of text. Without this attribute, there would be no space between the word at the end of this run and the word that starts the second run.
  • The formatting tag for a run is <w:rPr>, which translates to Word run properties.
  • Nested inside the run formatting tag shown in this example are the tags <w:b /> and <w:sz w:val=”28” />, which correspond to bold and 14 point font.

Other types of formatting display properties tags as well. For example, toward the end of a document.xml file, you see the Word section properties paired tag <w:sectPr>, which contains section-level document formatting, such as page size and margins.

Note     Numeric values are displayed in different units of measure for different types of Open XML Format files. As shown here, font sizes are displayed as double the actual value in the XML for Word documents. However, for Word, most values are displayed in twips (font size is an exception). A twip is equal to 1/20th of a point. In the XML for PowerPoint files you see a few units of measure, such as font size shown at 100 times the actual value, and many percent values multiplied by 100,000.

Page 6 of 29PREVNEXT