@Override public ValidationResult validate(final String subject, final String input, final ValidationContext validationContext) { try { final Processor proc = new Processor(false); final XQueryCompiler comp = proc.newXQueryCompiler(); String error = null; try { comp.compile(input); } catch (final Exception e) { error = e.toString(); } return new ValidationResult.Builder().input(input).subject(subject).valid(error == null).explanation(error).build(); } catch (final Exception e) { return new ValidationResult.Builder().input(input).subject(subject).valid(false) .explanation("Unable to initialize XQuery engine due to " + e.toString()).build(); } } }
final Map<String, XQueryExecutable> attributeToXQueryMap = new HashMap<>(); final Processor proc = new Processor(false); final XMLReader xmlReader;
/** * Construct a TransformerFactory using an existing Configuration. * * @param config the Saxon configuration */ public SaxonTransformerFactory(Configuration config) { processor = new Processor(config); }
/** * Default constructor. */ public SaxonTransformerFactory() { processor = new Processor(true); }
/** * Default constructor. */ public SaxonTransformerFactory() { processor = new Processor(true); }
/** * Construct a TransformerFactory using an existing Configuration. * * @param config the Saxon configuration */ public SaxonTransformerFactory(Configuration config) { processor = new Processor(config); }
public Processor getProcessor () { if (processor == null) { processor = new Processor(false); } return processor; }
public XMLStreamWriterOverTreeWriter(Configuration configuration) { // FIXME: TreeWriter doesn't need the Processor, it calls getUnderlyingConfiguration super(new Processor(configuration)); }
private static Processor makeProcessor () { try { if (Class.forName("com.saxonica.config.EnterpriseConfiguration") != null) { return new Processor (true); } } catch (ClassNotFoundException e) { } try { if (Class.forName("com.saxonica.config.ProfessionalConfiguration") != null) { //return new Processor (new Config()); return new Processor (true); } } catch (ClassNotFoundException e) { } Processor p = new Processor (new Config()); if (! StringUtils.isEmpty(System.getProperty("org.expath.pkg.saxon.repo"))) { EXPathSupport.initializeEXPath(p); } return p; }
private void initCompiler(Configuration config) { this.xsltCompiler = new Processor(config).newXsltCompiler(); if (this.uriResolver != null) { //this resolver is used for xsl:include and xsl:import this.xsltCompiler.setURIResolver(this.uriResolver); } } }
public XPathResolver(boolean autoNodeTextExtraction) { this.autoNodeTextExtraction = autoNodeTextExtraction; this.xpathProcessor = new Processor(false); this.xpath = xpathProcessor.newXPathCompiler(); this.xpath.setCaching(true); }
public XPathResolver(boolean autoNodeTextExtraction) { this.autoNodeTextExtraction = autoNodeTextExtraction; this.xpathProcessor = new Processor(false); this.xpath = xpathProcessor.newXPathCompiler(); this.xpath.setCaching(true); }
/** * Creates a new {@link Processor} with a default {@link Configuration}. * @return the new instance */ public Processor createProcessor() { return new Processor(new Configuration()); } }
public Engine() throws Exception { String s = System.getProperty("te.cacheSize"); if (s != null) { cacheSize = Integer.parseInt(s); } // Create processor processor = new Processor(false); // Modify its configuration settings Configuration config = processor.getUnderlyingConfiguration(); config.setVersionWarning(false); // Use our custom error listener which reports line numbers in the CTL // source file errorListener = new TeErrorListener(); config.setErrorListener(errorListener); // Create a compiler and document builder compiler = processor.newXsltCompiler(); builder = processor.newDocumentBuilder(); // Load an executable for the TECore.form method ClassLoader cl = Thread.currentThread().getContextClassLoader(); InputStream is = cl.getResourceAsStream("com/occamlab/te/formfn.xsl"); formExecutable = compiler.compile(new StreamSource(is)); // Fortify Mod: We are done with the InputStream. Release the resource is.close(); }
private void generateAggregatedHtmlReport(File xmlFile, File outputDir) throws SaxonApiException { Processor proc = new Processor(false); XsltCompiler comp = proc.newXsltCompiler(); InputStream xsl = getClass().getClassLoader().getResourceAsStream("spotbugs/html-aggregated.xsl"); XsltExecutable exp = comp.compile(new StreamSource(xsl)); XdmNode source = proc.newDocumentBuilder().build(new StreamSource(xmlFile)); Serializer out = proc.newSerializer(new File(outputDir, "SpotBugsAggregated.html")); out.setOutputProperty(Serializer.Property.METHOD, "html"); out.setOutputProperty(Serializer.Property.INDENT, "yes"); XsltTransformer trans = exp.load(); trans.setInitialContextNode(source); trans.setDestination(out); trans.transform(); }
public XpathFilterCollector(String query) { xpath = query; config = new Config(); Processor processor = new Processor(config); XPathCompiler compiler = processor.newXPathCompiler(); try { selector = compiler.compile(xpath).load(); } catch (SaxonApiException e) { throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Unable to compile xpath: " + query, e); } }
public void run() throws SaxonApiException { Processor saxon = new Processor(false); XProcConfiguration config = new XProcConfiguration(saxon); XProcRuntime runtime = new XProcRuntime(config); InputStream stream = new ByteArrayInputStream(pipeline_xml.getBytes()); DocumentBuilder builder = saxon.newDocumentBuilder(); XdmNode pipeline_doc = builder.build(new SAXSource(new InputSource(stream))); XPipeline pipeline = runtime.use(pipeline_doc); pipeline.run(); }
public SaxonCommand(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.isTracing = getConfigs().getBoolean(config, "isTracing", false); boolean isLicensedSaxonEdition = getConfigs().getBoolean(config, "isLicensedSaxonEdition", false); this.processor = new Processor(isLicensedSaxonEdition); this.documentBuilder = processor.newDocumentBuilder(); Config features = getConfigs().getConfig(config, "features", ConfigFactory.empty()); for (Map.Entry<String, Object> entry : new Configs().getEntrySet(features)) { processor.setConfigurationProperty(entry.getKey(), entry.getValue()); } }
public void aggregateSpotBugsFiles(File rootDir, int level, File outputDir) throws FileNotFoundException, IOException, SaxonApiException { List<File> spotBugsFiles = getSpotBugsFiles(rootDir, level); Processor proc = new Processor(false); XsltCompiler comp = proc.newXsltCompiler(); InputStream xsl = getClass().getClassLoader().getResourceAsStream("spotbugs/xml-aggregated.xsl"); XsltExecutable exp = comp.compile(new StreamSource(xsl)); Serializer out = proc.newSerializer(new File(outputDir, "SpotBugsAggregated.xml")); out.setOutputProperty(Serializer.Property.METHOD, "xml"); out.setOutputProperty(Serializer.Property.INDENT, "yes"); XsltTransformer trans = exp.load(); List<XdmNode> sources = createXdmNodes(spotBugsFiles, proc.newDocumentBuilder()); QName xmlFiles = new QName("xmlFiles"); XdmValue filesXdm = XdmValue.makeSequence(sources); trans.setParameter(xmlFiles, filesXdm); trans.setInitialTemplate(new QName("test")); trans.setDestination(out); trans.transform(); }
@Override public ValidationResult validate(final String subject, final String input, final ValidationContext validationContext) { try { final Processor proc = new Processor(false); final XQueryCompiler comp = proc.newXQueryCompiler(); String error = null; try { comp.compile(input); } catch (final Exception e) { error = e.toString(); } return new ValidationResult.Builder().input(input).subject(subject).valid(error == null).explanation(error).build(); } catch (final Exception e) { return new ValidationResult.Builder().input(input).subject(subject).valid(false) .explanation("Unable to initialize XQuery engine due to " + e.toString()).build(); } } }