The following diagrams define the "schema" of the Aspose.Words document tree. From the diagrams and descriptions, you can gather which nodes can contain which nodes. The diagrams also show a bit of inheritance between the classes where it helps the understanding.
Document, Section and Story
On the above diagram:
- Document has zero or more Section nodes.
- Section has maximum one Body and zero or more HeaderFooter nodes.
- Both Body and HeaderFooter derive from Story.
- Story contains zero or more block-level nodes Paragraph and Table.
Additional requirements to make a valid Microsoft Word document:
- Document needs to have at least one Section.
- Section needs to have Body.
- Body needs to contain at least one Paragraph.
- Maximum one HeaderFooter of each HeaderFooterType is allowed.
A Microsoft Word document consists of one or more sections. A section can define its own page size, margins, orientation, number of text columns as well as headers and footers. Sections are separated by section breaks in a document. The Section class represents a section of a document.
A section contains main text as well as headers and footers for the first, even and odd pages. These different “flows” of text are called stories. In Aspose.Words, the Section node contains the story nodes Body and HeaderFooter. The main text is stored inside the Body object. The text of each header and footer is stored in HeaderFooter objects.
The text of any story consists of paragraphs and tables, represented by the Paragraph and Table objects respectively.
Table, Row and Cell
On the above diagram:
- Table can have many Rows.
- Row can have many Cells.
- Cell can contain block-level nodes Paragraph and Table.
Additional requirements to make a valid Microsoft Word document:
- Table needs to have at least one Row.
- Row needs to have at least one Cell.
- Cell needs to have at least one Paragraph.
Paragraph and Inline Nodes
On the above diagram:
- Paragraph can have many runs of text formatted differently, represented by Run nodes.
- Paragraph can have many bookmarks - BookmarkStart and BookmarkEnd.
- Paragraph can have many Word fields - FieldStart, FieldSeparator and FieldEnd nodes that represent field characters.
- Paragraph can have many Word form fields - FormField nodes.
- Paragraph can have many Shape, GroupShape, Footnote, Comment and SpecialChar nodes.
Shapes, footnotes and comments in Microsoft Word can have text inside them, therefore Shape, Footnote and Comment nodes in Aspose.Words can contain Paragraph and Table nodes.
Shape and GroupShape
On the above diagram:
- Shape can have block-level elements Paragraph and Table.
- GroupShape can have other GroupShape or Shape objects in it.
Shapes in Microsoft Word include Office Art auto shapes, textboxes, images, OLE objects and ActiveX controls, all of these are represented using the Shape class. Some shapes can contain text. Shapes can be grouped using the GroupShape nodes.
Even though a shape in a Microsoft Word document can be positioned inline with text or floating at any position on the page, a shape always has an “anchor” position in text and the Shape or GroupShape object in Aspose.Words represents that anchor position.
Footnote, Endnote and Comment
\
On the above diagram:
- Footnote and Comment derive from InlineStory.
- InlineStory contains zero or more block-level nodes Paragraph and Table.
Footnote and Comment nodes represent the anchor position of a footnote, endnote or comment in the document. The footnote or comment itself usually contains text and this is represented by the Paragraph and Table nodes inside the Footnote or Comment.