net.sf.saxon.Configuration Java Examples
The following examples show how to use
net.sf.saxon.Configuration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SaxonEngine.java From jlibs with Apache License 2.0 | 6 votes |
@Override public List<Object> evaluate(TestCase testCase, String file) throws Exception{ XPathFactoryImpl xpf = new XPathFactoryImpl(); XPathEvaluator xpe = (XPathEvaluator)xpf.newXPath(); xpe.getConfiguration().setVersionWarning(false); ((StandardErrorListener)xpe.getConfiguration().getErrorListener()).setRecoveryPolicy(Configuration.RECOVER_SILENTLY); xpe.getStaticContext().setBackwardsCompatibilityMode(true); xpe.setXPathVariableResolver(testCase.variableResolver); xpe.setXPathFunctionResolver(testCase.functionResolver); xpe.setNamespaceContext(testCase.nsContext); NodeInfo doc = xpe.getConfiguration().buildDocument(new SAXSource(new InputSource(file))); List<Object> results = new ArrayList<Object>(testCase.xpaths.size()); for(XPathInfo xpathInfo: testCase.xpaths){ if(xpathInfo.forEach==null) results.add(xpe.evaluate(xpathInfo.xpath, doc, xpathInfo.resultType)); else{ List<Object> list = new ArrayList<Object>(); List nodeList = (List)xpe.evaluate(xpathInfo.forEach, doc, XPathConstants.NODESET); for(Object context: nodeList) list.add(xpe.evaluate(xpathInfo.xpath, context, xpathInfo.resultType)); results.add(list); } } return results; }
Example #2
Source File: JDKEngine.java From jlibs with Apache License 2.0 | 5 votes |
@Override public List<Object> evaluate(TestCase testCase, String file) throws Exception{ Document doc = toDOM(file); List<Object> results = new ArrayList<Object>(testCase.xpaths.size()); XPath xpathObj = factory.newXPath(); if(xpathObj instanceof XPathEvaluator){ XPathEvaluator xpe = (XPathEvaluator)xpathObj; xpe.getConfiguration().setVersionWarning(false); ((StandardErrorListener)xpe.getConfiguration().getErrorListener()).setRecoveryPolicy(Configuration.RECOVER_SILENTLY); xpe.getStaticContext().setBackwardsCompatibilityMode(true); } for(XPathInfo xpathInfo: testCase.xpaths){ xpathObj.setXPathVariableResolver(testCase.variableResolver); xpathObj.setXPathFunctionResolver(testCase.functionResolver); xpathObj.setNamespaceContext(testCase.nsContext); if(xpathInfo.forEach==null) results.add(xpathObj.evaluate(xpathInfo.xpath, doc, xpathInfo.resultType)); else{ List<Object> list = new ArrayList<Object>(); NodeList nodeList = (NodeList)xpathObj.evaluate(xpathInfo.forEach, doc, XPathConstants.NODESET); for(int i=0; i<nodeList.getLength(); i++){ Object context = nodeList.item(i); list.add(xpathObj.evaluate(xpathInfo.xpath, context, xpathInfo.resultType)); } results.add(list); } } return results; }
Example #3
Source File: XPathFunctionFromUserFunction.java From ph-schematron with Apache License 2.0 | 5 votes |
public XPathFunctionFromUserFunction (@Nonnull final Configuration aConfiguration, @Nonnull final Controller aXQController, @Nonnull final UserFunction aUserFunc) { m_aConfiguration = ValueEnforcer.notNull (aConfiguration, "Configuration"); m_aUserFunc = ValueEnforcer.notNull (aUserFunc, "UserFunc"); m_aXQController = ValueEnforcer.notNull (aXQController, "XQController"); }
Example #4
Source File: SaxonDebuggerApp.java From intellij-xquery with Apache License 2.0 | 5 votes |
@Override protected void doAdditionalConfiguration(Processor processor) { Configuration configuration = processor.getUnderlyingConfiguration(); configuration.setBooleanProperty(FeatureKeys.EAGER_EVALUATION, true); StaticQueryContext context = configuration.getDefaultStaticQueryContext(); configuration.setTraceListener(new SaxonTraceListener(this)); context.setCodeInjector(new SaxonExtendedTraceCodeInjector()); Optimizer optimizer = configuration.obtainOptimizer(); optimizer.setOptimizationLevel(Optimizer.NO_OPTIMIZATION); }
Example #5
Source File: SaxonXQDataSourceFactory.java From intellij-xquery with Apache License 2.0 | 5 votes |
@Override public XQDataSource getXQDataSource(XQueryRunConfig config) throws Exception { if (config.isConfigFileEnabled()) { File configFile = new File(config.getConfigFile()); Configuration configuration = Configuration.readConfiguration(new StreamSource(configFile)); return new SaxonXQDataSource(configuration); } return new SaxonXQDataSource(); }
Example #6
Source File: Engine.java From teamengine with Apache License 2.0 | 5 votes |
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(); }
Example #7
Source File: Engine.java From teamengine with Apache License 2.0 | 5 votes |
public void addFunctionLibrary(Collection<Index> indexes) { // Change the function library to a new library list that includes // our custom java function library Configuration config = processor.getUnderlyingConfiguration(); FunctionLibraryList liblist = new FunctionLibraryList(); for (Index index : indexes) { TEFunctionLibrary telib = new TEFunctionLibrary(config, index); liblist.addFunctionLibrary(telib); } liblist.addFunctionLibrary(config.getExtensionBinder("java")); config.setExtensionBinder("java", liblist); }
Example #8
Source File: StrictRelativeResolvingStrategy.java From validator with Apache License 2.0 | 4 votes |
@Override public Reader resolve(final URI absoluteURI, final String encoding, final Configuration config) throws XPathException { throw new IllegalStateException(MESSAGE); }
Example #9
Source File: XmlXPathEvaluator.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
public XmlXPathEvaluator() { FunctionLibrary javaFunctionLibrary = evaluator.getConfiguration().getExtensionBinder("java"); Configuration.getPlatform().declareJavaClass(javaFunctionLibrary, TAG_NAME_FUNCTIONS_NAMESPACE_URI, TagName.class); }
Example #10
Source File: PSXPathBoundSchema.java From ph-schematron with Apache License 2.0 | 4 votes |
@Nonnull private XPath _createXPathContext () { final MapBasedNamespaceContext aNamespaceContext = getNamespaceContext (); final XPath aXPathContext = XPathHelper.createNewXPath (m_aXPathConfig.getXPathFactory (), m_aXPathConfig.getXPathVariableResolver (), m_aXPathConfig.getXPathFunctionResolver (), aNamespaceContext); if ("net.sf.saxon.xpath.XPathEvaluator".equals (aXPathContext.getClass ().getName ())) { // Saxon implementation special handling final XPathEvaluator aSaxonXPath = (XPathEvaluator) aXPathContext; // Since 9.7.0-4 it must implement NamespaceResolver aSaxonXPath.setNamespaceContext (new SaxonNamespaceContext (aNamespaceContext)); // Wrap the PSErrorHandler to a ErrorListener final Function <Configuration, ? extends ErrorReporter> factory = cfg -> { final IPSErrorHandler aErrHdl = getErrorHandler (); return (final XmlProcessingError error) -> { final ILocation aLocation = error.getLocation () == null ? null : new SimpleLocation (error.getLocation () .getSystemId (), error.getLocation () .getLineNumber (), error.getLocation () .getColumnNumber ()); aErrHdl.handleError (SingleError.builder () .setErrorLevel (error.isWarning () ? EErrorLevel.WARN : EErrorLevel.ERROR) .setErrorID (error.getErrorCode () != null ? error.getErrorCode ().toString () : null) .setErrorLocation (aLocation) .setErrorText (error.getMessage ()) .setLinkedException (error.getCause ()) .build ()); }; }; aSaxonXPath.getConfiguration ().setErrorReporterFactory (factory); } return aXPathContext; }
Example #11
Source File: SaxonExpressionEvaluator.java From intellij-xquery with Apache License 2.0 | 4 votes |
@Override public Configuration getConfiguration() { return original.getConfiguration(); }
Example #12
Source File: SaxonRunnerApp.java From intellij-xquery with Apache License 2.0 | 4 votes |
private Configuration getConfiguration(XQueryRunConfig config) throws XPathException { File configFile = new File(config.getConfigFile()); return Configuration.readConfiguration(new StreamSource(configFile)); }
Example #13
Source File: TEFunctionLibrary.java From teamengine with Apache License 2.0 | 4 votes |
public TEFunctionLibrary(Configuration config, Index index) { this.config = config; this.index = index; }