To implement a SAXVisitor
geared towards transforming the serialized form of a fragment, program Smooks so the SAXVisitor
implementation will be writing to the StreamResult
. This is because Smooks supports targeting of multiple SAXVisitor
implementations at a single fragment, but only one SAXVisitor
is allowed to write to the StreamResult
, per fragment.
If a second SAXVisitor
attempts to write to the StreamResult
, a SAXWriterAccessException
will result and you will need to modify your Smooks configuration.
To specify the StreamResult
to write, the SAXVisitor
needs to "acquire ownership" of the Writer
to the StreamResult
. It does this by making a call to the SAXElement.getWriter(SAXVisitor)
method from inside the SAXVisitBefore.visitBefore
methods implementation, passing this
as the SAXVisitor
parameter.