public final class WordOutfilter extends WordBufferingFilter
This is the outfilter for the Word by Word pipeline, which is discussed in the Word by Word Text Comparison guide.
Concatenates contents of consecutive deltaxml:word
, deltaxml:punctuation
and
deltaxml:space
elements into deltaxml:textGroup
s.
Example
Comparing (after filtering withWordByWordInfilter
)
<p>sample of word-by-word changes</p>with
<p>sample of word-by-word processing changes</p>gives the delta file (pretty printed)
<p deltaxml:deltaV2="A!=B"> <deltaxml:word deltaxml:deltaV2="A=B">sample</deltaxml:word> <deltaxml:space deltaxml:deltaV2="A=B"> </deltaxml:space> <deltaxml:word deltaxml:deltaV2="A=B">of</deltaxml:word> <deltaxml:space deltaxml:deltaV2="A=B"> </deltaxml:space> <deltaxml:word deltaxml:deltaV2="B">processing</deltaxml:word> <deltaxml:space deltaxml:deltaV2="B"> </deltaxml:space> <deltaxml:word deltaxml:deltaV2="A=B">changes</deltaxml:word> </p>
This filter will process the delta file to remove the word and space elements and show the changes to their contents as follows (pretty printed):
<p deltaxml:deltaV2="A!=B"> sample of word-by-word <deltaxml:textGroup deltaxml:deltaV2="B"> <deltaxml:text deltaxml:deltaV2="B">processing</deltaxml:text> </deltaxml:textGroup> changes </p>
WordOutfilter
should always be used in conjunction with WordInfilter
. It is designed to be used as a
post-filter and should be placed at the beginning of the pipeline.
XML Compare 6.2 Compatibility
In the XML Compare 6.3 release, this filter included the functionality previously provided by the separate WordSpaceFixup
filter. As part of this, whitespace handling was updated to ensure that deltaxml:textGroup
elements did not
contain two child elements whose text content started and/or ended in the same whitespace sequence (as this resulted in a
non-optimal delta). If you wish to keep the original functionality provided prior to XML Compare 6.3 (e.g. for regression
testing purposes), please use the filters in the com.deltaxml.pipe.filters.dx2.wbw.v62
package.
If you are a new customer, we would recommend that you use the latest version of the filters provided in this package.
Note: This class has not been designed to be extended, therefore to err on the side of caution, it has been declared final.
WordInfilter
Constructor and Description |
---|
WordOutfilter()
Creates a WordOutfilter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isOptimiseWhitespaceOnlyChanges()
Reports whether this filter is optimising whitespace-only changes or not.
|
void |
setOptimiseWhitespaceOnlyChanges(boolean value)
Switches off textGroup optimisation for whitespace-only changes.
|
void |
setwrapUnchangedText(java.lang.String value)
Sets whether unchanged text should be wrapped in a
deltaxml:textGroup . |
characters, endElement, isBufferModifiedOnly, startElement, startPrefixMapping
endDocument, getClosestAttributeValueFromAncestor, getClosestAttributeValueFromAnyAncestor, getGrandParentLocalName, getParentLocalName, getParentQName, getProperty, hasAncestor, hasAncestor, hasAncestorWithAttr, hasAncestorWithAttrValue, hasAncestorWithAttrValues, outputCharacters, outputEndElement, outputStartElement, popAncestorStack, pushAncestorStack, setProperty, stackDepth, startDocument
attributeDecl, comment, elementDecl, endCDATA, endDTD, endEntity, externalEntityDecl, internalEntityDecl, parse, parse, startCDATA, startDTD, startEntity
endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, unparsedEntityDecl, warning
public void setwrapUnchangedText(java.lang.String value)
Sets whether unchanged text should be wrapped in a deltaxml:textGroup
.
By default, unchanged text is not wrapped in a deltaxml:textGroup
but if a value of true
is passed
to this method, unchanged text will be wrapped.
setwrapUnchangedText
in class WordBufferingFilter
value
- whether or not to wrap unchanged text in a deltaxml:textGroup
public void setOptimiseWhitespaceOnlyChanges(boolean value)
Switches off textGroup optimisation for whitespace-only changes.
This filter optimises the output of deltaxml:textGroup
elements so that, where possible they don't contain two
branches that both start or end with the same sequence of whitespace characters. While this generally produces the best
output, there may be cases where, for whitespace-only changes, this optimisation should not take place. This method can be
used to switch off the optimisation for thise cases.
value
- whether or not whitespace-only changes should be optimisedpublic boolean isOptimiseWhitespaceOnlyChanges()
Reports whether this filter is optimising whitespace-only changes or not.
WordOutfilter.setOptimiseWhitespaceOnlyChanges(boolean)