BasedOn class

Office 2013 and later

Parent Style ID. When the object is serialized out as xml, its qualified name is w:basedOn.

Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

public class BasedOn : String253Type

[ISO/IEC 29500-1 1st Edition]

basedOn (Parent Style ID)

This element specifies the style ID of the parent style from which this style inherits in the style inheritance. The style inheritance refers to a set of styles which inherit from one another to produce the resulting set of properties for a single style. The val attribute of this element specifies the styleId attribute for the parent style in the style inheritance.

If this element is omitted, then this style shall not be based on any other style in the current document (i.e. this element is the root of the style inheritance for a style). If no style in the current document specifies the styleId present in the val attribute, then this element shall be ignored (i.e. this element is the root of the style inheritance for a style).

If a style with this styleId is present, then it shall be subject to the following restrictions:

  • If the current style is a table style, then the parent style shall also be a table style, or this element shall be ignored.

  • If the current style is a paragraph style, then the parent style shall also be a paragraph style, or this element shall be ignored.

  • If the current style is a character style, then the parent style shall also be a character style, or this element shall be ignored.

  • If the current style is a numbering style, then this element shall be ignored.

[Example: Consider three WordprocessingML character styles defined as follows:

  • A character style with a styleId value of Strong whose properties consist of the bold property

  • A character style with a styleId value of Underline whose properties consist of the underline property

  • A character style with a styleId value of Emphasis whose properties consist of the italics property

Each of these character styles defines a single character formatting property. If the basedOn values for each element were defined as follows:

<w:style w:styleId="Strong">
  <w:basedOn w:val="Underline"/>
  …  <w:rPr>
    <w:b/>
  </w:rPr>
</w:style>
<w:style w:styleId="Underline">
  <w:basedOn w:val="Emphasis"/>
  …  <w:rPr>
    <w:u/>
  </w:rPr>
</w:style>
<w:style w:styleId="Emphasis">
  …  <w:rPr>
    <w:i/>
  </w:rPr>
</w:style>

The Strong style is based on the Underline style which is in turn based on the Emphasis style. This means that the actual definition of the Strong style would be as follows:

  • Bold

  • Underline (inherited from Underline)

  • Italics (inherited from Emphasis)

The style chain for the Strong style would be defined as follows:

  • Emphasis

  • Underline

  • Strong

Similarly, the style chain for the Underline style would be defined as follows:

  • Emphasis

  • Underline

In each case, the style chain is the list of all styles which are combined in order to produce the entire set of properties for any given style. end example]

Parent Elements

style (§17.7.4.17)

Attributes

Description

val (String Value)

Specifies that its contents contain a string.

The contents of this string are interpreted based on the context of the parent XML element.

[Example: Consider the following WordprocessingML fragment:

<w:pPr>
  <w:pStyle w:val="heading1" /> 
</w:pPr>

The value of the val attribute is the ID of the associated paragraph style's styleId.

However, consider the following fragment:

<w:sdtPr>
  <w:alias w:val="SDT Title Example" />
  …
</w:sdtPr>

In this case, the decimal number in the val attribute is the caption of the parent structured document tag. In each case, the value is interpreted in the context of the parent element. end example]

The possible values for this attribute are defined by the ST_String simple type (§22.9.2.13).

[Note: The W3C XML Schema definition of this element’s content model (CT_String) is located in §A.1. end note]

© ISO/IEC29500: 2008.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: