StructuredDocumentTag Class

Represents a structured document tag (SDT or content control) in a document.

Inheritance Hierarchy

Namespace:  Aspose.Words.Markup
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0

Syntax

public class StructuredDocumentTag : CompositeNode

The StructuredDocumentTag type exposes the following members.

Constructors

  NameDescription
Public methodCode exampleStructuredDocumentTag
Initializes a new instance of the Structured document tag class.

Properties

  NameDescription
Public propertyCode exampleBuildingBlockCategory
Specifies category of building block for this SDT node. Can not be null.
Public propertyCode exampleBuildingBlockGallery
Specifies type of building block for this SDT. Can not be null.
Public propertyCode exampleCalendarType
Specifies the type of calendar for this SDT. Default is Default
Public propertyCode exampleChecked
Gets/Sets current state of the Checkbox SDT. Default value for this property is false.
Public propertyCode exampleChildNodes
Gets all immediate child nodes of this node.
(Inherited from CompositeNode.)
Public propertyCode exampleColor
Gets or sets the color of the structured document tag.
Public propertyCode exampleContentsFont
Font formatting that will be applied to text entered into SDT.
Public propertyCode exampleCount
Gets the number of immediate children of this node.
(Inherited from CompositeNode.)
Public propertyCode exampleDateDisplayFormat
String that represents the format in which dates are displayed. Can not be null. The dates for English (U.S.) is "mm/dd/yyyy"
Public propertyCode exampleDateDisplayLocale
Allows to set/get the language format for the date displayed in this SDT.
Public propertyCode exampleDateStorageFormat
Gets/sets format in which the date for a date SDT is stored when the SDT is bound to an XML node in the document's data store. Default value is DateTime
Public propertyCode exampleDocument
Gets the document to which this node belongs.
(Inherited from Node.)
Public propertyCode exampleEndCharacterFont
Font formatting that will be applied to the last character of text entered into SDT.
Public propertyCode exampleFirstChild
Gets the first child of the node.
(Inherited from CompositeNode.)
Public propertyCode exampleFullDate
Specifies the full date and time last entered into this SDT.
Public propertyCode exampleHasChildNodes
Returns true if this node has any child nodes.
(Inherited from CompositeNode.)
Public propertyCode exampleId

Specifies a unique read-only persistent numerical Id for this SDT.

Public propertyCode exampleIsComposite
Returns true as this node can have child nodes.
(Inherited from CompositeNode.)
Public propertyCode exampleIsShowingPlaceholderText

Specifies whether the content of this SDT shall be interpreted to contain placeholder text (as opposed to regular text contents within the SDT).

if set to true, this state shall be resumed (showing placeholder text) upon opening this document.

Public propertyCode exampleIsTemporary
Specifies whether this SDT shall be removed from the WordPprocessingML document when its contents are modified.
Public propertyCode exampleLastChild
Gets the last child of the node.
(Inherited from CompositeNode.)
Public propertyCode exampleLevel
Gets the level at which this SDT occurs in the document tree.
Public propertyCode exampleListItems
Gets SdtListItemCollection associated with this SDT.
Public propertyCode exampleLockContentControl
When set to true, this property will prohibit a user from deleting this SDT.
Public propertyCode exampleLockContents
When set to true, this property will prohibit a user from editing the contents of this SDT.
Public propertyCode exampleMultiline
Specifies whether this SDT allows multiple lines of text.
Public propertyCode exampleNextSibling
Gets the node immediately following this node.
(Inherited from Node.)
Public propertyCode exampleNodeType
Returns NodeType.StructuredDocumentTag.
(Overrides NodeNodeType.)
Public propertyCode exampleParentNode
Gets the immediate parent of this node.
(Inherited from Node.)
Public propertyCode examplePlaceholder
Gets the BuildingBlock containing placeholder text which should be displayed when this SDT run contents are empty, the associated mapped XML element is empty as specified via the XmlMapping element or the IsShowingPlaceholderText element is true.
Public propertyCode examplePlaceholderName

Gets or sets Name of the BuildingBlock containing placeholder text.

BuildingBlock with this name Name has to be present in the GlossaryDocument otherwise InvalidOperationException will occur.

Public propertyCode examplePreviousSibling
Gets the node immediately preceding this node.
(Inherited from Node.)
Public propertyCode exampleRange
Returns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node.)
Public propertyCode exampleSdtType
Gets type of this Structured document tag.
Public propertyCode exampleStyle
Gets or sets the Style of the structured document tag.
Public propertyCode exampleStyleName
Gets or sets the name of the style applied to the structured document tag.
Public propertyCode exampleTag
Specifies a tag associated with the current SDT node. Can not be null.
Public propertyCode exampleTitle
Specifies the friendly name associated with this SDT. Can not be null.
Public propertyCode exampleXmlMapping
Gets an object that represents the mapping of this structured document tag to XML data in a custom XML part of the current document.

Methods

  NameDescription
Public methodCode exampleAccept
Accepts a visitor.
(Overrides NodeAccept(DocumentVisitor).)
Public methodCode exampleAppendChild
Adds the specified node to the end of the list of child nodes for this node.
(Inherited from CompositeNode.)
Public methodCode exampleClear
Clears contents of this structured document tag and displays a placeholder if it is defined.
Public methodCode exampleClone (Inherited from Node.)
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetAncestor(Type)
Gets the first ancestor of the specified object type.
(Inherited from Node.)
Public methodCode exampleGetAncestor(NodeType)
Gets the first ancestor of the specified NodeType.
(Inherited from Node.)
Public methodCode exampleGetChild
Returns an Nth child node that matches the specified type.
(Inherited from CompositeNode.)
Public methodCode exampleGetChildNodes
Returns a live collection of child nodes that match the specified type.
(Inherited from CompositeNode.)
Public methodCode exampleGetEnumerator
Provides support for the for each style iteration over the child nodes of this node.
(Inherited from CompositeNode.)
Public methodGetHashCode (Inherited from Object.)
Public methodCode exampleGetText
Gets the text of this node and of all its children.
(Inherited from CompositeNode.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleIndexOf
Returns the index of the specified child node in the child node array.
(Inherited from CompositeNode.)
Public methodCode exampleInsertAfter
Inserts the specified node immediately after the specified reference node.
(Inherited from CompositeNode.)
Public methodCode exampleInsertBefore
Inserts the specified node immediately before the specified reference node.
(Inherited from CompositeNode.)
Public methodCode exampleNextPreOrder
Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node.)
Public methodCode examplePrependChild
Adds the specified node to the beginning of the list of child nodes for this node.
(Inherited from CompositeNode.)
Public methodCode examplePreviousPreOrder
Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node.)
Public methodCode exampleRemove
Removes itself from the parent.
(Inherited from Node.)
Public methodCode exampleRemoveAllChildren
Removes all the child nodes of the current node.
(Inherited from CompositeNode.)
Public methodCode exampleRemoveChild
Removes the specified child node.
(Inherited from CompositeNode.)
Public methodCode exampleRemoveSelfOnly
Removes just this SDT node itself, but keeps the content of it inside the document tree.
Public methodCode exampleRemoveSmartTags
Removes all SmartTag descendant nodes of the current node.
(Inherited from CompositeNode.)
Public methodCode exampleSelectNodes
Selects a list of nodes matching the XPath expression.
(Inherited from CompositeNode.)
Public methodCode exampleSelectSingleNode
Selects the first Node that matches the XPath expression.
(Inherited from CompositeNode.)
Public methodToString (Inherited from Object.)
Public methodCode exampleToString(SaveFormat)
Exports the content of the node into a string in the specified format.
(Inherited from Node.)
Public methodCode exampleToString(SaveOptions)
Exports the content of the node into a string using the specified save options.
(Inherited from Node.)

Remarks

Structured document tags (SDTs) allow to embed customer-defined semantics as well as its behavior and appearance into a document.

In this version Aspose.Words provides a number of public methods and properties to manipulate the behavior and content of StructuredDocumentTag. Mapping of SDT nodes to custom XML packages within a document can be performed with using the XmlMapping property.

StructuredDocumentTag can occur in a document in the following places:

  • Block-level - Among paragraphs and tables, as a child of a Body, HeaderFooter, Comment, Footnote or a Shape node.
  • Row-level - Among rows in a table, as a child of a Table node.
  • Cell-level - Among cells in a table row, as a child of a Row node.
  • Inline-level - Among inline content inside, as a child of a Paragraph.
  • Nested inside another StructuredDocumentTag.

Examples

Shows how to work with styles for content control elements.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Get specific style from the document to apply it to an SDT
Style quoteStyle = doc.Styles[StyleIdentifier.Quote];
StructuredDocumentTag sdtPlainText = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);
sdtPlainText.Style = quoteStyle;

StructuredDocumentTag sdtRichText = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Inline);
// Second method to apply specific style to an SDT control
sdtRichText.StyleName = "Quote";

// Insert content controls into the document
builder.InsertNode(sdtPlainText);
builder.InsertNode(sdtRichText);

// We can get a collection of StructuredDocumentTags by looking for the document's child nodes of this NodeType
Assert.AreEqual(NodeType.StructuredDocumentTag, sdtPlainText.NodeType);

NodeCollection tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);

foreach (Node node in tags)
{
    StructuredDocumentTag sdt = (StructuredDocumentTag)node;
    // If style was not defined before, style should be "Default Paragraph Font"
    Assert.AreEqual(StyleIdentifier.Quote, sdt.Style.StyleIdentifier);
    Assert.AreEqual("Quote", sdt.StyleName);
}

See Also