In the current JAXB RI, developed by Sun, there is a series of "proprietary" JAXB extensions which provide advanced functionality outside of the JAXB specification (these extension classes and properties reside in the '''com.sun.xml.bind''' package).

In the current JAXB RI, developed by Sun, there is a series of "proprietary" JAXB extensions which provide advanced functionality outside of the JAXB specification (these extension classes and properties reside in the '''com.sun.xml.bind''' package).

The '''CharacterEscapeHandler''' interface provided in the Sun JAXB implementation allows users to write their own character escaping code, to be used when marshalling.

The '''CharacterEscapeHandler''' interface provided in the Sun JAXB implementation allows users to write their own character escaping code, to be used when marshalling.

−

−

This document will outline the design for an EclipseLink equivalent to this extension.

Line 37:

Line 33:

m.setProperty(MarshallerProperties.CHARACTER_ESCAPE_HANDLER, new MyHandler());

m.setProperty(MarshallerProperties.CHARACTER_ESCAPE_HANDLER, new MyHandler());

...

...

−

</source>

−

</div>

−

−

The '''CharacterEscapeHandler''' cannot be null. If you need to re-set the '''CharacterEscapeHandler''' back to the EclipseLink default, use the following handler class:

Latest revision as of 11:36, 18 June 2012

Contents

Character Escape Handler

In the current JAXB RI, developed by Sun, there is a series of "proprietary" JAXB extensions which provide advanced functionality outside of the JAXB specification (these extension classes and properties reside in the com.sun.xml.bind package).

The CharacterEscapeHandler interface provided in the Sun JAXB implementation allows users to write their own character escaping code, to be used when marshalling.

Behaviour

If a custom CharacterEscapeHandler is set, then that class will be responsible for all character escaping during marshal operations.

Custom escape handling is not supported when marshalling to the following targets:

javax.xml.stream.XMLStreamWriter

javax.xml.stream.XMLEventWriter

org.xml.sax.ContentHandler

org.w3c.dom.Node

Configuration

Your custom handler should be an implementation of the org.eclipse.persistence.oxm.CharacterEscapeHandler interface.

A custom CharacterEscapeHandler can be specified on a Marshaller using the setProperty() method: