public void cache(XdmNode doc, URI baseURI) { XdmNode root = S9apiUtils.getDocumentElement(doc); // We explicitly use the base URI of the root element so that if it has an xml:base // attribute, that becomes the base URI of the document. URI docURI = baseURI.resolve(root.getBaseURI()); if (useCache) { cache.put(docURI.toASCIIString(), doc); } }
public void add(XdmNode document) { if (closed) { throw new XProcException("You can't add a document to a closed DocumentSequence."); } else { S9apiUtils.assertDocument(document); //runtime.finest(logger, null, "Wrote " + (document == null ? "null" : document.getBaseURI()) + " to " + toString()); documents.add(document); if (outputlog != null) { outputlog.log(document); } } }
public static void dumpTree(XdmNode tree, String message) { NodeInfo treeNode = tree.getUnderlyingNode(); System.err.println(message); System.err.println("Dumping tree: " + treeNode.getSystemId() + ", " + tree.getBaseURI()); XdmSequenceIterator iter = tree.axisIterator(Axis.CHILD); while (iter.hasNext()) { XdmNode child = (XdmNode) iter.next(); dumpTreeNode(child, " "); } }
public XdmNode read() throws SaxonApiException { read = true; if (doc != null) { return doc; } if (nodes != null) { // Find the document element so we can get the base URI XdmNode node = null; for (int pos = 0; pos < nodes.size() && node == null; pos++) { if (((XdmNode) nodes.get(pos)).getNodeKind() == XdmNodeKind.ELEMENT) { node = (XdmNode) nodes.get(pos); } } XdmDestination dest = new XdmDestination(); try { S9apiUtils.writeXdmValue(cfgProcessor, nodes, dest, node.getBaseURI()); doc = dest.getXdmNode(); if (excludeUris.size() != 0) { doc = S9apiUtils.removeNamespaces(cfgProcessor, doc, excludeUris, true); } } catch (SaxonApiException sae) { throw new XProcException(sae); } } else { doc = readXML(href, base); } return doc; }
XdmNode ssroot = S9apiUtils.getDocumentElement(stylesheet); if (ssroot != null) { version = ssroot.getAttributeValue(new QName("","version")); S9apiUtils.assertDocument(xformed); resultPipe.write(xformed); } catch (XProcException e) { serializer.setOutputStream(baos); try { S9apiUtils.serialize(runtime, xformed, serializer); } catch (SaxonApiException e2) { throw new XProcException(e2);
public static void serialize(XProcRuntime xproc, XdmNode node, Serializer serializer) throws SaxonApiException { Vector<XdmNode> nodes = new Vector<XdmNode> (); nodes.add(node); serialize(xproc, nodes, serializer); }
XdmNode root = S9apiUtils.getDocumentElement(query.read()); String queryString = null; S9apiUtils.assertDocument(node); } catch (XProcException e) {
XdmNode piperoot = S9apiUtils.getDocumentElement(pipedoc); String port = primaryin; XdmNode doc = pipe.read(); XdmNode root = S9apiUtils.getDocumentElement(doc); if (detailed && cx_document.equals(root.getNodeName())) { port = root.getAttributeValue(_port); S9apiUtils.writeXdmValue(runtime, nodes, dest, root.getBaseURI()); doc = dest.getXdmNode(); while (pipe.moreDocuments()) { XdmNode doc = pipe.read(); XdmNode root = S9apiUtils.getDocumentElement(doc);
/** * Write an XdmValue to a given destination. The sequence represented by the XdmValue is "normalized" * as defined in the serialization specification (this is equivalent to constructing a document node * in XSLT or XQuery with this sequence as the content expression), and the resulting document is * then copied to the destination. If the destination is a serializer this has the effect of serializing * the sequence as described in the W3C specifications. * @param runtime The runtime * @param values the value to be written * @param destination the destination to which the value is to be written * @param baseURI the base URI * @throws SaxonApiException if something goes wrong */ public static void writeXdmValue(XProcRuntime runtime, Vector<XdmValue> values, Destination destination, URI baseURI) throws SaxonApiException { writeXdmValue(runtime.getProcessor(), values, destination, baseURI); }
public void run() throws SaxonApiException { super.run(); HashSet<String> excludeUris = S9apiUtils.excludeInlinePrefixes(step.getNode(), getOption(_prefixes).getString()); while (source.moreDocuments()) { XdmNode doc = source.read(); logger.trace(MessageFormatter.nodeMessage(step.getNode(), "Namespace-delete step " + step.getName() + " read " + doc.getDocumentURI())); doc = S9apiUtils.removeNamespaces(runtime, doc, excludeUris, false); result.write(doc); } } }
if (S9apiUtils.xpathSyntaxError(sae)) { throw XProcException.dynamicError(23, context, "Invalid XPath expression: '" + select + "'."); } else { S9apiUtils.writeXdmValue(runtime, node, dest, node.getBaseURI());
S9apiUtils.assertDocumentContent(body.axisIterator(Axis.CHILD)); } catch (XProcException xe) { throw XProcException.stepError(22); S9apiUtils.serialize(runtime, content, serializer); writer.close(); requestEntity = new StringEntity(writer.toString(), ContentType.create(contentType, "UTF-8"));
step.setXPathVersion(xpathVersion); HashSet<String> excludeURIs = S9apiUtils.excludeInlinePrefixes(node, node.getAttributeValue(_exclude_inline_prefixes)); if (!declStack.isEmpty()) { DeclareStep parent = declStack.peek(); if (S9apiUtils.getParent(node) != null) { XdmNode parent = node.getParent(); if (XProcConstants.p_library.equals(parent.getNodeName()) && parent.getAttributeValue(_exclude_inline_prefixes) != null) { HashSet<String> pexcl = S9apiUtils.excludeInlinePrefixes(parent, parent.getAttributeValue(_exclude_inline_prefixes)); for (String uri : pexcl) { excludeURIs.add(uri);
HashSet<String> excludeURIs = S9apiUtils.excludeInlinePrefixes(node, node.getAttributeValue(_exclude_inline_prefixes)); documents.add(new ConfigDocument(docnodes, excludeURIs));
public static XdmNode removeNamespaces(Processor proc, XdmNode node, HashSet<String> excludeNS, boolean preserveUsed) { TreeWriter tree = new TreeWriter(proc); tree.startDocument(node.getBaseURI()); removeNamespacesWriter(tree, node, excludeNS, preserveUsed); tree.endDocument(); return tree.getResult(); }
public static XdmNode removeNamespaces(XProcRuntime runtime, XdmNode node, HashSet<String> excludeNS, boolean preserveUsed) { return removeNamespaces(runtime.getProcessor(), node, excludeNS, preserveUsed); }
&& parent.getNodeKind() != XdmNodeKind.ELEMENT && parent.getNodeKind() != XdmNodeKind.DOCUMENT) { parent = S9apiUtils.getParent(parent);
public static void assertDocument(XdmNode doc) { if (doc.getNodeKind() == XdmNodeKind.DOCUMENT) { S9apiUtils.assertDocumentContent(doc.axisIterator(Axis.CHILD)); } else if (doc.getNodeKind() == XdmNodeKind.ELEMENT) { // this is ok } else { throw XProcException.dynamicError(1, "Document root cannot be " + doc.getNodeKind()); } }
XdmNode ssroot = S9apiUtils.getDocumentElement(stylesheet); if (ssroot != null) { version = ssroot.getAttributeValue(new QName("","version")); S9apiUtils.assertDocument(xformed); resultPipe.write(xformed); } catch (XProcException e) { serializer.setOutputStream(baos); try { S9apiUtils.serialize(runtime, xformed, serializer); } catch (SaxonApiException e2) { throw new XProcException(e2);
public static void serialize(XProcRuntime xproc, XdmNode node, Serializer serializer) throws SaxonApiException { Vector<XdmNode> nodes = new Vector<XdmNode> (); nodes.add(node); serialize(xproc, nodes, serializer); }