public void run() throws SaxonApiException { super.run(); String cmethod = getOption(_compression_method, "gzip"); if (!"gzip".equals(cmethod)) { throw XProcException.stepError(999, "The only compression method supported is 'gzip'."); } XdmNode root = S9apiUtils.getDocumentElement(source.read()); byte[] decoded = null; // N.B. The Base64.decode() method *automatically* expands gzipped data! if ("base64".equals(root.getAttributeValue(_encoding))) { decoded = Base64.decode(root.getStringValue()); } else { throw XProcException.stepError(999, "Input to cx:gunzip must be binary encoded data."); } try { ByteArrayInputStream bais = new ByteArrayInputStream(decoded); InputSource is = new InputSource(bais); XdmNode doc = runtime.parse(is); result.write(doc); } catch (Exception e) { throw new XProcException(e); } } }
public void run() throws SaxonApiException { super.run(); String cmethod = getOption(_compression_method, "gzip"); if (!"gzip".equals(cmethod)) { throw XProcException.stepError(999, "The only compression method supported is 'gzip'."); } XdmNode root = S9apiUtils.getDocumentElement(source.read()); byte[] decoded = null; // N.B. The Base64.decode() method *automatically* expands gzipped data! if ("base64".equals(root.getAttributeValue(_encoding))) { decoded = Base64.decode(root.getStringValue()); } else { throw XProcException.stepError(999, "Input to cx:gunzip must be binary encoded data."); } try { ByteArrayInputStream bais = new ByteArrayInputStream(decoded); InputSource is = new InputSource(bais); XdmNode doc = runtime.parse(is); result.write(doc); } catch (Exception e) { throw new XProcException(e); } } }