net.sf.saxon.event
Class RuleBasedStripper

java.lang.Object
  extended by net.sf.saxon.event.SequenceReceiver
      extended by net.sf.saxon.event.ProxyReceiver
          extended by net.sf.saxon.event.Stripper
              extended by net.sf.saxon.event.RuleBasedStripper
All Implemented Interfaces:
Result, Receiver

public class RuleBasedStripper
extends Stripper

The RuleBasedStripper class performs whitespace stripping according to the rules of the xsl:strip-space and xsl:preserve-space instructions. It 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

Nested Class Summary
static class RuleBasedStripper.StripRuleTarget
           
 
Field Summary
static RuleBasedStripper.StripRuleTarget PRESERVE
           
static RuleBasedStripper.StripRuleTarget STRIP
           
 
Fields inherited from class net.sf.saxon.event.Stripper
ALWAYS_PRESERVE, ALWAYS_STRIP, CANNOT_STRIP, PRESERVE_PARENT, STRIP_DEFAULT
 
Fields inherited from class net.sf.saxon.event.ProxyReceiver
nextReceiver
 
Fields inherited from class net.sf.saxon.event.SequenceReceiver
pipelineConfiguration, previousAtomic, systemId
 
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
 
Constructor Summary
RuleBasedStripper()
          Default constructor for use in subclasses
RuleBasedStripper(StripSpaceRules stripperRules)
          create a Stripper and initialise variables
 
Method Summary
 RuleBasedStripper getAnother()
          Get a clean copy of this stripper.
 byte isSpacePreserving(int fingerprint)
          Decide whether an element is in the set of white-space preserving element names
 
Methods inherited from class net.sf.saxon.event.Stripper
attribute, characters, endElement, open, startElement, usesTypeAnnotations
 
Methods inherited from class net.sf.saxon.event.ProxyReceiver
append, close, comment, endDocument, getConfiguration, getDocumentLocator, getNamePool, getUnderlyingReceiver, namespace, processingInstruction, setPipelineConfiguration, setSystemId, setUnderlyingReceiver, setUnparsedEntity, startContent, startDocument
 
Methods inherited from class net.sf.saxon.event.SequenceReceiver
append, getPipelineConfiguration, getSystemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRIP

public static final RuleBasedStripper.StripRuleTarget STRIP

PRESERVE

public static final RuleBasedStripper.StripRuleTarget PRESERVE
Constructor Detail

RuleBasedStripper

public RuleBasedStripper()
Default constructor for use in subclasses


RuleBasedStripper

public RuleBasedStripper(StripSpaceRules stripperRules)
create a Stripper and initialise variables

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

getAnother

public RuleBasedStripper getAnother()
Get a clean copy of this stripper. The new copy shares the same PipelineConfiguration as the original, but the underlying receiver (that is, the destination for post-stripping events) is left uninitialized.

Specified by:
getAnother in class Stripper

isSpacePreserving

public byte isSpacePreserving(int fingerprint)
                       throws XPathException
Decide whether an element is in the set of white-space preserving element names

Specified by:
isSpacePreserving in class Stripper
Parameters:
fingerprint - 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
Throws:
XPathException - if the rules are ambiguous and ambiguities are to be reported as errors


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.