public void processComment(XdmNode node) throws SaxonApiException { if (!inGroup.peek()) { matcher.addStartElement(wrapperCode, Untyped.getInstance(), null); } matcher.addComment(node.getStringValue()); if (groupAdjacent != null && nextMatches(node)) { inGroup.pop(); inGroup.push(true); } else { matcher.addEndElement(); inGroup.pop(); inGroup.push(false); } }
public void run() throws SaxonApiException { super.run(); RuntimeValue wrapperNameValue = getOption(_wrapper); String wrapperNameStr = wrapperNameValue.getString(); String wpfx = getOption(_wrapper_prefix, (String) null); String wns = getOption(_wrapper_namespace, (String) null); if (wpfx != null && wns == null) { throw XProcException.dynamicError(34, step.getNode(), "You can't specify a prefix without a namespace"); } if (wns != null && wrapperNameStr.contains(":")) { throw XProcException.dynamicError(34, step.getNode(), "You can't specify a namespace if the wrapper name contains a colon"); } if (wrapperNameStr.contains(":")) { wrapper = new QName(wrapperNameStr, wrapperNameValue.getNode()); } else { wrapper = new QName(wpfx == null ? "" : wpfx, wns, wrapperNameStr); } groupAdjacent = getOption(_group_adjacent); inGroup.push(false); XdmNode doc = source.read(); wrapperCode = new FingerprintedQName(wrapper.getPrefix(),wrapper.getNamespaceURI(),wrapper.getLocalName()); matcher = new ProcessMatch(runtime, this); matcher.match(doc,getOption(_match)); if (source.moreDocuments()) { throw XProcException.dynamicError(6, "Reading source on " + getStep().getName()); } result.write(matcher.getResult()); }
private boolean nextMatches(XdmNode node) { XdmItem nodeValue = computeGroup(node); if (nodeValue == null) { return false; } XdmSequenceIterator iter = node.axisIterator(Axis.FOLLOWING_SIBLING); while (iter.hasNext()) { XdmNode chk = (XdmNode) iter.next(); boolean skippable = (chk.getNodeKind() == XdmNodeKind.COMMENT || chk.getNodeKind() == XdmNodeKind.PROCESSING_INSTRUCTION); if (chk.getNodeKind() == XdmNodeKind.TEXT) { if ("".equals(chk.toString().trim())) { skippable = true; } } if (matcher.matches(chk)) { XdmItem nextValue = computeGroup(chk); boolean same = S9apiUtils.xpathEqual(runtime.getProcessor(), nodeValue, nextValue); return same; } if (!skippable) { return false; } } return false; }
public void run() throws SaxonApiException { super.run(); RuntimeValue wrapperNameValue = getOption(_wrapper); String wrapperNameStr = wrapperNameValue.getString(); String wpfx = getOption(_wrapper_prefix, (String) null); String wns = getOption(_wrapper_namespace, (String) null); if (wpfx != null && wns == null) { throw XProcException.dynamicError(34, step.getNode(), "You can't specify a prefix without a namespace"); } if (wns != null && wrapperNameStr.contains(":")) { throw XProcException.dynamicError(34, step.getNode(), "You can't specify a namespace if the wrapper name contains a colon"); } if (wrapperNameStr.contains(":")) { wrapper = new QName(wrapperNameStr, wrapperNameValue.getNode()); } else { wrapper = new QName(wpfx == null ? "" : wpfx, wns, wrapperNameStr); } groupAdjacent = getOption(_group_adjacent); inGroup.push(false); XdmNode doc = source.read(); wrapperCode = new FingerprintedQName(wrapper.getPrefix(),wrapper.getNamespaceURI(),wrapper.getLocalName()); matcher = new ProcessMatch(runtime, this); matcher.match(doc,getOption(_match)); if (source.moreDocuments()) { throw XProcException.dynamicError(6, "Reading source on " + getStep().getName()); } result.write(matcher.getResult()); }
private boolean nextMatches(XdmNode node) { XdmItem nodeValue = computeGroup(node); if (nodeValue == null) { return false; } XdmSequenceIterator iter = node.axisIterator(Axis.FOLLOWING_SIBLING); while (iter.hasNext()) { XdmNode chk = (XdmNode) iter.next(); boolean skippable = (chk.getNodeKind() == XdmNodeKind.COMMENT || chk.getNodeKind() == XdmNodeKind.PROCESSING_INSTRUCTION); if (chk.getNodeKind() == XdmNodeKind.TEXT) { if ("".equals(chk.toString().trim())) { skippable = true; } } if (matcher.matches(chk)) { XdmItem nextValue = computeGroup(chk); boolean same = S9apiUtils.xpathEqual(runtime.getProcessor(), nodeValue, nextValue); return same; } if (!skippable) { return false; } } return false; }
public boolean processStartElement(XdmNode node) throws SaxonApiException { if (!inGroup.peek()) { matcher.addStartElement(wrapperCode, Untyped.getInstance(), null); } if (groupAdjacent != null && nextMatches(node)) { inGroup.pop(); inGroup.push(true); } else { inGroup.pop(); inGroup.push(false); } matcher.addStartElement(node); matcher.addAttributes(node); inGroup.push(false); // processEndElement will pop it! Value doesn't matter! return true; }
public boolean processStartElement(XdmNode node) throws SaxonApiException { if (!inGroup.peek()) { matcher.addStartElement(wrapperCode, Untyped.getInstance(), null); } if (groupAdjacent != null && nextMatches(node)) { inGroup.pop(); inGroup.push(true); } else { inGroup.pop(); inGroup.push(false); } matcher.addStartElement(node); matcher.addAttributes(node); inGroup.push(false); // processEndElement will pop it! Value doesn't matter! return true; }
public void processText(XdmNode node) throws SaxonApiException { if (!inGroup.peek()) { matcher.addStartElement(wrapperCode, Untyped.getInstance(), null); } matcher.addText(node.getStringValue()); if (groupAdjacent != null && nextMatches(node)) { inGroup.pop(); inGroup.push(true); } else { matcher.addEndElement(); inGroup.pop(); inGroup.push(false); } }
public void processComment(XdmNode node) throws SaxonApiException { if (!inGroup.peek()) { matcher.addStartElement(wrapperCode, Untyped.getInstance(), null); } matcher.addComment(node.getStringValue()); if (groupAdjacent != null && nextMatches(node)) { inGroup.pop(); inGroup.push(true); } else { matcher.addEndElement(); inGroup.pop(); inGroup.push(false); } }
public void processText(XdmNode node) throws SaxonApiException { if (!inGroup.peek()) { matcher.addStartElement(wrapperCode, Untyped.getInstance(), null); } matcher.addText(node.getStringValue()); if (groupAdjacent != null && nextMatches(node)) { inGroup.pop(); inGroup.push(true); } else { matcher.addEndElement(); inGroup.pop(); inGroup.push(false); } }
public void processPI(XdmNode node) throws SaxonApiException { if (!inGroup.peek()) { matcher.addStartElement(wrapperCode, Untyped.getInstance(), null); } matcher.addPI(node.getNodeName().getLocalName(),node.getStringValue()); if (groupAdjacent != null && nextMatches(node)) { inGroup.pop(); inGroup.push(true); } else { matcher.addEndElement(); inGroup.pop(); inGroup.push(false); } }
public void processPI(XdmNode node) throws SaxonApiException { if (!inGroup.peek()) { matcher.addStartElement(wrapperCode, Untyped.getInstance(), null); } matcher.addPI(node.getNodeName().getLocalName(),node.getStringValue()); if (groupAdjacent != null && nextMatches(node)) { inGroup.pop(); inGroup.push(true); } else { matcher.addEndElement(); inGroup.pop(); inGroup.push(false); } }