Export (0) Print
Expand All

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.

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

[OfficeAvailabilityAttribute(FileFormatVersions.Office2010)]
public class ContentPart : OpenXmlLeafElement

[ISO/IEC 29500-1 1st Edition]

contentPart (Content Part)

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

  • MathML (http://www.w3.org/TR/MathML2/)

  • SMIL (http://www.w3.org/TR/REC-smil/)

  • SVG (http://www.w3.org/TR/SVG11/)

end note]

The relationship type of the explicit relationship specified by this element shall be http://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="http://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:

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

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

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

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

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

  • http://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.

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:
© 2015 Microsoft