| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.om; |
| 9 |
|
| 10 |
|
| 11 |
import net.sf.saxon.event.IgnorableWhitespaceStripper; |
| 12 |
import net.sf.saxon.event.ProxyReceiver; |
| 13 |
import net.sf.saxon.event.Receiver; |
| 14 |
import net.sf.saxon.event.Stripper; |
| 15 |
import net.sf.saxon.trace.ExpressionPresenter; |
| 16 |
import net.sf.saxon.type.ComplexType; |
| 17 |
import net.sf.saxon.type.SchemaType; |
| 18 |
import net.sf.saxon.type.Untyped; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public class IgnorableSpaceStrippingRule implements SpaceStrippingRule { |
| 26 |
|
| 27 |
private final static IgnorableSpaceStrippingRule THE_INSTANCE = new IgnorableSpaceStrippingRule(); |
| 28 |
|
| 29 |
public static IgnorableSpaceStrippingRule getInstance() { |
| 30 |
return THE_INSTANCE; |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public int isSpacePreserving(NodeName name, SchemaType schemaType) { |
| 42 |
if (schemaType != Untyped.getInstance() && schemaType.isComplexType() && |
| 43 |
!((ComplexType) schemaType).isSimpleContent() && |
| 44 |
!((ComplexType) schemaType).isMixedContent()) { |
| 45 |
return Stripper.ALWAYS_STRIP; |
| 46 |
} else { |
| 47 |
return Stripper.ALWAYS_PRESERVE; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
@Override |
| 58 |
public ProxyReceiver makeStripper(Receiver next) { |
| 59 |
return new IgnorableWhitespaceStripper(next); |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public void export(ExpressionPresenter presenter) { |
| 69 |
presenter.startElement("strip.ignorable"); |
| 70 |
presenter.endElement(); |
| 71 |
} |
| 72 |
} |
| 73 |
|