private void update(ZipInputStream inZip, final ZipOutputStream outZip) { String command = getOption(_command).getString(); if ("create".equals(command)) { try { if (inZip != null) { inZip.close(); } } catch (IOException ioe) { throw new XProcException(ioe); } inZip = null; } if ("update".equals(command) || "create".equals(command)) { update(inZip, outZip, false); } else if ("freshen".equals(command)) { update(inZip, outZip, true); } else if ("delete".equals(command)) { delete(inZip, outZip); } else { throw new XProcException(step.getNode(), "Unexpected cx:zip command: " + command); } }
private void readStream(TreeWriter tree, URI id, InputStream stream, final DatatypeFactory dfactory) throws IOException { ZipInputStream zipStream = new ZipInputStream(stream); try { ZipEntry entry = zipStream.getNextEntry(); while (entry != null) { processEntry(tree, entry, dfactory); } } finally { zipStream.close(); } }
protected void store(FileToZip file, XdmNode doc, OutputStream out) throws SaxonApiException, IOException { XdmNode root = S9apiUtils.getDocumentElement(doc); if (((XProcConstants.NS_XPROC_STEP.equals(root.getNodeName().getNamespaceURI()) && "base64".equals(root.getAttributeValue(_encoding))) || ("".equals(root.getNodeName().getNamespaceURI()) && "base64".equals(root.getAttributeValue(c_encoding))))) { storeBinary(file, doc, out); } else if (XProcConstants.c_result.equals(root.getNodeName()) && root.getAttributeValue(_content_type) != null && root.getAttributeValue(_content_type).startsWith("text/")) { storeText(file, doc, out); } else if (runtime.transparentJSON() && (((c_body.equals(root.getNodeName()) && ("application/json".equals(root.getAttributeValue(_content_type)) || "text/json".equals(root.getAttributeValue(_content_type)))) || c_json.equals(root.getNodeName())) || JSONtoXML.JSONX_NS.equals(root.getNodeName().getNamespaceURI()) || JSONtoXML.JXML_NS.equals(root.getNodeName().getNamespaceURI()) || JSONtoXML.MLJS_NS.equals(root.getNodeName().getNamespaceURI()))) { storeJSON(file, doc, out); } else { storeXML(file, doc, out); } }
public void run() throws SaxonApiException { super.run(); final String zipFn = getOption(_href).getString(); parseManifest(man); final String base = getOption(_href).getBaseURI().toASCIIString(); final DataStore store = runtime.getDataStore(); store.writeEntry(zipFn, base, "application/zip", new DataStore.DataWriter() {
public void storeXML(FileToZip file, XdmNode doc, OutputStream out) throws SaxonApiException { Serializer serializer = makeSerializer(file.getOptions()); serializer.setOutputStream(out); S9apiUtils.serialize(runtime, doc, serializer); }
protected void store(FileToZip file, XdmNode doc, OutputStream out) throws SaxonApiException, IOException { XdmNode root = S9apiUtils.getDocumentElement(doc); if (((XProcConstants.NS_XPROC_STEP.equals(root.getNodeName().getNamespaceURI()) && "base64".equals(root.getAttributeValue(_encoding))) || ("".equals(root.getNodeName().getNamespaceURI()) && "base64".equals(root.getAttributeValue(c_encoding))))) { storeBinary(file, doc, out); } else if (XProcConstants.c_result.equals(root.getNodeName()) && root.getAttributeValue(_content_type) != null && root.getAttributeValue(_content_type).startsWith("text/")) { storeText(file, doc, out); } else if (runtime.transparentJSON() && (((c_body.equals(root.getNodeName()) && ("application/json".equals(root.getAttributeValue(_content_type)) || "text/json".equals(root.getAttributeValue(_content_type)))) || c_json.equals(root.getNodeName())) || JSONtoXML.JSONX_NS.equals(root.getNodeName().getNamespaceURI()) || JSONtoXML.JXML_NS.equals(root.getNodeName().getNamespaceURI()) || JSONtoXML.MLJS_NS.equals(root.getNodeName().getNamespaceURI()))) { storeJSON(file, doc, out); } else { storeXML(file, doc, out); } }
public void run() throws SaxonApiException { super.run(); final String zipFn = getOption(_href).getString(); parseManifest(man); final String base = getOption(_href).getBaseURI().toASCIIString(); final DataStore store = runtime.getDataStore(); store.writeEntry(zipFn, base, "application/zip", new DataStore.DataWriter() {
public void storeXML(FileToZip file, XdmNode doc, OutputStream out) throws SaxonApiException { Serializer serializer = makeSerializer(file.getOptions()); serializer.setOutputStream(out); S9apiUtils.serialize(runtime, doc, serializer); }
private void update(ZipInputStream inZip, final ZipOutputStream outZip) { String command = getOption(_command).getString(); if ("create".equals(command)) { try { if (inZip != null) { inZip.close(); } } catch (IOException ioe) { throw new XProcException(ioe); } inZip = null; } if ("update".equals(command) || "create".equals(command)) { update(inZip, outZip, false); } else if ("freshen".equals(command)) { update(inZip, outZip, true); } else if ("delete".equals(command)) { delete(inZip, outZip); } else { throw new XProcException(step.getNode(), "Unexpected cx:zip command: " + command); } }
private void readStream(TreeWriter tree, URI id, InputStream stream, final DatatypeFactory dfactory) throws IOException { ZipInputStream zipStream = new ZipInputStream(stream); try { ZipEntry entry = zipStream.getNextEntry(); while (entry != null) { processEntry(tree, entry, dfactory); } } finally { zipStream.close(); } }
private void readFile(TreeWriter tree, URI id, String zipFn, final DatatypeFactory dfactory) throws IOException { ZipFile zipFile = null; try { File uriFile = new File(new URI(zipFn)); zipFile = new ZipFile(uriFile); Enumeration<? extends ZipEntry> zipEntryEnum = zipFile.entries(); while (zipEntryEnum.hasMoreElements()) { ZipEntry entry = zipEntryEnum.nextElement(); processEntry(tree, entry, dfactory); } } catch (URISyntaxException e) { throw new XProcException(e); } finally { if (zipFile != null) { zipFile.close(); } } }
private void readFile(TreeWriter tree, URI id, String zipFn, final DatatypeFactory dfactory) throws IOException { ZipFile zipFile = null; try { File uriFile = new File(new URI(zipFn)); zipFile = new ZipFile(uriFile); Enumeration<? extends ZipEntry> zipEntryEnum = zipFile.entries(); while (zipEntryEnum.hasMoreElements()) { ZipEntry entry = zipEntryEnum.nextElement(); processEntry(tree, entry, dfactory); } } catch (URISyntaxException e) { throw new XProcException(e); } finally { if (zipFile != null) { zipFile.close(); } } }