Docx4JWordTemplate { static List<SdtElement> findContentControls(ContentAccessor container) throws Docx4JException, JAXBException { List<SdtElement> sdtElements = new LinkedList<SdtElement>(); for (Object o : container.getContent()) { Object unwrapped = XmlUtils.unwrap(o); if (unwrapped instanceof SdtElement) { sdtElements.add((SdtElement) unwrapped); } if (unwrapped instanceof ContentAccessor) { List<SdtElement> list = findContentControls((ContentAccessor) unwrapped); sdtElements.addAll(list); } } return sdtElements; } Docx4JWordTemplate();  Docx4JWordTemplate(InputStream in); PlainTextContent addPlainTextContent(); List<PlainTextContent> getPlainTextContent(); void writeAsOPCXml(OutputStream out); void writeAsOpenXML(OutputStream out); void writeAsPDF(OutputStream out);  }
@Test public void findContentControlsTest() throws Exception { InputStream in = ClassLoader .getSystemResourceAsStream("org/wte4j/impl/word/ContentControls.docx"); WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage .load(in); in.close(); List<SdtElement> elements = Docx4JWordTemplate .findContentControls(wordMLPackage.getMainDocumentPart()); assertEquals(9, elements.size()); }