Latent Styles

The final piece of information stored in the styles part in the document, aside from style definition information, is latent style information.

Latent styles are all styles contained in a document’s template which have not yet been instantiated (used) in the current instance of the document.

In WordprocessingML, there are often properties which must be set on all styles in a document template regardless of whether they are being used: for example, whether or not the style can be applied in the current document (locked state), UI sorting priority, whether the style should be shown in the user interface, etc. In order for the document to function correctly, it is essential that this information is stored within the document, so that a consumer can determine the necessary style information from the document alone (without access to the template). However, it would be grossly inefficient for the document to store all style information for all styles simply to store this information, so latent styles are used to store just the necessary style properties without caching all style information in the document.

In order to do this efficiently, the document declares a <latentStyles> element in the styles part which defines the default properties applied to all latent styles in the document. All styles whose properties do not match the default for the set of style properties which must be defined for all styles are explicitly defined using the <lsdException> element.

Consider the following latent style information stored in a document’s styles part:

<w:latentStyles w:defLockedState="off" w:defPriority="99"
  w:defSemiHidden="on" w:defUnhideWhenUsed="on" w:defQFormat="off"
  w:count="180">
  <w:lsdException w:name="Normal" w:unhideWhenUsed="off"
    w:qformat="on"/>
  <w:lsdException w:name="heading 1" w:semiHidden="off" w:priority="1"/>
  <w:lsdException w:name="heading 2" w:priority="1" 
    w:unhideWhenUsed="on"/>
  <w:lsdException w:name="heading 3" w:semiHidden="off/>
  <w:lsdException w:name="heading 4" w:priority="1" w:qformat="on"/>
  <w:lsdException w:name="heading 5" w:priority="1" w:qformat="on"/>
  <w:lsdException w:name="heading 6" w:priority="1" w:qformat="on"/>
  <w:lsdException w:name="heading 7" w:priority="1" w:qformat="on"/>
  <w:lsdException w:name="heading 8" w:priority="1" w:qformat="on"/>
  <w:lsdException w:name="heading 9" w:priority="1" w:qformat="on"/>
  <w:lsdException w:name="Normal Indent" w:priority="6" w:qformat="on"/>
</w:latentStyles>

The attributes on the <latentStyles> element define the properties applied to all latent styles for this document. All styles whose properties do not match the default latent styles properties are explicitly defined using the values on the <lsdException> elements.