StructuredDocumentTag class

StructuredDocumentTag class

Represents a structured document tag (SDT or content control) in a document. To learn more, visit the Structured Document Tags or Content Control documentation article.

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 StructuredDocumentTag.xml_mapping property.

StructuredDocumentTag can occur in a document in the following places:

Inheritance: StructuredDocumentTagCompositeNodeNode

Interfaces: IStructuredDocumentTag

Constructors

NameDescription
StructuredDocumentTag(doc, type, level)Initializes a new instance of the Structured document tag class.

Properties

NameDescription
appearanceGets/sets the appearance of a structured document tag.
building_block_categorySpecifies category of building block for this SDT node. Can not be None.
building_block_gallerySpecifies type of building block for this SDT. Can not be None.
calendar_typeSpecifies the type of calendar for this SDT. Default is SdtCalendarType.DEFAULT
checkedGets/Sets current state of the Checkbox SDT. Default value for this property is False.
colorGets or sets the color of the structured document tag.
contents_fontFont formatting that will be applied to text entered into SDT.
countGets the number of immediate children of this node.
(Inherited from CompositeNode)
custom_node_idSpecifies custom node identifier.
(Inherited from Node)
date_display_formatString that represents the format in which dates are displayed.
date_display_localeAllows to set/get the language format for the date displayed in this SDT.
date_storage_formatGets/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 SdtDateStorageFormat.DATE_TIME
documentGets the document to which this node belongs.
(Inherited from Node)
end_character_fontFont formatting that will be applied to the last character of text entered into SDT.
first_childGets the first child of the node.
(Inherited from CompositeNode)
full_dateSpecifies the full date and time last entered into this SDT.
has_child_nodesReturns True if this node has any child nodes.
(Inherited from CompositeNode)
idSpecifies a unique read-only persistent numerical Id for this SDT.
is_compositeReturns True if this node can contain other nodes.
(Inherited from Node)
is_multi_sectionReturns true if this instance is a ranged (multi-section) structured document tag.
(Inherited from IStructuredDocumentTag)
is_showing_placeholder_textSpecifies whether the content of this SDT shall be interpreted to contain placeholder text (as opposed to regular text contents within the SDT).
is_temporarySpecifies whether this SDT shall be removed from the WordProcessingML document when its contents are modified.
last_childGets the last child of the node.
(Inherited from CompositeNode)
levelGets the level at which this SDT occurs in the document tree.
list_itemsGets SdtListItemCollection associated with this SDT.
lock_content_controlWhen set to True, this property will prohibit a user from deleting this SDT.
lock_contentsWhen set to True, this property will prohibit a user from editing the contents of this SDT.
multilineSpecifies whether this SDT allows multiple lines of text.
next_siblingGets the node immediately following this node.
(Inherited from Node)
nodeReturns Node object that implements this interface.
(Inherited from IStructuredDocumentTag)
node_typeReturns NodeType.STRUCTURED_DOCUMENT_TAG.
parent_nodeGets the immediate parent of this node.
(Inherited from Node)
placeholderGets 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 StructuredDocumentTag.xml_mapping element or the StructuredDocumentTag.is_showing_placeholder_text element is True.
placeholder_nameGets or sets Name of the BuildingBlock containing placeholder text.
previous_siblingGets the node immediately preceding this node.
(Inherited from Node)
rangeReturns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node)
sdt_typeGets type of this Structured document tag.
styleGets or sets the Style of the structured document tag.
style_nameGets or sets the name of the style applied to the structured document tag.
tagSpecifies a tag associated with the current SDT node. Can not be None.
titleSpecifies the friendly name associated with this SDT. Can not be None.
word_open_xmlGets a string that represents the XML contained within the node in the SaveFormat.FLAT_OPC format.
word_open_xml_minimalGets a string that represents the XML contained within the node in the SaveFormat.FLAT_OPC format.
xml_mappingGets 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
accept(visitor)Accepts a visitor.
accept_end(visitor)Accepts a visitor for visiting the end of the StructuredDocumentTag.
accept_start(visitor)Accepts a visitor for visiting the start of the StructuredDocumentTag.
append_child(new_child)Adds the specified node to the end of the list of child nodes for this node.
(Inherited from CompositeNode)
clear()Clears contents of this structured document tag and displays a placeholder if it is defined.
clone(is_clone_children)Creates a duplicate of the node.
(Inherited from Node)
get_ancestor(ancestor_type)Gets the first ancestor of the specified object type.
(Inherited from Node)
get_ancestor(ancestor_type)Gets the first ancestor of the specified NodeType.
(Inherited from Node)
get_child(node_type, index, is_deep)Returns an Nth child node that matches the specified type.
(Inherited from CompositeNode)
get_child_nodes(node_type, is_deep)Returns a live collection of child nodes that match the specified type.
(Inherited from CompositeNode)
get_text()Gets the text of this node and of all its children.
(Inherited from Node)
index_of(child)Returns the index of the specified child node in the child node array.
(Inherited from CompositeNode)
insert_after(new_child, ref_child)Inserts the specified node immediately after the specified reference node.
(Inherited from CompositeNode)
insert_before(new_child, ref_child)Inserts the specified node immediately before the specified reference node.
(Inherited from CompositeNode)
next_pre_order(root_node)Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node)
node_type_to_string(node_type)A utility method that converts a node type enum value into a user friendly string.
(Inherited from Node)
prepend_child(new_child)Adds the specified node to the beginning of the list of child nodes for this node.
(Inherited from CompositeNode)
previous_pre_order(root_node)Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node)
remove()Removes itself from the parent.
(Inherited from Node)
remove_all_children()Removes all the child nodes of the current node.
(Inherited from CompositeNode)
remove_child(old_child)Removes the specified child node.
(Inherited from CompositeNode)
remove_self_only()Removes just this SDT node itself, but keeps the content of it inside the document tree.
remove_smart_tags()Removes all SmartTag descendant nodes of the current node.
(Inherited from CompositeNode)
select_nodes(xpath)Selects a list of nodes matching the XPath expression.
(Inherited from CompositeNode)
select_single_node(xpath)Selects the first Node that matches the XPath expression.
(Inherited from CompositeNode)
set_checked_symbol(character_code, font_name)Sets the symbol used to represent the checked state of a check box content control.
set_unchecked_symbol(character_code, font_name)Sets the symbol used to represent the unchecked state of a check box content control.
to_string(save_format)Exports the content of the node into a string in the specified format.
(Inherited from Node)
to_string(save_options)Exports the content of the node into a string using the specified save options.
(Inherited from Node)

Examples

Shows how to work with styles for content control elements.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
# Below are two ways to apply a style from the document to a structured document tag.
# 1 -  Apply a style object from the document's style collection:
quote_style = doc.styles.get_by_style_identifier(aw.StyleIdentifier.QUOTE)
sdt_plain_text = aw.markup.StructuredDocumentTag(doc, aw.markup.SdtType.PLAIN_TEXT, aw.markup.MarkupLevel.INLINE)
sdt_plain_text.style = quote_style
# 2 -  Reference a style in the document by name:
sdt_rich_text = aw.markup.StructuredDocumentTag(doc, aw.markup.SdtType.RICH_TEXT, aw.markup.MarkupLevel.INLINE)
sdt_rich_text.style_name = 'Quote'
builder.insert_node(sdt_plain_text)
builder.insert_node(sdt_rich_text)
self.assertEqual(aw.NodeType.STRUCTURED_DOCUMENT_TAG, sdt_plain_text.node_type)
tags = doc.get_child_nodes(aw.NodeType.STRUCTURED_DOCUMENT_TAG, True)
for node in tags:
    sdt = node.as_structured_document_tag()
    print(sdt.word_open_xml_minimal)
    self.assertEqual(aw.StyleIdentifier.QUOTE, sdt.style.style_identifier)
    self.assertEqual('Quote', sdt.style_name)

See Also