@Override public void append(Item item, Location locationId, int copyNamespaces) throws XPathException { if (isSignificant(item)) { start(); } super.append(item, locationId, copyNamespaces); }
@Override public void startElement(NodeName elemName, SchemaType typeCode, Location location, int properties) throws XPathException { start(); level++; super.startElement(elemName, typeCode, location, properties); }
public static boolean isSignificant(Item item) { if (item instanceof NodeInfo) { NodeInfo node = (NodeInfo) item; return (node.getNodeKind() != Type.TEXT || !node.getStringValue().isEmpty()) && (node.getNodeKind() != Type.DOCUMENT || node.hasChildNodes()); } else if (item instanceof AtomicValue) { return !item.getStringValue().isEmpty(); } else if (item instanceof ArrayItem) { if (((ArrayItem) item).isEmpty()) { return true; } else { for (Sequence<?> mem : ((ArrayItem) item).members()) { try { SequenceIterator<?> memIter = mem.iterate(); Item it; while ((it = memIter.next()) != null) { if (isSignificant(it)) { return true; } } } catch (XPathException e) { return true; } } return false; } } return true; }
SignificantItemDetector significantItemDetector = new SignificantItemDetector(context.getReceiver(), action); c2.setReceiver(significantItemDetector); for (Operand o : operands()) { if (significantItemDetector.isEmpty()) { onNonEmptyPending.add((OnNonEmptyExpr)child); } else { if (significantItemDetector.isEmpty()) { for (Operand o : operands()) { Expression child = o.getChildExpression();
@Override public void attribute(NodeName nameCode, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException { start(); super.attribute(nameCode, typeCode, value, locationId, properties); }
public static boolean isSignificant(Item item) { if (item instanceof NodeInfo) { NodeInfo node = (NodeInfo) item; return (node.getNodeKind() != Type.TEXT || !node.getStringValue().isEmpty()) && (node.getNodeKind() != Type.DOCUMENT || node.hasChildNodes()); } else if (item instanceof AtomicValue) { return !item.getStringValue().isEmpty(); } else if (item instanceof ArrayItem) { if (((ArrayItem) item).isEmpty()) { return true; } else { for (Sequence<?> mem : ((ArrayItem) item).members()) { try { SequenceIterator<?> memIter = mem.iterate(); Item it; while ((it = memIter.next()) != null) { if (isSignificant(it)) { return true; } } } catch (XPathException e) { return true; } } return false; } } return true; }
SignificantItemDetector significantItemDetector = new SignificantItemDetector(context.getReceiver(), action); c2.setReceiver(significantItemDetector); for (Operand o : operands()) { if (significantItemDetector.isEmpty()) { onNonEmptyPending.add((OnNonEmptyExpr)child); } else { if (significantItemDetector.isEmpty()) { for (Operand o : operands()) { Expression child = o.getChildExpression();
@Override public void characters(CharSequence chars, Location locationId, int properties) throws XPathException { if (chars.length() > 0) { start(); } super.characters(chars, locationId, properties); }
@Override public void append(Item item, Location locationId, int copyNamespaces) throws XPathException { if (isSignificant(item)) { start(); } super.append(item, locationId, copyNamespaces); }
@Override public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException { start(); super.processingInstruction(target, data, locationId, properties); }
@Override public void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException { start(); super.namespace(namespaceBindings, properties); }
@Override public void comment(CharSequence chars, Location locationId, int properties) throws XPathException { start(); super.comment(chars, locationId, properties); }
@Override public void startElement(NodeName elemName, SchemaType typeCode, Location location, int properties) throws XPathException { start(); level++; super.startElement(elemName, typeCode, location, properties); }
@Override public void attribute(NodeName nameCode, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException { start(); super.attribute(nameCode, typeCode, value, locationId, properties); }
@Override public void characters(CharSequence chars, Location locationId, int properties) throws XPathException { if (chars.length() > 0) { start(); } super.characters(chars, locationId, properties); }
@Override public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException { start(); super.processingInstruction(target, data, locationId, properties); }
@Override public void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException { start(); super.namespace(namespaceBindings, properties); }
@Override public void comment(CharSequence chars, Location locationId, int properties) throws XPathException { start(); super.comment(chars, locationId, properties); }