Class SelectedElementsSpaceStrippingRule

java.lang.Object
net.sf.saxon.om.SelectedElementsSpaceStrippingRule
All Implemented Interfaces:
SpaceStrippingRule

public class SelectedElementsSpaceStrippingRule extends Object implements SpaceStrippingRule
A whitespace stripping rule that strips elected elements unless xml:space indicates that whitespace should be preserved.
  • Constructor Details

    • SelectedElementsSpaceStrippingRule

      public SelectedElementsSpaceStrippingRule(boolean rejectDuplicates)
      Create the ruleset
      Parameters:
      rejectDuplicates - indicates whether duplicate conflicting rules are a static error
  • Method Details

    • isSpacePreserving

      public int isSpacePreserving(NodeName fingerprint, SchemaType schemaType) throws XPathException
      Decide whether an element is in the set of white-space preserving element names
      Specified by:
      isSpacePreserving in interface SpaceStrippingRule
      Parameters:
      fingerprint - identifies the name of the element whose whitespace is to be preserved
      schemaType - the type annotation of the element
      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
    • addRule

      public void addRule(NodeTest test, Stripper.StripRuleTarget action, StylesheetModule module, int lineNumber) throws XPathException
      Add a rule
      Parameters:
      test - a NodeTest (*, *:local, prefix:*, or QName)
      action - StripRuleTarget.STRIP or StripRuleTarget.PRESERVE
      module - the stylesheet module containing the rule
      lineNumber - the line where the strip-space or preserve-space instruction appears
      Throws:
      XPathException - if this rule is a conflicting duplicate
    • addRule

      public void addRule(NodeTestPattern pattern, Stripper.StripRuleTarget action, int precedence, int minImportPrecedence) throws XPathException
      Throws:
      XPathException
    • getRule

      public Rule getRule(NodeName nodeName)
      Get the rule corresponding to a given element node, by finding the best pattern match.
      Parameters:
      nodeName - the name of the element node to be matched
      Returns:
      the best matching rule, if any (otherwise null).
    • getRankedRules

      public Iterator<Rule> getRankedRules()
      Get all the rules in rank order, highest-ranking rules first
      Returns:
      the rules in rank order
    • makeStripper

      public ProxyReceiver makeStripper(Receiver next)
      Make a filter to implement these space-stripping rules, or null if no filtering is necessary
      Specified by:
      makeStripper in interface SpaceStrippingRule
      Parameters:
      next - the Receiver that is to receive the filtered event stream
      Returns:
      a filter in the form of a ProxyReceiver, or null
    • export

      public void export(ExpressionPresenter presenter) throws XPathException
      Export this rule as part of an exported stylesheet
      Specified by:
      export in interface SpaceStrippingRule
      Parameters:
      presenter - the output handler
      Throws:
      XPathException - if an error is detected