net.sf.saxon.event

Class Stripper

public class Stripper extends ProxyReceiver

The Stripper class maintains details of which elements need to be stripped. The code is written to act as a SAX-like filter to do the stripping.

Author: Michael H. Kay

Field Summary
static byteALWAYS_PRESERVE
static byteALWAYS_STRIP
static byteCANNOT_STRIP
static bytePRESERVE_PARENT
static byteSTRIP_DEFAULT
Constructor Summary
protected Stripper()
Default constructor for use in subclasses
Stripper(Mode stripperRules)
create a Stripper and initialise variables
Method Summary
voidattribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
voidcharacters(CharSequence chars, int locationId, int properties)
Handle a text node
voidendElement()
Handle an end-of-element event
StrippergetAnother()
Get a clean copy of this stripper
booleangetStripAll()
Determine if all whitespace is to be stripped (in this case, no further testing is needed)
byteisSpacePreserving(int nameCode)
Decide whether an element is in the set of white-space preserving element types
byteisSpacePreserving(NodeInfo element)
Decide whether an element is in the set of white-space preserving element types.
voidopen()
Callback interface for SAX: not for application use
voidsetPipelineConfiguration(PipelineConfiguration pipe)
voidsetStripAll()
Specify that all whitespace nodes are to be stripped
voidstartElement(int nameCode, int typeCode, int locationId, int properties)

Field Detail

ALWAYS_PRESERVE

public static final byte ALWAYS_PRESERVE

ALWAYS_STRIP

public static final byte ALWAYS_STRIP

CANNOT_STRIP

public static final byte CANNOT_STRIP

PRESERVE_PARENT

public static final byte PRESERVE_PARENT

STRIP_DEFAULT

public static final byte STRIP_DEFAULT

Constructor Detail

Stripper

protected Stripper()
Default constructor for use in subclasses

Stripper

public Stripper(Mode stripperRules)
create a Stripper and initialise variables

Parameters: stripperRules defines which elements have whitespace stripped. If null, all whitespace is preserved.

Method Detail

attribute

public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)

characters

public void characters(CharSequence chars, int locationId, int properties)
Handle a text node

endElement

public void endElement()
Handle an end-of-element event

getAnother

public Stripper getAnother()
Get a clean copy of this stripper

getStripAll

public boolean getStripAll()
Determine if all whitespace is to be stripped (in this case, no further testing is needed)

isSpacePreserving

public byte isSpacePreserving(int nameCode)
Decide whether an element is in the set of white-space preserving element types

Parameters: nameCode Identifies the name of the element whose whitespace is to be preserved

Returns: ALWAYS_PRESERVE if the element is in the set of white-space preserving element types, ALWAYS_STRIP if the element is to be stripped regardless of the xml:space setting, and STRIP_DEFAULT otherwise

isSpacePreserving

public byte isSpacePreserving(NodeInfo element)
Decide whether an element is in the set of white-space preserving element types. This version of the method is useful in cases where getting the namecode of the element is potentially expensive, e.g. with DOM nodes.

Parameters: element Identifies the element whose whitespace is possibly to be preserved

Returns: ALWAYS_PRESERVE if the element is in the set of white-space preserving element types, ALWAYS_STRIP if the element is to be stripped regardless of the xml:space setting, and STRIP_DEFAULT otherwise

open

public void open()
Callback interface for SAX: not for application use

setPipelineConfiguration

public void setPipelineConfiguration(PipelineConfiguration pipe)

setStripAll

public void setStripAll()
Specify that all whitespace nodes are to be stripped

startElement

public void startElement(int nameCode, int typeCode, int locationId, int properties)