Debian Codegraph @

net/sf/saxon/om/AllElementsSpaceStrippingRule.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.om;
9
10
11 import net.sf.saxon.event.ProxyReceiver;
12 import net.sf.saxon.event.Receiver;
13 import net.sf.saxon.event.Stripper;
14 import net.sf.saxon.trace.ExpressionPresenter;
15 import net.sf.saxon.type.SchemaType;
16
17 /**
18 * A whitespace stripping rule that strips all elements unless xml:space indicates that whitespace
19 * should be preserved.
20 */
21
22 public class AllElementsSpaceStrippingRule implements SpaceStrippingRule {
23
24 private final static AllElementsSpaceStrippingRule THE_INSTANCE = new AllElementsSpaceStrippingRule();
25
26 public static AllElementsSpaceStrippingRule getInstance() {
27 return THE_INSTANCE;
28 }
29
30 /**
31 * Decide whether an element is in the set of white-space preserving element types
32 *
33 * @param fingerprint identifies the element being tested
34 * @param schemaType
35 * @return STRIP_DEFAULT: strip spaces unless xml:space tells you not to.
36 */
37
38 public int isSpacePreserving(NodeName fingerprint, SchemaType schemaType) {
39 return Stripper.STRIP_DEFAULT;
40 }
41
42 /**
43 * Make a filter to implement these space-stripping rules, or null if no filtering
44 * is necessary
45 *
46 * @return a filter in the form of a ProxyReceiver, or null
47 */
48 @Override
49 public ProxyReceiver makeStripper(Receiver next) {
50 return new Stripper(this, next);
51 }
52
53 /**
54 * Export this rule as part of an exported stylesheet
55 *
56 * @param presenter the output handler
57 */
58 public void export(ExpressionPresenter presenter) {
59 presenter.startElement("strip.all");
60 presenter.endElement();
61 }
62 }
63