/** * Make a filter to implement these space-stripping rules, or null if no filtering * is necessary * * @return a filter in the form of a ProxyReceiver, or null */ @Override public ProxyReceiver makeStripper(Receiver next) { return new Stripper(this, next); }
/** * Copy this node to a given outputter (deep copy) */ public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException { // The underlying code does not do whitespace stripping. So we need to interpose // a stripper. Stripper stripper = docWrapper.getStripper().getAnother(); stripper.setUnderlyingReceiver(out); node.copy(stripper, whichNamespaces, copyAnnotations, locationId); }
/** * Get a clean copy of this stripper */ public Stripper getAnother() { Stripper clone = new Stripper(stripperMode); clone.setPipelineConfiguration(getPipelineConfiguration()); clone.stripAll = stripAll; clone.preserveAll = preserveAll; return clone; }
} else { Stripper s = new AllElementStripper(); s.setUnderlyingReceiver(b); s.setPipelineConfiguration(b.getPipelineConfiguration()); return s; stripper = new Stripper(new Mode(Mode.STRIPPER_MODE, Mode.DEFAULT_MODE_NAME)); } else { stripper = executable.newStripper(); stripper.setXPathContext(newXPathContext()); if (b == null) { stripper.setPipelineConfiguration(makePipelineConfiguration()); } else { stripper.setPipelineConfiguration(b.getPipelineConfiguration()); stripper.setUnderlyingReceiver(b);
/** * Override the behaviour of startDocument() in ReceivingContentHandler */ public void startDocument() throws SAXException { if (result==null) { result = new StreamResult(System.out); } try { Properties props = controller.getOutputProperties(); PipelineConfiguration pipe = controller.makePipelineConfiguration(); Configuration config = getConfiguration(); SerializerFactory sf = config.getSerializerFactory(); Receiver out = sf.getReceiver(result, pipe, props); setPipelineConfiguration(pipe); int stripSpace = config.getStripsWhiteSpace(); if (stripSpace == Whitespace.ALL) { Stripper s = new AllElementStripper(); s.setStripAll(); s.setPipelineConfiguration(pipe); s.setUnderlyingReceiver(out); out = s; } setReceiver(out); } catch (XPathException err) { throw new SAXException(err); } super.startDocument(); }
public void startElement (int nameCode, int typeCode, int locationId, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(nameCode, typeCode, locationId, properties); byte preserveParent = stripStack[top]; byte preserve = (byte)(preserveParent & PRESERVE_PARENT); byte elementStrip = isSpacePreserving(nameCode); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (preserve == 0 && typeCode != -1 && typeCode != StandardNames.XS_UNTYPED) { // if the element has simple content, whitespace stripping is disabled SchemaType type = getConfiguration().getSchemaType(typeCode); if (type.isSimpleType() || ((ComplexType)type).isSimpleContent()) { preserve |= CANNOT_STRIP; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { byte[] newStack = new byte[top*2]; System.arraycopy(stripStack, 0, newStack, 0, top); stripStack = newStack; } stripStack[top] = preserve; }
public void startElement(NodeName elemName, SchemaType type, Location location, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(elemName, type, location, properties); byte preserveParent = stripStack[top]; byte preserve = (byte) (preserveParent & (PRESERVE_PARENT | ASSERTIONS_EXIST)); int elementStrip = isSpacePreserving(elemName, type); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (type != Untyped.getInstance()) { if (preserve == 0) { // if the element has simple content, whitespace stripping is disabled if (type.isSimpleType() || ((ComplexType) type).isSimpleContent()) { preserve |= SIMPLE_CONTENT; } } if (type instanceof ComplexType && ((ComplexType) type).hasAssertions()) { preserve |= ASSERTIONS_EXIST; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { stripStack = Arrays.copyOf(stripStack, top * 2); } stripStack[top] = preserve; }
stripper.setUnderlyingReceiver(b); receiver = stripper;
case Whitespace.ALL: { Stripper stripper = AllElementStripper.getInstance(); stripper.setStripAll(); source = AugmentedSource.makeAugmentedSource(source); ((AugmentedSource)source).addFilter(stripper);
} else { Stripper s = new AllElementStripper(); s.setUnderlyingReceiver(b); s.setPipelineConfiguration(b.getPipelineConfiguration()); return s; stripper = new Stripper(new Mode(Mode.STRIPPER_MODE, Mode.DEFAULT_MODE_NAME)); } else { stripper = executable.newStripper(); stripper.setXPathContext(newXPathContext()); if (b == null) { stripper.setPipelineConfiguration(makePipelineConfiguration()); } else { stripper.setPipelineConfiguration(b.getPipelineConfiguration()); stripper.setUnderlyingReceiver(b);
s.setStripAll(); s.setPipelineConfiguration(pipe); s.setUnderlyingReceiver(receiver); next = s; } else if (stripSpace == Whitespace.XSLT) {
public void startElement (int nameCode, int typeCode, int locationId, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(nameCode, typeCode, locationId, properties); byte preserveParent = stripStack[top]; byte preserve = (byte)(preserveParent & PRESERVE_PARENT); byte elementStrip = isSpacePreserving(nameCode); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (preserve == 0 && typeCode != -1 && typeCode != StandardNames.XS_UNTYPED) { // if the element has simple content, whitespace stripping is disabled SchemaType type = getConfiguration().getSchemaType(typeCode); if (type.isSimpleType() || ((ComplexType)type).isSimpleContent()) { preserve |= CANNOT_STRIP; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { byte[] newStack = new byte[top*2]; System.arraycopy(stripStack, 0, newStack, 0, top); stripStack = newStack; } stripStack[top] = preserve; }
public void startElement(NodeName elemName, SchemaType type, Location location, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(elemName, type, location, properties); byte preserveParent = stripStack[top]; byte preserve = (byte) (preserveParent & (PRESERVE_PARENT | ASSERTIONS_EXIST)); int elementStrip = isSpacePreserving(elemName, type); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (type != Untyped.getInstance()) { if (preserve == 0) { // if the element has simple content, whitespace stripping is disabled if (type.isSimpleType() || ((ComplexType) type).isSimpleContent()) { preserve |= SIMPLE_CONTENT; } } if (type instanceof ComplexType && ((ComplexType) type).hasAssertions()) { preserve |= ASSERTIONS_EXIST; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { stripStack = Arrays.copyOf(stripStack, top * 2); } stripStack[top] = preserve; }
stripper.setUnderlyingReceiver(b); receiver = stripper;
case Whitespace.ALL: { Stripper stripper = AllElementStripper.getInstance(); stripper.setStripAll(); source = AugmentedSource.makeAugmentedSource(source); ((AugmentedSource)source).addFilter(stripper);
/** * Make a filter to implement these space-stripping rules, or null if no filtering * is necessary * * @return a filter in the form of a ProxyReceiver, or null */ @Override public ProxyReceiver makeStripper(Receiver next) { return new Stripper(this, next); }
/** * Get a clean copy of this stripper */ public Stripper getAnother() { Stripper clone = new Stripper(stripperMode); clone.setPipelineConfiguration(getPipelineConfiguration()); clone.stripAll = stripAll; clone.preserveAll = preserveAll; return clone; }
if (stripSpace == Whitespace.ALL) { Stripper s = new AllElementStripper(); s.setStripAll(); s.setPipelineConfiguration(pipe); s.setUnderlyingReceiver(receiver); next = s; } else if (stripSpace == Whitespace.XSLT) {
public void startElement (int nameCode, int typeCode, int locationId, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(nameCode, typeCode, locationId, properties); byte preserveParent = stripStack[top]; byte preserve = (byte)(preserveParent & PRESERVE_PARENT); byte elementStrip = isSpacePreserving(nameCode); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (preserve == 0 && typeCode != -1 && typeCode != StandardNames.XS_UNTYPED) { // if the element has simple content, whitespace stripping is disabled SchemaType type = getConfiguration().getSchemaType(typeCode); if (type.isSimpleType() || ((ComplexType)type).isSimpleContent()) { preserve |= CANNOT_STRIP; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { byte[] newStack = new byte[top*2]; System.arraycopy(stripStack, 0, newStack, 0, top); stripStack = newStack; } stripStack[top] = preserve; }
if (docWrapper.getStripper().isSpacePreserving(actualParent) == Stripper.ALWAYS_PRESERVE) { return true;