public class ElementTransformingFragmentTransformer extends Object implements FragmentTransformer
A FragmentTransformer that can be configured to transform individual Elements it reads.
Typically you would configure ElementTransformers directly on the DefaultFragmentTransformer to transform individual elements but this FragmentTransformer can be used when you want to reduce the scope of the ElementTransform to just a Fragment of the full XML document being read.
This FragmentTransformer makes use of the ConversionContext to store a flag which ensures that this transformer instance will only apply once per ConversionContext. (There is no point in transforming elements multiple times and it could lead to infinite loops if we didn't consume the triggering event. If we do consume the triggering event then the mainFragmentTransformer will fail because it will encounter the closing event without having seen the opening event.)
Rather than having multiple ElementTransformingFragmentTransformer in the pipeline it would be preferable to have only a single one if possible but instead with multiple ElementTransformers configured.
Constructor and Description |
---|
ElementTransformingFragmentTransformer(List<ElementTransformer> elementTransformers,
Set<QName> handledNames) |
Modifier and Type | Method and Description |
---|---|
boolean |
handles(StartElement startElementEvent,
ConversionContext conversionContext) |
Streamable |
transform(XMLEventReader reader,
FragmentTransformer mainFragmentTransformer,
ConversionContext conversionContext)
Wraps the supplied reader in an ElementTransformingXmlEventReader and then applies the mainFragmentTransformer.
|
public ElementTransformingFragmentTransformer(List<ElementTransformer> elementTransformers, Set<QName> handledNames)
public boolean handles(StartElement startElementEvent, ConversionContext conversionContext)
handles
in interface FragmentTransformer
public Streamable transform(XMLEventReader reader, FragmentTransformer mainFragmentTransformer, ConversionContext conversionContext) throws XhtmlException
transform
in interface FragmentTransformer
XhtmlException
Copyright © 2003–2020 Atlassian. All rights reserved.