Package org.docx4j.model.datastorage
Class RemovalHandler
java.lang.Object
org.docx4j.model.datastorage.RemovalHandler
public class RemovalHandler
extends java.lang.Object
Tool to remove content controls (Structured Document Tags) from an OpenXML document part.
This tool removes SDTs tagged with a certain quantifier from the document part.
Restrictions:
- As it does text processing and no real namespace qualification exist, the quantifiers must be prefixed exactly be "od", not any other prefix.
-
In case of qualified removal (in effect not
RemovalHandler.Quantifier.ALL), bindings containing more than one qualifier are not supported, that is, when you tagod:repeat=/this&od:xpath=/that, the SDT is removed whenever you specify to remove either repeat or bind tags. (multiple qualifiers are not recommended in any case!)
- Version:
- $Revision: $ $Date: $
- Author:
- Karsten Tinnefeld
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRemovalHandler.QuantifierA quantifier specifying kinds of SDTs. -
Constructor Summary
Constructors Constructor Description RemovalHandler()Initializes the removal handler. -
Method Summary
Modifier and Type Method Description voidremoveSDTs(WordprocessingMLPackage wordMLPackage)Removes Structured Document Tags from the main document part, headers, and footer, preserving their contents.voidremoveSDTs(WordprocessingMLPackage wordMLPackage, RemovalHandler.Quantifier quantifier, java.lang.String... keys)Removes Structured Document Tags from the main document part, headers, and footer, preserving their contents.voidremoveSDTs(JaxbXmlPart<? extends java.lang.Object> part)Removes Structured Document Tags from a document part, preserving their contents.voidremoveSDTs(JaxbXmlPart<? extends java.lang.Object> part, RemovalHandler.Quantifier quantifier, java.lang.String... keys)Removes Structured Document Tags from a document part, preserving their contents.
-
Constructor Details
-
RemovalHandler
public RemovalHandler()Initializes the removal handler. This tool is thread safe and should be reused, as initialization is relatively expensive.
-
-
Method Details
-
removeSDTs
Removes Structured Document Tags from the main document part, headers, and footer, preserving their contents.- Parameters:
wordMLPackage- The docx package to modify (in situ).- Throws:
Docx4JException- In case any transformation error occurs.- Since:
- 6.1.0
-
removeSDTs
public void removeSDTs(WordprocessingMLPackage wordMLPackage, RemovalHandler.Quantifier quantifier, java.lang.String... keys) throws Docx4JExceptionRemoves Structured Document Tags from the main document part, headers, and footer, preserving their contents. In case key "empty" is specified, value bindings (xpath) are removed only if they have void contents (e.g. the XML points nowhere).- Parameters:
wordMLPackage- The docx package to modify (in situ).quantifier- The quantifier regarding which kinds of parts are to be removed.keys- In case ofRemovalHandler.Quantifier.NAMED, quantifier names. All strings except "xpath", "condition", "repeat", "empty" are ignored.- Throws:
Docx4JException- In case any transformation error occurs.
-
removeSDTs
Removes Structured Document Tags from a document part, preserving their contents. In case key "empty" is specified, value bindings (xpath) are removed only if they have void contents (e.g. the XML points nowhere).- Parameters:
part- The document part to modify (in situ).quantifier- The quantifier regarding which kinds of parts are to be removed.keys- In case ofRemovalHandler.Quantifier.NAMED, quantifier names. All strings except "xpath", "condition", "repeat", "empty" are ignored.- Throws:
Docx4JException- In case any transformation error occurs.
-
removeSDTs
public void removeSDTs(JaxbXmlPart<? extends java.lang.Object> part, RemovalHandler.Quantifier quantifier, java.lang.String... keys) throws Docx4JExceptionRemoves Structured Document Tags from a document part, preserving their contents. In case key "empty" is specified, value bindings (xpath) are removed only if they have void contents (e.g. the XML points nowhere).- Parameters:
part- The document part to modify (in situ).quantifier- The quantifier regarding which kinds of parts are to be removed.keys- In case ofRemovalHandler.Quantifier.NAMED, quantifier names. All strings except "xpath", "condition", "repeat", "empty" are ignored.- Throws:
Docx4JException- In case any transformation error occurs.
-