| 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 retains all whitespace text nodes |
| 19 | */ |
| 20 | |
| 21 | public class NoElementsSpaceStrippingRule implements SpaceStrippingRule { |
| 22 | |
| 23 | private final static NoElementsSpaceStrippingRule THE_INSTANCE = new NoElementsSpaceStrippingRule(); |
| 24 | |
| 25 | public static NoElementsSpaceStrippingRule getInstance() { |
| 26 | return THE_INSTANCE; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Decide whether an element is in the set of white-space preserving element types |
| 31 | * |
| 32 | * @param fingerprint identifies the element being tested |
| 33 | * @param schemaType |
| 34 | * @return STRIP_DEFAULT: strip spaces unless xml:space tells you not to. |
| 35 | */ |
| 36 | |
| 37 | public int isSpacePreserving(NodeName fingerprint, SchemaType schemaType) { |
| 38 | return Stripper.ALWAYS_PRESERVE; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Make a filter to implement these space-stripping rules, or null if no filtering |
| 43 | * is necessary |
| 44 | * |
| 45 | * @param next the Receiver that is to receiver the filtered event stream |
| 46 | * @return a filter in the form of a ProxyReceiver, or null |
| 47 | */ |
| 48 | @Override |
| 49 | public ProxyReceiver makeStripper(Receiver next) { |
| 50 | return null; |
| 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.none"); |
| 60 | presenter.endElement(); |
| 61 | } |
| 62 | } |
| 63 |