Class ElementTransformingFragmentTransformer
- java.lang.Object
-
- com.atlassian.confluence.content.render.xhtml.transformers.ElementTransformingFragmentTransformer
-
- All Implemented Interfaces:
FragmentTransformer
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 Summary
Constructors Constructor Description ElementTransformingFragmentTransformer(List<ElementTransformer> elementTransformers, Set<QName> handledNames)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
ElementTransformingFragmentTransformer
public ElementTransformingFragmentTransformer(List<ElementTransformer> elementTransformers, Set<QName> handledNames)
-
-
Method Detail
-
handles
public boolean handles(StartElement startElementEvent, ConversionContext conversionContext)
- Specified by:
handles
in interfaceFragmentTransformer
- Returns:
- true for any StartElement QName that is returned by the configured Set of ElementTransformer.
-
transform
public Streamable transform(XMLEventReader reader, FragmentTransformer mainFragmentTransformer, ConversionContext conversionContext) throws XhtmlException
Wraps the supplied reader in an ElementTransformingXmlEventReader and then applies the mainFragmentTransformer.- Specified by:
transform
in interfaceFragmentTransformer
- Throws:
XhtmlException
-
-