ContentPart Class

Defines the ContentPart Class.This class is only available in Office2010.When the object is serialized out as xml, its qualified name is w:contentPart.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlLeafElement
      DocumentFormat.OpenXml.Wordprocessing.ContentPart

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

Syntax

'Declaration
<OfficeAvailabilityAttribute(FileFormatVersions.Office2010)> _
Public Class ContentPart _
    Inherits OpenXmlLeafElement
'Usage
Dim instance As ContentPart
[OfficeAvailabilityAttribute(FileFormatVersions.Office2010)]
public class ContentPart : OpenXmlLeafElement

Remarks

[ISO/IEC 29500-1 1st Edition]

17.3.3.2 contentPart (Content Part)

This element specifies a reference to XML content in a format not defined by ISO/IEC 29500. [Note: This part allows the native use of other commonly used interchange formats, such as:

end note]

The relationship type of the explicit relationship specified by this element shall be https://schemas.openxmlformats.org/officeDocument/2006/customXml and have a TargetMode attribute value of Internal. If an application cannot process content of the content type specified by the targeted part, then it should continue to process the file. If possible, it should also provide some indication that unknown content was not imported.

[Example: Consider a WordprocessingML document which includes the following MathML markup in a part named math1.xml:

<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML">
  <mml:mi>r</mml:mi>
  <mml:mo>=</mml:mo>
  <mml:msup>
    <mml:mrow>
      <mml:mfenced separators="|">
        <mml:mrow>
          <mml:mi>V</mml:mi>
          <mml:mfrac>
            <mml:mrow>
              <mml:mn>3</mml:mn>
            </mml:mrow>
            <mml:mrow>
              <mml:mn>4</mml:mn>
              <mml:mi>π</mml:mi>
            </mml:mrow>
          </mml:mfrac>
        </mml:mrow>
      </mml:mfenced>
    </mml:mrow>
    <mml:mrow>
      <mml:mfrac>
        <mml:mrow>
          <mml:mn>1</mml:mn>
        </mml:mrow>
        <mml:mrow>
          <mml:mn>3</mml:mn>
        </mml:mrow>
      </mml:mfrac>
    </mml:mrow>
  </mml:msup>
</mml:math>

The Main Document Part would reference this content as follows:

<w:body>
…
<w:p>
<w:r>
<w:contentPart r:id="rId8" />
</w:r>
</w:p>
  …
</w:body>

The contentPart element specifies that the content targeted by the relationship with an ID of rId8 is part of the WordprocessingML document. Examining the contents of the corresponding relationship part item, we can see the targets for that relationship:

<Relationships … >
…
<Relationship Id="rId8" TargetMode="Internal" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml" Target="math1.xml" />
…
</Relationships>

The corresponding relationship part item shows that the file to be imported is located next to the main document and is named math1.xml. end example]

Parent Elements

r (§22.1.2.87); r (§17.3.2.25)

Attributes

Description

id (Relationship to Part)

Namespace: .../officeDocument/2006/relationships

Specifies the relationship ID to a specified part.

The specified relationship shall match the relationship type required by the parent element:

  • https://schemas.openxmlformats.org/officeDocument/2006/customXml for the contentPart element

  • https://schemas.openxmlformats.org/officeDocument/2006/relationships/footer for the footerReference element

  • https://schemas.openxmlformats.org/officeDocument/2006/relationships/header for the headerReference element

  • https://schemas.openxmlformats.org/officeDocument/2006/relationships/font for the embedBold, embedBoldItalic, embedItalic, or embedRegular elements

  • https://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings for the printerSettings element

  • https://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink for the longDesc or hyperlink element

[Example: Consider an XML element which has the following id attribute:

<… r:id="rId10" />

The markup specifies the associated relationship part with relationship ID rId1 contains the corresponding relationship information for the parent XML element. end example]

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

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

© ISO/IEC29500: 2008.

Thread Safety

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

See Also

Reference

ContentPart Members

DocumentFormat.OpenXml.Wordprocessing Namespace