Class SelectedElementsSpaceStrippingRule

  • All Implemented Interfaces:
    SpaceStrippingRule

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

      • SelectedElementsSpaceStrippingRule

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

      • 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
      • 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 java.util.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