com.aspose.words

Class SdtType

  • java.lang.Object
    • com.aspose.words.SdtType
public class SdtType 
extends java.lang.Object

Utility class containing constants. Specifies the type of a structured document tag (SDT) node.

Example:

Shows how to work with styles for content control elements.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(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:
Style quoteStyle = doc.getStyles().getByStyleIdentifier(StyleIdentifier.QUOTE);
StructuredDocumentTag sdtPlainText = new StructuredDocumentTag(doc, SdtType.PLAIN_TEXT, MarkupLevel.INLINE);
sdtPlainText.setStyle(quoteStyle);

// 2 -  Reference a style in the document by name:
StructuredDocumentTag sdtRichText = new StructuredDocumentTag(doc, SdtType.RICH_TEXT, MarkupLevel.INLINE);
sdtRichText.setStyleName("Quote");

builder.insertNode(sdtPlainText);
builder.insertNode(sdtRichText);

Assert.assertEquals(NodeType.STRUCTURED_DOCUMENT_TAG, sdtPlainText.getNodeType());

NodeCollection tags = doc.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true);

for (StructuredDocumentTag sdt : (Iterable<StructuredDocumentTag>) tags) {
    Assert.assertEquals(StyleIdentifier.QUOTE, sdt.getStyle().getStyleIdentifier());
    Assert.assertEquals("Quote", sdt.getStyleName());
}

Example:

Shows how to fill a table with data from in an XML part.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

CustomXmlPart xmlPart = doc.getCustomXmlParts().add("Books",
        "<books>" +
                "<book>" +
                "<title>Everyday Italian</title>" +
                "<author>Giada De Laurentiis</author>" +
                "</book>" +
                "<book>" +
                "<title>The C Programming Language</title>" +
                "<author>Brian W. Kernighan, Dennis M. Ritchie</author>" +
                "</book>" +
                "<book>" +
                "<title>Learning XML</title>" +
                "<author>Erik T. Ray</author>" +
                "</book>" +
                "</books>");

// Create headers for data from the XML content.
Table table = builder.startTable();
builder.insertCell();
builder.write("Title");
builder.insertCell();
builder.write("Author");
builder.endRow();
builder.endTable();

// Create a table with a repeating section inside.
StructuredDocumentTag repeatingSectionSdt =
        new StructuredDocumentTag(doc, SdtType.REPEATING_SECTION, MarkupLevel.ROW);
repeatingSectionSdt.getXmlMapping().setMapping(xmlPart, "/books[1]/book", "");
table.appendChild(repeatingSectionSdt);

// Add repeating section item inside the repeating section and mark it as a row.
// This table will have a row for each element that we can find in the XML document
// using the "/books[1]/book" XPath, of which there are three.
StructuredDocumentTag repeatingSectionItemSdt =
        new StructuredDocumentTag(doc, SdtType.REPEATING_SECTION_ITEM, MarkupLevel.ROW);
repeatingSectionSdt.appendChild(repeatingSectionItemSdt);

Row row = new Row(doc);
repeatingSectionItemSdt.appendChild(row);

// Map XML data with created table cells for the title and author of each book.
StructuredDocumentTag titleSdt =
        new StructuredDocumentTag(doc, SdtType.PLAIN_TEXT, MarkupLevel.CELL);
titleSdt.getXmlMapping().setMapping(xmlPart, "/books[1]/book[1]/title[1]", "");
row.appendChild(titleSdt);

StructuredDocumentTag authorSdt =
        new StructuredDocumentTag(doc, SdtType.PLAIN_TEXT, MarkupLevel.CELL);
authorSdt.getXmlMapping().setMapping(xmlPart, "/books[1]/book[1]/author[1]", "");
row.appendChild(authorSdt);

doc.save(getArtifactsDir() + "StructuredDocumentTag.RepeatingSectionItem.docx");

Field Summary
static final intNONE = 0
No type is assigned to the SDT.
static final intBIBLIOGRAPHY = 1
The SDT represents a bibliography entry.
static final intCITATION = 2
The SDT represents a citation.
static final intEQUATION = 3
The SDT represents an equation.
static final intDROP_DOWN_LIST = 4
The SDT represents a drop down list when displayed in the document.
static final intCOMBO_BOX = 5
The SDT represents a combo box when displayed in the document.
static final intDATE = 6
The SDT represents a date picker when displayed in the document.
static final intBUILDING_BLOCK_GALLERY = 7
The SDT represents a building block gallery type.
static final intDOC_PART_OBJ = 8
The SDT represents a document part type.
static final intGROUP = 9
The SDT represents a restricted grouping when displayed in the document.
static final intPICTURE = 10
The SDT represents a picture when displayed in the document.
static final intRICH_TEXT = 11
The SDT represents a rich text box when displayed in the document.
static final intPLAIN_TEXT = 12
The SDT represents a plain text box when displayed in the document.
static final intCHECKBOX = 13
The SDT represents a checkbox when displayed in the document.
static final intREPEATING_SECTION = 14
The SDT represents repeating section type when displayed in the document.
static final intREPEATING_SECTION_ITEM = 15
The SDT represents repeating section item.
static final intENTITY_PICKER = 16
The SDT represents an entity picker that allows the user to select an instance of an external content type.
 

    • Field Detail

      • NONE = 0

        public static final int NONE
        No type is assigned to the SDT.
      • BIBLIOGRAPHY = 1

        public static final int BIBLIOGRAPHY
        The SDT represents a bibliography entry.
      • CITATION = 2

        public static final int CITATION
        The SDT represents a citation.
      • EQUATION = 3

        public static final int EQUATION
        The SDT represents an equation.
      • DROP_DOWN_LIST = 4

        public static final int DROP_DOWN_LIST
        The SDT represents a drop down list when displayed in the document.
      • COMBO_BOX = 5

        public static final int COMBO_BOX
        The SDT represents a combo box when displayed in the document.
      • DATE = 6

        public static final int DATE
        The SDT represents a date picker when displayed in the document.
      • BUILDING_BLOCK_GALLERY = 7

        public static final int BUILDING_BLOCK_GALLERY
        The SDT represents a building block gallery type.
      • DOC_PART_OBJ = 8

        public static final int DOC_PART_OBJ
        The SDT represents a document part type.
      • GROUP = 9

        public static final int GROUP
        The SDT represents a restricted grouping when displayed in the document.
      • PICTURE = 10

        public static final int PICTURE
        The SDT represents a picture when displayed in the document.
      • RICH_TEXT = 11

        public static final int RICH_TEXT
        The SDT represents a rich text box when displayed in the document.
      • PLAIN_TEXT = 12

        public static final int PLAIN_TEXT
        The SDT represents a plain text box when displayed in the document.
      • CHECKBOX = 13

        public static final int CHECKBOX
        The SDT represents a checkbox when displayed in the document. This is MS-specific feature available since Office 2010 and not supported by the ISO/IEC 29500 OOXML standard.
      • REPEATING_SECTION = 14

        public static final int REPEATING_SECTION
        The SDT represents repeating section type when displayed in the document. This is MS-specific feature available since Office 2013 and not supported by the ISO/IEC 29500 OOXML standard.
      • REPEATING_SECTION_ITEM = 15

        public static final int REPEATING_SECTION_ITEM
        The SDT represents repeating section item. This is MS-specific feature available since Office 2013 and not supported by the ISO/IEC 29500 OOXML standard.
      • ENTITY_PICKER = 16

        public static final int ENTITY_PICKER
        The SDT represents an entity picker that allows the user to select an instance of an external content type. This is MS-specific feature available since Office 2010 and not supported by the ISO/IEC 29500 OOXML standard.