| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 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 |
import java.util.Arrays; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
public class StylesheetSpaceStrippingRule implements SpaceStrippingRule { |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
private static final int[] specials = { |
| 30 |
StandardNames.XSL_ANALYZE_STRING, |
| 31 |
StandardNames.XSL_APPLY_IMPORTS, |
| 32 |
StandardNames.XSL_APPLY_TEMPLATES, |
| 33 |
StandardNames.XSL_ATTRIBUTE_SET, |
| 34 |
StandardNames.XSL_CALL_TEMPLATE, |
| 35 |
StandardNames.XSL_CHARACTER_MAP, |
| 36 |
StandardNames.XSL_CHOOSE, |
| 37 |
StandardNames.XSL_EVALUATE, |
| 38 |
StandardNames.XSL_MERGE, |
| 39 |
StandardNames.XSL_MERGE_SOURCE, |
| 40 |
StandardNames.XSL_NEXT_ITERATION, |
| 41 |
StandardNames.XSL_NEXT_MATCH, |
| 42 |
StandardNames.XSL_STYLESHEET, |
| 43 |
StandardNames.XSL_TRANSFORM |
| 44 |
}; |
| 45 |
|
| 46 |
private NamePool namePool; |
| 47 |
|
| 48 |
public StylesheetSpaceStrippingRule(NamePool pool) { |
| 49 |
this.namePool = pool; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public int isSpacePreserving( NodeName elementName, SchemaType schemaType) { |
| 59 |
int fingerprint = elementName.obtainFingerprint(namePool); |
| 60 |
if (fingerprint == (StandardNames.XSL_TEXT & NamePool.FP_MASK)) { |
| 61 |
return Stripper.ALWAYS_PRESERVE; |
| 62 |
} |
| 63 |
|
| 64 |
if (Arrays.binarySearch(specials, fingerprint) >= 0) { |
| 65 |
return Stripper.ALWAYS_STRIP; |
| 66 |
} |
| 67 |
|
| 68 |
return Stripper.STRIP_DEFAULT; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
@Override |
| 78 |
public ProxyReceiver makeStripper(Receiver next) { |
| 79 |
return new Stripper(this, next); |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
public void export(ExpressionPresenter presenter) { |
| 88 |
|
| 89 |
} |
| 90 |
} |
| 91 |
|