private List<XdmNode> createXdmNodes(List<File> spotBugsFiles, DocumentBuilder documentBuilder) { return spotBugsFiles.stream().map(t -> { try { return documentBuilder.build(t); } catch (SaxonApiException e) { LOG.error(e.getMessage(), e); } return null; }).collect(Collectors.toList()); } }
/** * Close the destination, allowing resources to be released. Saxon calls this method when * it has finished writing to the destination. * <p>The close() method should not cause any adverse effects if it is called more than * once. If any other method is called after the close() call, the results are undefined. * This means that a Destination is not, in general, serially reusable.</p> * * @throws SaxonApiException if any failure occurs */ public void close() throws SaxonApiException { try { writer.close(); } catch (XMLStreamException e) { throw new SaxonApiException(e); } } }
public static boolean xpathSyntaxError(SaxonApiException sae) { Throwable cause = sae.getCause(); // FIME: Is this right? Are all XPathExceptions syntax errors? return (cause != null && cause instanceof XPathException); }
} catch (SaxonApiException err) { failures++; System.err.println("While processing " + localName + ": " + err.getMessage() + '\n'); throw new SaxonApiException(failures + " transformation" + (failures == 1 ? "" : "s") + " failed");
log.error("Problems processing the content. EXPRESSION:" + xQueryExpression + " " + e.getMessage(),e); throw new XQueryException(e.getMessage());
/** * Close the destination, allowing resources to be released. Saxon calls this method when * it has finished writing to the destination. * <p>The close() method should not cause any adverse effects if it is called more than * once. If any other method is called after the close() call, the results are undefined. * This means that a Destination is not, in general, serially reusable.</p> * * @throws SaxonApiException if any failure occurs */ public void close() throws SaxonApiException { try { writer.close(); } catch (XMLStreamException e) { throw new SaxonApiException(e); } } }
public static boolean xpathSyntaxError(SaxonApiException sae) { Throwable cause = sae.getCause(); // FIME: Is this right? Are all XPathExceptions syntax errors? return (cause != null && cause instanceof XPathException); }
/** * Filter the content with the XPath expression specified when creating the XPathProcessor. * * @param content String to which the XPath expression will be applied * @return TRUE if the XPath expression evaluates to true, FALSE otherwise * @throws XPathException */ private boolean filter(StreamSource content) throws XPathException { try { // Prepare to evaluate the XPath expression against the content XdmNode xmlDoc = builder.build(content); xsel.setContextItem(xmlDoc); // Evaluate and return the boolean value for the XPath expression return xsel.effectiveBooleanValue(); } catch (SaxonApiException e) { log.error("Problems processing the content. EXPRESSION:" + xPathExpression + " " + e.getMessage(),e); throw new XPathException(e.getMessage()); } }
/** * Close the destination, allowing resources to be released. Saxon calls this method when * it has finished writing to the destination. */ public void close() throws SaxonApiException { try { sequenceOutputter.close(); closed = true; } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Returns the detail message string of this throwable. * * @return the detail message string of this <tt>Throwable</tt> instance * (which may be <tt>null</tt>). */ public String getMessage() { return getCause().getMessage(); }
/** * Run the tests to assess "Atom WMS" conformance only if the context * document contains WMS service offerings. Otherwise they will be skipped. */ @BeforeTest public void hasWmsOfferings() { String xpath = String.format("//owc:offering[@code='%s']", OWC10.ATOM_WMS_OFFERING); Source source = new StreamSource(this.contextFile); XdmValue result; try { result = XMLUtils.evaluateXPath2(source, xpath, Collections.singletonMap(Namespaces.OWC, "owc")); } catch (SaxonApiException e) { throw new AssertionError(e.getMessage()); } if (result.size() == 0) { throw new SkipException("No WMS offerings found."); } }
@Override public void close() throws SaxonApiException { try { r.close(); } catch (XPathException e) { throw new SaxonApiException(e); } } };
/** * Returns the detail message string of this throwable. * * @return the detail message string of this <tt>Throwable</tt> instance * (which may be <tt>null</tt>). */ public String getMessage() { return getCause().getMessage(); }
protected String safeAddResult (NamedList<Object> xpathResults, XdmItem item) { try { addResult (xpathResults, item); return null; } catch (SaxonApiException e) { return e.getMessage(); } catch (ResourceExhaustedException e) { return e.getMessage(); } catch (OutOfMemoryError e) { return e.getMessage(); } }
/** * Close the destination, allowing resources to be released. Saxon calls this method when * it has finished writing to the destination. */ public void close() throws SaxonApiException { try { sequenceOutputter.close(); closed = true; } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Returns the detail message string of this throwable. * * @return the detail message string of this <tt>Throwable</tt> instance * (which may be <tt>null</tt>). */ public String getMessage() { return getCause().getMessage(); } }
private List<File> convertFiles(List<File> filesToLoad) throws ServletException { List<File> rdfxmlFiles = new ArrayList<File>(filesToLoad.size()); for( File file: filesToLoad){ try { //look for an example of this in S9APIExamples.java from saxon he 9 XsltTransformer t = xsltExec.load(); //this is how to set parameters: //t.setParameter(new QName("someparametername"), new XdmAtomicValue(10)); Serializer out = new Processor(false).newSerializer(); out.setOutputProperty(Serializer.Property.METHOD, "xml"); out.setOutputProperty(Serializer.Property.INDENT, "yes"); File outFile = new File(file.getAbsolutePath() + ".rdfxml"); rdfxmlFiles.add(outFile); out.setOutputFile(outFile); t.setSource(new StreamSource(file)); t.setDestination(out); t.transform(); } catch (SaxonApiException e) { log.error("could not convert " + file.getAbsolutePath() + " to RDF/XML: " + e.getMessage()); throw new ServletException("could not convert " + file.getAbsolutePath() + " to RDF/XML: " + e.getMessage()); } } return rdfxmlFiles; }
@Override public void close() throws SaxonApiException { try { r.close(); } catch (XPathException e) { throw new SaxonApiException(e); } } };
private XsltExecutable reportCompileError(SaxonApiException e, List<TransformerException> compileErrors) throws XPathException { for (TransformerException te : compileErrors) { // This is primarily so that the right error code is reported as required by the fn:transform spec if (te instanceof XPathException) { if (((XPathException) te).getErrorCodeLocalPart() == null) { ((XPathException) te).setErrorCode("FOXT0002"); } throw (XPathException)te; } } if (e.getCause() instanceof XPathException) { throw (XPathException) e.getCause(); } else { throw new XPathException(e); } }
/** * Process each file in the source directory using its own associated stylesheet * * @param sources The sources in the directory to be processed * @param outputDir The directory in which output files are to be * created * @param options Command line options * @param traceDestination output destination for fn:trace() calls * @throws Exception when any error occurs during a transformation */ private void processDirectoryAssoc(List<Source> sources, File outputDir, CommandLineOptions options, Logger traceDestination) throws Exception { int failures = 0; for (Source source : sources) { String localName = getLocalFileName(source); try { processFileAssoc(source, localName, outputDir, options, traceDestination); } catch (SaxonApiException err) { failures++; System.err.println("While processing " + localName + ": " + err.getMessage() + '\n'); } } if (failures > 0) { throw new XPathException(failures + " transformation" + (failures == 1 ? "" : "s") + " failed"); } }