@Override public void append(Item item, Location locationId, int copyNamespaces) throws XPathException { if (isSignificant(item)) { start(); } super.append(item, locationId, copyNamespaces); }
@Override public void append(Item item, Location locationId, int copyNamespaces) throws XPathException { if (isSignificant(item)) { start(); } super.append(item, locationId, copyNamespaces); }
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; }
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; }