protected void setSaxonConfig(Input saxonConfig) { needsCheck = true; if ((this.saxonConfig != null) && (saxonConfig != null)) { throw new XProcException("Multiple saxonConfig are not supported."); } this.saxonConfig = saxonConfig; }
protected void setProfile(Output profile) { needsCheck = true; if ((this.profile != null) && (profile != null)) { throw new XProcException("Multiple profile are not supported."); } this.profile = profile; }
private HttpResponse head(HttpClient client, HttpUriRequest httpRequest, HttpContext localContext) { try { return client.execute(httpRequest, localContext); } catch (ClientProtocolException cpe) { throw new XProcException(cpe); } catch (IOException ioe) { throw new XProcException(ioe); } }
protected URI getDataUri(String uri) { try { return new URI(uri); } catch (URISyntaxException use) { throw new XProcException(use); } }
public void addOutput(String port, OutputStream outputStream) { if (outputs.containsKey(port)) { if (port == null) { throw new XProcException("Duplicate output binding for default output port."); } else { throw new XProcException("Duplicate output binding: '" + port + "'."); } } outputs.put(port, new Output(outputStream)); }
private void parseHtmlParser(XdmNode node) { String value = node.getAttributeValue(_value); if (value == null) { throw new XProcException("Configuration option 'html-parser' cannot have null value"); } if ("validator.nu".equals(value) || "tagsoup".equals(value)) { htmlParser = value; } else { throw new XProcException("Unrecognized value in html-parser: " + value); } }
public XPointerXmlnsScheme(QName name, String data, int readLimit) { super(name,data, readLimit); Pattern scheme = Pattern.compile("([\\w:]+)\\s*=\\s*([^=]+)$"); Matcher matcher = scheme.matcher(data); if (matcher.matches()) { prefix = matcher.group(1); uri = matcher.group(2); } else { throw new XProcException("Unparseable xmlns(): " + data); } }
public void addEndElement() { try { receiver.endElement(); } catch (XPathException e) { throw new XProcException(e); } }
public void setJsonFlavor(String jsonFlavor) { this.jsonFlavor = jsonFlavor; if ((jsonFlavor != null) && !knownFlavor(jsonFlavor)) { throw new XProcException("Unknown JSON flavor: '" + jsonFlavor + "'."); } }
public void append(String string) { try { byte[] bytes = string.getBytes("US-ASCII"); append(bytes, bytes.length); } catch (UnsupportedEncodingException uee) { // This never happens! throw new XProcException(uee); } }
public Source resolve(String href, String base) throws TransformerException { if ("iso_schematron_skeleton_for_saxon.xsl".equals(href)) { return new SAXSource(new InputSource(skeleton)); } else { throw new XProcException(step.getNode(), "Failed to resolve " + href + " from JAR file."); } } }
private void parseFoProcessor(XdmNode node) { String value = node.getAttributeValue(_class_name); if (value == null) { throw new XProcException(node, "Missing required attribute: class-name"); } foProcessor = value; }
private void parseCssProcessor(XdmNode node) { String value = node.getAttributeValue(_class_name); if (value == null) { throw new XProcException(node, "Missing required attribute: class-name"); } cssProcessor = value; }
private static void storeBinary(XdmNode doc, OutputStream stream) { try { try { byte[] decoded = Base64.decode(doc.getStringValue()); stream.write(decoded); } finally { stream.close(); } } catch (IOException ioe) { throw new XProcException(ioe); } }
public void addPI(String target, String data) { try { receiver.processingInstruction(target, data, VoidLocation.instance(), 0); } catch (XPathException e) { throw new XProcException(e); } } }
private String checkNCName(String name) { if (name != null) { try { TypeUtils.checkType(runtime, name, XProcConstants.xs_NCName,null); } catch (XProcException xe) { throw new XProcException("Invalid name: \"" + name + "\". Step and port names must be NCNames.", xe.getCause()); } } return name; }
private byte[] textContent(final XdmNode doc) { Serializer serializer = makeSerializer(); serializer.setOutputProperty(Serializer.Property.METHOD, "text"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); serializer.setOutputStream(baos); try { S9apiUtils.serialize(runtime, doc, serializer); } catch (SaxonApiException e) { throw new XProcException(e); } return baos.toByteArray(); }
public void addOutput(Output output) { if (this.output != null) { throw new XProcException(output.getNode(), "cx:until-unchanged can have only a single output port: " + output.getPort()); } if (!"#current".equals(output.getPort())) { this.output = output; } super.addOutput(output); }
@Override protected Representation post(Representation entity, Variant variant) { try { ((PiperackApplication) getApplication()).stop(); } catch (Exception e) { throw new XProcException(e); } return okResponse("Stopping", variant.getMediaType()); }
public XdmAtomicValue getUntypedAtomic(XProcRuntime runtime) { try { ItemTypeFactory itf = new ItemTypeFactory(runtime.getProcessor()); ItemType untypedAtomic = itf.getAtomicType(new QName(NamespaceConstant.SCHEMA, "xs:untypedAtomic")); XdmAtomicValue val = new XdmAtomicValue(value, untypedAtomic); return val; } catch (SaxonApiException sae) { throw new XProcException(sae); } }