Class LexicalPreservationConfig
- document loading phase converts/encodes the 'lexical' aspects of the document into a form that can be retained and processed by the underpinning comparator engine.
- preservation processing phase conceptually gathers together those output filters that are responsible for transforming any differences contained in the preserved items into a form that can be handled by the final output/serialisation stage. This stage may require some custom filters for handling, say for specific output format constraints.
- output/serialisation phase typically converts/decodes the 'lexical' aspects of the document back into their original forms. However, it is possible for encoded forms to be retained if desired.
Normally an XML parser or 'XML processor' (a term defined in the XML specification) disregards 'doctype', 'ignorable
whitespace', 'cdata Sections' and other 'lexical' aspects of the XML input during processing. Both the
PipelinedComparator and the DocumentComparator can be configured to convert the 'lexical' items into markup
that can be processed by the underpinning comparator (i.e. element, attribute, and text nodes). Note that comments and
processing instructions are also treated as 'lexical' aspects of the input, as the underpinning comparator ignores them.
Note that some aspects of XML are not reported by an XML Parser and so we cannot ensure complete preservation of all lexical aspects of an input file. Some of these aspects include:
- whether single or double quotes are used for attribute values
- attribute order within a start tag
- any whitespace within a start tag or end tag, for example whitespace or line breaks between attributes
- any whitespace outside of the root element, including whitespace in the DTD internal subset
- whether or not an XML Declaration was present in the input
Some of the things that can be preserved include:
- comments
- processing instructions
- doctype declarations
- information about the file encoding and XML version (whether from the XML Declaration or otherwise)
- entity reference information (while the parser expands we still keep reference info)
- subset declarations for elements, attributes and entities
- use of CDATA sections
- ignorable whitespace (while the parser is set to load a DTD or XML Schema)
Usage
This configuration class should be set up as required and then passed as the parameter to the
PipelinedComparator.setLexicalPreservationConfig(LexicalPreservationConfig) method.
Data relocation
Some marked up items cannot be placed at their original locations whilst maintaining a well-formed result. This primarily relates to information outside the root element. For these areas the markup is moved inside the root element and contained in the first few children of the root element or the last child. Generally only comments and processing instructions can appear outside the root element, however the internal subset contains other items, as does the XML declaration. When all types of information are present the output will have this structure:
<root> <preserve:xmldecl xml-version="1.0" encoding="UTF-8" standalone="no"/> <preserve:comments-and-pis region="BEFORE_DTD"> ... </preserve:comments-and-pis> <preserve:doctype> ... </preserve:doctype> <preserve:comments-and-pis region="AFTER_DTD"> ... </preserve:comments-and-pis> <child> first child element of original root element ... </child> ... <child> last child element of original root element ... </child> <preserve:comments-and-pis region="AFTER_BODY"> ... </preserve:comments-and-pis> </root>
Entity Handling
Three of the settings provided for handling entities interact in various ways. Some observations to note include:
- Setting
setPreserveNestedEntityReferences(boolean)totrueonly makes sense when bothsetPreserveEntityReferences(boolean)andsetPreserveEntityReplacementText(boolean)are alsotrue - Setting both
setPreserveEntityReferences(boolean)andsetPreserveEntityReplacementText(boolean)tofalsemeans that information is lost completely and this is not recommended
Namespaces
Lexcial preservation creates elements in several namespaces, the following table provides a summary:
| Usual prefix | Namespace URI | Description |
|---|---|---|
| preserve | http://www.deltaxml.com/ns/preserve | All generated markup uses this namespace unless one of those mentioned below |
| er | http://www.deltaxml.com/ns/entity-references | Entity references are represented as elements using this namespace and a local name based on the entity name |
| pi | http://www.deltaxml.com/ns/processing-instructions | Processing instructions are represented as elements using this namespace and a local name based on the PI target |
Compatibility with Previous Releases
Lexical preservation is now a feature setting on a PipelinedComparator, rather than being an XMLFilter that is added
at the start of the input pipelines. This method of preserving items replaces the previous LexicalPreservation filter which has
been removed.
- Since:
- 7.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanThe default value of the configuration property for enabling lexical preservation during comparator construction.static final StringThe name of the configuration property for enabling lexical preservation during comparator construction. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Configuration for lexical preservation.Creates a new Configuration for lexical preservation using the specified mode.LexicalPreservationConfig(PresetPreservationMode preserveItemSetName) Creates a new Configuration for lexical preservation using the specified mode.LexicalPreservationConfig(String preserveItemSetName) Creates a new Configuration for lexical preservation using the specified mode. -
Method Summary
Modifier and TypeMethodDescriptionReturn whether entity references or their replacement text appear in the output.Return the currentPreservationOutputTypefor CDATA sections.Return the currentPreservationProcessingModefor CDATA blocks.Return the currentPreservationOutputTypefor comments.Return the currentPreservationProcessingModefor comments.Return the currentPreservationOutputTypefor defaulted attributes.Return the currentDefaultAttProcessingModefor defaulted attributes.Return the current defaultPreservationOutputTypefor preserved items.Return the current defaultPreservationProcessingMode.Return the currentPreservationOutputTypefor document type (and internal subset).Return the currentPreservationProcessingModefor doctype declarations.Return the currentPreservationOutputTypefor entity references.Return the currentPreservationProcessingModefor entity references.Return the currentPreservationOutputTypefor ignorable whitespace.Return the currentPreservationProcessingModefor ignorable whitespace.Return thePreservationOutputTypeto use for changes to processing instructions and comments outside the root element (and outside the internal subset).Return the currentPreservationProcessingModefor processing instructions and comments outside the root element.booleanReports the current CDATA marker status.booleanReports the current comment conversion/preservation status.booleanReports the current setting of the content model preservation feature.booleanReports whether information on which attributes were provided by a DTD is being stored.booleanReports the current setting of the entity reference preservation feature.booleanReports the current setting for DTD internal subset preservation.booleanReports the current setting of the document location preservation feature.booleanReports whether entity replacement text is preserved.booleanReports the current whitespace preservation setting.booleanReports the current nested entity references setting.booleanReports the current processing instructions conversion status.booleanReports whether XML Declarations are currently converted into markup.Return the currentPreservationOutputTypefor processing instructions.Return the currentPreservationProcessingModefor processing instructions.Return the currentPreservationOutputTypefor XML declaration.Return the currentPreservationProcessingModefor xml declaration changes.booleanStates whether thisLexicalPreservationConfigobject is preserving any items on the inputs.voidSpecify advanced behaviour of entity reference processing.voidsetAllPreservationItems(boolean preserve) Sets the preservation status of all PreserveItems.voidSet thePreservationOutputTypefor changes to CDATA sections.voidSet thePreservationProcessingModeto use for changes to CDATA blocks.voidSet thePreservationOutputTypefor changes to comments.voidSet thePreservationProcessingModeto use for changes to comments.voidSet thePreservationOutputTypefor changes to defaulted attributes.voidSet theDefaultAttProcessingModeto use for defaulted attributes.voidSet the defaultPreservationOutputTypefor changes to preserved items.voidSet thePreservationProcessingModeto use as the default behaviour for changed lexical preservation items.voidSet thePreservationOutputTypefor changes to document type (and internal subset).voidSet thePreservationProcessingModeto use for changes to doctype declarations.voidSet thePreservationOutputTypefor changes to entity references.voidSet thePreservationProcessingModefor changes to entity references.voidSet thePreservationOutputTypefor changes to ignorable whitespace.voidSet thePreservationProcessingModefor changes to ignorable whitespace.voidSet thePreservationOutputTypeto use for changes to processing instructions and comments outside the root element (and outside the internal subset).voidSet thePreservationProcessingModeto use for changes to processing instructions and comments outside the root element.voidsetPreserveCDATA(boolean preserve) Controls whether marker elements are inserted to record where CDATA sections were used.voidsetPreserveComments(boolean preserve) Controls whether XML Comments are converted into XML markup.voidsetPreserveContentModel(boolean preserve) Controls whether markup used to record content model information is persisted.voidsetPreserveDefaultAttributeInfo(boolean preserve) Adds information about which attributes arose through the use of default attribute values in the DTD, as opposed to having explicit values.voidsetPreserveDoctype(boolean preserve) Controls whether items in XML DOCTYPE declaration and the DTD internal subset are converted into XML markup.voidsetPreserveDocumentLocation(boolean preserve) Controls whether markup is added to record the document location informationvoidsetPreserveEntityReferences(boolean preserve) Controls whether markup is used to record where entity references were used.voidsetPreserveEntityReplacementText(boolean preserve) Controls whether entity replacement text is preserved by this filter.voidsetPreserveIgnorableWhitespace(boolean preserve) Controls whether ignorableWhitespace is converted into standard character data.voidsetPreserveNestedEntityReferences(boolean preserve) Controls whether entity references are included in entity replacement text results.voidsetPreserveProcessingInstructions(boolean preserve) Controls whether processing instructions are converted into XML markup.voidsetPreserveXMLDeclaration(boolean preserve) Controls whether XML Declaration related information is converted into XML markup.voidSet thePreservationOutputTypefor changes to processing instructions.voidSet thePreservationProcessingModefor changes to processing instructions.voidSet thePreservationOutputTypefor changes to XML declaration.voidSet thePreservationProcessingModeto use for changes to the xml declaration.This method is for internal use.
-
Field Details
-
ENABLED_PROP_NAME
The name of the configuration property for enabling lexical preservation during comparator construction.- See Also:
-
ENABLED_PROP_DVAL
public static final boolean ENABLED_PROP_DVALThe default value of the configuration property for enabling lexical preservation during comparator construction.- See Also:
-
-
Constructor Details
-
LexicalPreservationConfig
public LexicalPreservationConfig()Creates a new Configuration for lexical preservation.
Note: the default behaviour of the lexical preservation is
PresetPreservationMode.ROUND_TRIP, unless this has been overridden by supplying configuration properties as discussed in the Lexical Preservation Guide. -
LexicalPreservationConfig
Creates a new Configuration for lexical preservation using the specified mode.
Note: the default behaviour of the lexical preservation is
PresetPreservationMode.ROUND_TRIP, unless this has been overridden by supplying configuration properties as discussed in the Lexical Preservation Guide.- Parameters:
preserveItemSetName- a String specifying the preservation mode to create the Configuration with. Invalid values result in the default setting ofPresetPreservationMode.ROUND_TRIPbeing used.- See Also:
-
LexicalPreservationConfig
Creates a new Configuration for lexical preservation using the specified mode.
Note: the default behaviour of the lexical preservation is
PresetPreservationMode.ROUND_TRIP, unless this has been overridden by supplying configuration properties as discussed in the Lexical Preservation Guide.- Parameters:
preserveItemSetName- the preservation mode to create the Configuration with, ornullfor the default behaviour.- See Also:
-
LexicalPreservationConfig
Creates a new Configuration for lexical preservation using the specified mode.- Parameters:
base- The lexical preservation object to be used as the base configuration.
-
-
Method Details
-
isPreservingItems
public boolean isPreservingItems()States whether this
LexicalPreservationConfigobject is preserving any items on the inputs.This is a shorthand way of determining if any of the
getPreserve...()methods returntrue.- Returns:
- a boolean stating whether any preservation items are being preserved
-
setPreserveDoctype
public void setPreserveDoctype(boolean preserve) Controls whether items in XML DOCTYPE declaration and the DTD internal subset are converted into XML markup.
The XML DOCTYPE declaration and associated internal subset can be converted into XML Markup for subsequent pipeline comparison and processing. The use of an external DTD is recorded, and as well as conversion the parser will validate the content using any declarations specified in an external DTD or internal DTD subset.
For example, when
truehas been passed to this method, the following DOCTYPE, in an input file:<!DOCTYPE article SYSTEM "http://www.docbook.org/xml/4.5/docbookx.dtd" [ <!ENTITY genEnt "<emphasis role='bold'>warning</emphasis>"> ]>
will be converted into output containing:
<preserve:doctype name="article" systemId="http://www.docbook.org/xml/4.5/docbookx.dtd"> <preserve:internalParsedGeneralEntityDecl name="genEnt" deltaxml:key="entity_gen_genEnt" value="an !(*lt!)emphasis role=!(*apos!)bold!(*apos!)!(*gt!)internal (parsed) general!(*lt!)/emphasis!(*gt!) entity."/> </preserve:doctype>- Parameters:
preserve- iftrueinternal subset items are converted and preserved- See Also:
-
getPreserveDoctype
public boolean getPreserveDoctype()Reports the current setting for DTD internal subset preservation.
- Returns:
trueif internal subset items are currently being preserved- See Also:
-
setPreserveXMLDeclaration
public void setPreserveXMLDeclaration(boolean preserve) Controls whether XML Declaration related information is converted into XML markup.
An XML declaration can specify the encoding, XML version and whether an XML file is 'standalone'. This information can be explicitly specified in an XML file but if it is not presebt, the parser will determine the information based on rules defined in the XML Specifications (see below).
The input settings will be preserved and used in the result file as long as they are not overridden with pipeline outputProperties e.g. if the inputs specify an encoding of UTF-16BE, this will be used as the encoding for files written by the comparison. However, if the encoding output property is set to UTF-8, the result file will be encoded using UTF-8.
N.B. Having no XML declaration in the inputs does not stop one from being output in the result file. The result will always contain a declaration specifying the XML version and File encoding unless the omit-xml-declaration output property has been set to 'yes'.
For example, when this method has been passed a value of
true, an XML file with this declaration:<?xml version="1.0" encoding="UTF-8"?>
will produce output containing:
<preserve:xmldecl xml-version="1.0" encoding="UTF-8"/>
- Parameters:
preserve- whether or not to preserve XML declaration settings- See Also:
-
getPreserveXMLDeclaration
public boolean getPreserveXMLDeclaration()Reports whether XML Declarations are currently converted into markup.
- Returns:
truewhen XML declaration information is converted
-
setPreserveDefaultAttributeInfo
public void setPreserveDefaultAttributeInfo(boolean preserve) Adds information about which attributes arose through the use of default attribute values in the DTD, as opposed to having explicit values.
A DTD can contain attribute definitions such as the following:
<!ELEMENT myElement> <!ATTLIST myElement myAttribute CDATA "defaultValue">
When a value is defined in quotes like this, and the XML document is associated with this DTD using the DOCTYPE declaration, the attribute
myAttributewill be present on everymyElementelement whether it has been explicitly added or not. If it is added by the parser, it will have the default value ofdefaultValueas defined in the DTD.When
truehas been passed to this method, attributes that have default values assigned by the parser in this way will be marked by adding an attribute to the element like this:<myElement myAttribute="defaultValue" preserve:defaultAttributes="{}myAttribute">where the attribute name is encoded in the form
{URI}localName.- Parameters:
preserve- if true information about defaulted attributes is added to the mark
-
getPreserveDefaultAttributeInfo
public boolean getPreserveDefaultAttributeInfo()Reports whether information on which attributes were provided by a DTD is being stored.
- Returns:
- true if default attribute info is added to markup
-
setPreserveEntityReferences
public void setPreserveEntityReferences(boolean preserve) Controls whether markup is used to record where entity references were used.
An XML start-tag and end-tag will usually mark the position of the entity reference. This marker element will contain, by default, the entity replacement text as it was expanded by the parser.
Here is an example showing use of the XML predefined ampersand entity, more complex entities are also supported, including longer sequences of text and markup (elements):
<para>Hide & seek</para>
When this method is configured to
false, the output will be:<para>Hide & seek</para>
The parser converts the entity into a literal unicode character (which may be serialized back into an entity at the end of the pipeline). With the setting
truewe see an XML element (using the 'er' namespace and local-name from the entity name) which records the details of the entity reference:<para>Hide <er:amp>&</er:amp> seek</para>
Please see the method description of
setPreserveEntityReplacementText(boolean)for a more detailed description of how these two settings interact.- Parameters:
preserve- whether or not to record where entity references were used- See Also:
-
getPreservedEntityReferences
public boolean getPreservedEntityReferences()Reports the current setting of the entity reference preservation feature.- Returns:
- whether entity reference information is preserved
-
setPreserveContentModel
public void setPreserveContentModel(boolean preserve) Controls whether markup used to record content model information is persisted.
- Parameters:
preserve- whether or not to persist content model information
-
getPreserveContentModel
public boolean getPreserveContentModel()Reports the current setting of the content model preservation feature.- Returns:
- whether content model information is preserved
-
setPreserveDocumentLocation
public void setPreserveDocumentLocation(boolean preserve) Controls whether markup is added to record the document location information
The document location is stored by adding an xml:base attribute to the root element.
N.B. If the xml:base attribute is already present on the parsed input, it will NOT be replaced.
- Parameters:
preserve- whether or not to preserve document location information
-
getPreserveDocumentLocation
public boolean getPreserveDocumentLocation()Reports the current setting of the document location preservation feature.- Returns:
- whether document location information is preserved
-
setPreserveNestedEntityReferences
public void setPreserveNestedEntityReferences(boolean preserve) Controls whether entity references are included in entity replacement text results.
A entity definition can itself contain an entity reference (general or parameter) and this method controls whether such entity references appear in the output.
When
false, entity reference elements will not be nested. Conversely when this parameter is set totrue, the result may include nested entity reference elements (in theernamespace).The nesting corresponds to the use of entity references in the definition of other entity references.
- Parameters:
preserve- iftrue, nested entities are converted- See Also:
-
getPreserveNestedEntityReferences
public boolean getPreserveNestedEntityReferences()Reports the current nested entity references setting.
- Returns:
trueif nested entity references are converted- See Also:
-
setPreserveEntityReplacementText
public void setPreserveEntityReplacementText(boolean preserve) Controls whether entity replacement text is preserved by this filter.
As well as being able to use an element to describe the details of an element reference it is also possible to control whether the replacement text is preserved in the output.
The term 'Entity Replacement Text' is used in the W3C XML Specification and section 4.5 describes the process of replacing entity references.
For the follow example input markup:
<para>Hide & seek</para>
Effects of the preservation settings for entity replacement text and also entity references setPreserveEntityReplacementText setPreserveEntityReferences result true true <para>Hide <er:amp>&</er:amp> seek</para> true false <para>Hide & seek</para> false true <para>Hide <er:amp></er:amp> seek</para> false false <para>Hide seek</para> The entity replacement text for the
&entity is the unicode ampersand character (U+0026) and this character appears in the results generated by this filter. An output filter or serializer at the end of a pipeline may subsequently re-serialize this character back into an entity reference such as&or a character reference&so that the pipeline result is well-formed.- Parameters:
preserve- whentrue, replacement text is preserved- See Also:
-
getPreserveEntityReplacementText
public boolean getPreserveEntityReplacementText()Reports whether entity replacement text is preserved.
- Returns:
- the current setting for entity replacement text
- See Also:
-
setPreserveCDATA
public void setPreserveCDATA(boolean preserve) Controls whether marker elements are inserted to record where CDATA sections were used.
The CDATA shorthand removes the need for entities and is a useful shorthand when authoring. The characters that an XML processor receives are identical irrespective of whether CDATA or entities are used.
This feature uses an element to record the position of CDATA sections in the input file.
<para><![CDATA[Hide & seek]]></para>
When this feature is
truethe output of this filter will be:<para><preserve:cdata>Hide & seek</preserve:cdata></para>
When
false, the text content is as before, only the marker element is missing:<para>Hide & seek</para>
- Parameters:
preserve- whentrue, insert CDATA markers
-
getPreserveCDATA
public boolean getPreserveCDATA()Reports the current CDATA marker status.
- Returns:
truewhen CDATA is marked- See Also:
-
setPreserveComments
public void setPreserveComments(boolean preserve) Controls whether XML Comments are converted into XML markup.
For example, when the preserve parameter is
true, with this input:<!-- add another section here -->
the comment would be converted into:
<preserve:comment> add another section here </preserve:comment>
When the preserve parameter is
false, i.e. comments are not converted, it is still possible for the subsequent filters in a filter chain to receive comment events. This depends on whether the subsequent filters have configured the use of aLexicalHandlerand/or extendXMLFilterImpl2orXMLFilterImpl3.The
setPreserveProcessingInstructions(boolean)documentation also describes in which contexts the comment markup appears in the result.- Parameters:
preserve- controls whether comments are converted- See Also:
-
getPreserveComments
public boolean getPreserveComments()Reports the current comment conversion/preservation status.
- Returns:
trueif comments are converted to markup,falseotherwise
-
setPreserveProcessingInstructions
public void setPreserveProcessingInstructions(boolean preserve) Controls whether processing instructions are converted into XML markup.
For example, with this input and setting of
truefor the preserve parameter:<?dbfo table-width="50%"?>
the processing instruction would be converted into:
<pi:dbfo>table-width="50%"</pi:dbfo>
When the processing instructions are contained within the root element of an XML file they appear in their converted form as in the example above. However, when outside of the root element they need to be moved and they will then appear as a child of either
<preserve:comments-and-pis>element with a range attribute indicating their position, or as a child of the<preserve:doctype>element.- Parameters:
preserve- controls whether XML Processing Instructions are converted
-
getPreserveProcessingInstructions
public boolean getPreserveProcessingInstructions()Reports the current processing instructions conversion status.
- Returns:
- true when conversion will take place
- See Also:
-
setPreserveIgnorableWhitespace
public void setPreserveIgnorableWhitespace(boolean preserve) Controls whether ignorableWhitespace is converted into standard character data.
Ignorable whitespace is reported by parsers when the input file is associated with a DTD. The DTD allows a parser to differentiate between mixed content and element-only content where ignorable whitespace is reported. A
truevalue will allow all whitespace to flow through a comparison pipeline including what is typically regarded as 'indentation whitespace' in XML and this may be important when round trip processing is required.- Parameters:
preserve- specifies whether whitespace is converted to characters
-
getPreserveIgnorableWhitespace
public boolean getPreserveIgnorableWhitespace()Reports the current whitespace preservation setting.
- Returns:
trueif whitespace is converted to comments.- See Also:
-
setAllPreservationItems
public void setAllPreservationItems(boolean preserve) Sets the preservation status of all PreserveItems.
This method provides a shorthand way of setting all PreserveItems to the same value. It is useful if you only wish to set one or two of the items to be preserved. If this is the case, pass
falseto this method and subsequently passtrueto the individual set methods for the items you wish to preserve.- Parameters:
preserve- iftrue, preserve all PreserveItems, iffalse, preserve none
-
setDefaultProcessingMode
Set thePreservationProcessingModeto use as the default behaviour for changed lexical preservation items. Note this does not affect the setting of the default attribute processing mode.- Parameters:
mode- thePreservationProcessingModeto use as the default behaviour for changes to lexical preservation items
-
getDefaultProcessingMode
Return the current defaultPreservationProcessingMode.- Returns:
- an
PreservationProcessingModedetailing the default behaviour for changed lexical preservation items
-
setXMLDeclarationProcessingMode
Set thePreservationProcessingModeto use for changes to the xml declaration.- Parameters:
mode- thePreservationProcessingModeto use for changes to the xml declaration
-
getXMLDeclarationProcessingMode
Return the currentPreservationProcessingModefor xml declaration changes.- Returns:
- an
PreservationProcessingModedetailing how a changed xml declaration will be output
-
setDoctypeProcessingMode
Set thePreservationProcessingModeto use for changes to doctype declarations.- Parameters:
mode- thePreservationProcessingModeto use for changes to doctype declarations
-
getDoctypeProcessingMode
Return the currentPreservationProcessingModefor doctype declarations.- Returns:
- an
PreservationProcessingModedetailing how changed doctype declarations will be output
-
setDefaultAttributeInfoProcessingMode
Set theDefaultAttProcessingModeto use for defaulted attributes. Note that when this mode is set to 'atomatic' it behaves as 'excplicit' rather than as specified by the default processing mode.- Parameters:
mode- theDefaultAttProcessingModeto use for defaulted attributes.- See Also:
-
getDefaultedAttributeInfoProcessingMode
Return the currentDefaultAttProcessingModefor defaulted attributes.- Returns:
- a
DefaultAttProcessingModedetailing how defaulted attributes will be output
-
setOuterPiAndCommentProcessingMode
Set thePreservationProcessingModeto use for changes to processing instructions and comments outside the root element. Note if this element is set toPreservationProcessingMode.CHANGE, then the processing instructions and comments outside the root element are handled in the same manner as those inside the root element.- Parameters:
mode- thePreservationProcessingModeto use for changes to processing instructions and comments outside the root element
-
getOuterPiAndCommentProcessingMode
Return the currentPreservationProcessingModefor processing instructions and comments outside the root element.- Returns:
- an
PreservationProcessingModedetailing how changed processing instructions and comments outside the root element will be output
-
setCommentProcessingMode
Set thePreservationProcessingModeto use for changes to comments.- Parameters:
mode- thePreservationProcessingModeto use for changes to comments
-
getCommentProcessingMode
Return the currentPreservationProcessingModefor comments.- Returns:
- an
PreservationProcessingModedetailing how changed comments will be output
-
setCDATAProcessingMode
Set thePreservationProcessingModeto use for changes to CDATA blocks.- Parameters:
mode- thePreservationProcessingModeto use for changes to CDATA blocks
-
getCDATAProcessingMode
Return the currentPreservationProcessingModefor CDATA blocks.- Returns:
- an
PreservationProcessingModedetailing how changed CDATA blocks will be output
-
setProcessingInstructionProcessingMode
Set thePreservationProcessingModefor changes to processing instructions.- Parameters:
mode- thePreservationProcessingModeto use for changes to processing instructions
-
getProcessingInstructionProcessingMode
Return the currentPreservationProcessingModefor processing instructions.- Returns:
- an
PreservationProcessingModedetailing how processing instructions will be output
-
setIgnorableWhitespaceProcessingMode
Set thePreservationProcessingModefor changes to ignorable whitespace.- Parameters:
mode- thePreservationProcessingModeto use for changes to ignorable whitespace
-
getIgnorableWhitespaceProcessingMode
Return the currentPreservationProcessingModefor ignorable whitespace.- Returns:
- an
PreservationProcessingModedetailing how ignorable whitespace will be output
-
setEntityRefProcessingMode
Set thePreservationProcessingModefor changes to entity references.- Parameters:
mode- thePreservationProcessingModeto use for changes to entity references
-
getEntityRefProcessingMode
Return the currentPreservationProcessingModefor entity references.- Returns:
- an
PreservationProcessingModedetailing how entity references will be output
-
setAdvancedEntityReferenceUsage
Specify advanced behaviour of entity reference processing. In particular, whether a 'compared' encoded entity reference should be replaced by its content, split into an 'old' and 'new' version on detection of change, or left with the full change information. This method is intended for expert use and should typically be left on automatic, as this configures it appropriately for non-specialist use cases (i.e. cases where the input and output preservation setting are consistent). The four modes are interpreted as follows:
- split - encoded entity references have their replacement text removed and are split into 'new' and 'old' versions on detection of change.
- replace - encoded entity references are converted to their replacement text values.
- change - encoded entity references are left encoded (i.e. skipped over).
- auto - if encoded entity references exist then treat as 'true', else treat as 'change'.
Note that entity references are being encoded if, and only if,
getPreservedEntityReferences()returns true. And that the entity replacement text is kept within an encoded entity reference when thegetPreserveEntityReplacementText()method returns true.Warning: specifying that the encoded entity replacement text should be used, when it does not exist (see not above) will result in neither the entity reference or its replacement text appearing in the output.
- Parameters:
usageMode- theAdvancedEntityRefUsageto use for entity references
-
getAdvancedEntityReferenceUsage
Return whether entity references or their replacement text appear in the output. See the setter method for the interpretation of the four potential values.- Returns:
- an
AdvancedEntityRefUsagewhich states whether entity references or their replacement text will be output.
-
setDefaultOutputType
Set the defaultPreservationOutputTypefor changes to preserved items.- Parameters:
type- the defaultPreservationOutputTypeto use for changes to preserved items
-
getDefaultOutputType
Return the current defaultPreservationOutputTypefor preserved items.- Returns:
- the default
PreservationOutputTypedetailing how preserved items will be output
-
setCDATAOutputType
Set thePreservationOutputTypefor changes to CDATA sections.- Parameters:
type- thePreservationOutputTypeto use for changes to CDATA sections
-
getCDATAOutputType
Return the currentPreservationOutputTypefor CDATA sections.- Returns:
- an
PreservationOutputTypedetailing how CDATA sections will be output
-
setCommentOutputType
Set thePreservationOutputTypefor changes to comments.- Parameters:
type- thePreservationOutputTypeto use for changes to comments
-
getCommentOutputType
Return the currentPreservationOutputTypefor comments.- Returns:
- an
PreservationOutputTypedetailing how comments will be output
-
setIgnorableWhitespaceOutputType
Set thePreservationOutputTypefor changes to ignorable whitespace.- Parameters:
type- thePreservationOutputTypeto use for changes to ignorable whitespace
-
getIgnorableWhitespaceOutputType
Return the currentPreservationOutputTypefor ignorable whitespace.- Returns:
- an
PreservationOutputTypedetailing how ignorable whitespace will be output
-
setDefaultAttributeInfoOutputType
Set thePreservationOutputTypefor changes to defaulted attributes.- Parameters:
type- thePreservationOutputTypeto use for changes to defaulted attributes
-
getDefaultedAttributeInfoOutputType
Return the currentPreservationOutputTypefor defaulted attributes.- Returns:
- an
PreservationOutputTypedetailing how defaulted attributes will be output
-
setDoctypeOutputType
Set thePreservationOutputTypefor changes to document type (and internal subset).- Parameters:
type- thePreservationOutputTypeto use for changes to document type (and internal subset)
-
getDoctypeOutputType
Return the currentPreservationOutputTypefor document type (and internal subset).- Returns:
- an
PreservationOutputTypedetailing how document type (and internal subset) will be output
-
setOuterPiAndCommentOutputType
Set thePreservationOutputTypeto use for changes to processing instructions and comments outside the root element (and outside the internal subset).- Parameters:
type- thePreservationOutputTypeto use for changes to processing instructions and comments outside the root element.
-
getOuterPiAndCommentOutputType
Return thePreservationOutputTypeto use for changes to processing instructions and comments outside the root element (and outside the internal subset).- Returns:
- a
PreservationOutputTypedetailing how changes to processing instructions and comments outside the root element will be output.
-
setEntityRefOutputType
Set thePreservationOutputTypefor changes to entity references.- Parameters:
type- thePreservationOutputTypeto use for changes to entity references
-
getEntityRefOutputType
Return the currentPreservationOutputTypefor entity references.- Returns:
- an
PreservationOutputTypedetailing how entity references will be output
-
setProcessingInstructionOutputType
Set thePreservationOutputTypefor changes to processing instructions.- Parameters:
type- thePreservationOutputTypeto use for changes to processing instructions
-
getProcessingInstructionOutputType
Return the currentPreservationOutputTypefor processing instructions.- Returns:
- an
PreservationOutputTypedetailing how processing instructions will be output
-
setXMLDeclarationOutputType
Set thePreservationOutputTypefor changes to XML declaration.- Parameters:
type- thePreservationOutputTypeto use for changes to XML declaration
-
getXMLDeclarationOutputType
Return the currentPreservationOutputTypefor XML declaration.- Returns:
- an
PreservationOutputTypedetailing how XML declaration will be output
-
toPreserveItemEnumSet
This method is for internal use.
- Returns:
- an EnumSet representation of the input items configured to be preserved.
-