public void run() throws SaxonApiException { super.run(); RuntimeValue attrNameValue = getOption(_attribute); String attrNameStr = attrNameValue.getString(); String apfx = getOption(_attribute_prefix, (String) null); String ans = getOption(_attribute_namespace, (String) null); if (apfx != null && ans == null) { throw XProcException.dynamicError(34, "You can't specify a prefix without a namespace"); } if (ans != null && attrNameStr.contains(":")) { throw XProcException.dynamicError(34, "You can't specify a namespace if the attribute name contains a colon"); } if (attrNameStr.contains(":")) { attribute = new QName(attrNameStr, attrNameValue.getNode()); } else { // For Saxon 9.4, make sure there's some sort of prefix if there's a namespace; // Saxon will take care of resolving collisions, if necessary if (apfx == null && ans != null) { apfx = "_1"; } attribute = new QName(apfx == null ? "" : apfx, ans, attrNameStr); } label = getOption(_label); replace = getOption(_replace).getBoolean(); matcher = new ProcessMatch(runtime, this); matcher.match(source.read(), getOption(_match)); result.write(matcher.getResult()); }
public boolean processStartElement(XdmNode node) throws SaxonApiException { matcher.addStartElement(node); boolean found = false; XdmSequenceIterator iter = node.axisIterator(Axis.ATTRIBUTE); while (iter.hasNext()) { XdmNode attr = (XdmNode) iter.next(); if (attribute.equals(attr.getNodeName())) { found = true; if (replace) { matcher.addAttribute(attr, computedLabel(node)); } else { matcher.addAttribute(attr); } } else { matcher.addAttribute(attr); } } if (!found) { matcher.addAttribute(attribute, computedLabel(node)); } return true; }
public boolean processStartElement(XdmNode node) throws SaxonApiException { matcher.addStartElement(node); boolean found = false; XdmSequenceIterator iter = node.axisIterator(Axis.ATTRIBUTE); while (iter.hasNext()) { XdmNode attr = (XdmNode) iter.next(); if (attribute.equals(attr.getNodeName())) { found = true; if (replace) { matcher.addAttribute(attr, computedLabel(node)); } else { matcher.addAttribute(attr); } } else { matcher.addAttribute(attr); } } if (!found) { matcher.addAttribute(attribute, computedLabel(node)); } return true; }
public void run() throws SaxonApiException { super.run(); RuntimeValue attrNameValue = getOption(_attribute); String attrNameStr = attrNameValue.getString(); String apfx = getOption(_attribute_prefix, (String) null); String ans = getOption(_attribute_namespace, (String) null); if (apfx != null && ans == null) { throw XProcException.dynamicError(34, "You can't specify a prefix without a namespace"); } if (ans != null && attrNameStr.contains(":")) { throw XProcException.dynamicError(34, "You can't specify a namespace if the attribute name contains a colon"); } if (attrNameStr.contains(":")) { attribute = new QName(attrNameStr, attrNameValue.getNode()); } else { // For Saxon 9.4, make sure there's some sort of prefix if there's a namespace; // Saxon will take care of resolving collisions, if necessary if (apfx == null && ans != null) { apfx = "_1"; } attribute = new QName(apfx == null ? "" : apfx, ans, attrNameStr); } label = getOption(_label); replace = getOption(_replace).getBoolean(); matcher = new ProcessMatch(runtime, this); matcher.match(source.read(), getOption(_match)); result.write(matcher.getResult()); }