/** * Get the processor under which this package was created * * @return the corresponding Processor */ public Processor getProcessor() { return compiler.getProcessor(); }
/** * Declare the default collation * * @param uri the absolute URI of the default collation. Either this URI must have been bound to a collation * using the method {@link Configuration#registerCollation(String, StringCollator)}, or it must be a * collation that is recognized implicitly, such as a UCA collation * @throws IllegalStateException if the collation URI is not a recognized collation * @since 9.5 */ public void declareDefaultCollation(String uri) { StringCollator c; try { c = getProcessor().getUnderlyingConfiguration().getCollation(uri); } catch (XPathException e) { c = null; } if (c == null) { throw new IllegalStateException("Unknown collation " + uri); } compilerInfo.setDefaultCollation(uri); }
/** * Declare the default collation * * @param uri the absolute URI of the default collation. Either this URI must have been bound to a collation * using the method {@link Configuration#registerCollation(String, StringCollator)}, or it must be a * collation that is recognized implicitly, such as a UCA collation * @throws IllegalStateException if the collation URI is not a recognized collation * @since 9.5 */ public void declareDefaultCollation(String uri) { StringCollator c; try { c = getProcessor().getUnderlyingConfiguration().getCollation(uri); } catch (XPathException e) { c = null; } if (c == null) { throw new IllegalStateException("Unknown collation " + uri); } compilerInfo.setDefaultCollation(uri); }
/** * Apply XSLT 3.0 static parameters to a compilerInfo. Actually this sets all parameter values, whether static or dynamic. * This is possible because the stylesheet is compiled for once-only use. * * @param compiler The XsltCompiler object into which the parameters are copied * @throws SaxonApiException if invalid options are found */ public void applyStaticParams(XsltCompiler compiler) throws SaxonApiException { Processor processor = compiler.getProcessor(); for (Enumeration e = paramValues.propertyNames(); e.hasMoreElements(); ) { String name = (String) e.nextElement(); String value = paramValues.getProperty(name); compiler.setParameter(QName.fromClarkName(name), new XdmAtomicValue(value, ItemType.UNTYPED_ATOMIC)); } for (Enumeration e = paramExpressions.propertyNames(); e.hasMoreElements(); ) { String name = (String) e.nextElement(); String value = paramExpressions.getProperty(name); // parameters starting with "?" are taken as XPath expressions XPathCompiler xpc = processor.newXPathCompiler(); XPathExecutable xpe = xpc.compile(value); XdmValue val = xpe.load().evaluate(); compiler.setParameter(QName.fromClarkName(name), val); } }
/** * Apply XSLT 3.0 static parameters to a compilerInfo. Actually this sets all parameter values, whether static or dynamic. * This is possible because the stylesheet is compiled for once-only use. * * @param compiler The XsltCompiler object into which the parameters are copied * @throws SaxonApiException if invalid options are found */ public void applyStaticParams(XsltCompiler compiler) throws SaxonApiException { Processor processor = compiler.getProcessor(); for (Enumeration e = paramValues.propertyNames(); e.hasMoreElements(); ) { String name = (String) e.nextElement(); String value = paramValues.getProperty(name); compiler.setParameter(QName.fromClarkName(name), new XdmAtomicValue(value, ItemType.UNTYPED_ATOMIC)); } for (Enumeration e = paramExpressions.propertyNames(); e.hasMoreElements(); ) { String name = (String) e.nextElement(); String value = paramExpressions.getProperty(name); // parameters starting with "?" are taken as XPath expressions XPathCompiler xpc = processor.newXPathCompiler(); XPathExecutable xpe = xpc.compile(value); XdmValue val = xpe.load().evaluate(); compiler.setParameter(QName.fromClarkName(name), val); } }
/** * Request fast compilation. Fast compilation will generally be achieved at the expense of run-time performance * and quality of diagnostics. Fast compilation is a good trade-off if (a) the stylesheet is known to be correct, * and (b) once compiled, it is only executed once against a document of modest size. * <p>Fast compilation may result in static errors going unreported, especially if they occur in code * that is never executed.</p> * <p><i>The current implementation is equivalent to switching off all optimizations other than just-in-time * compilation of template rules. Setting this option, however, indicates an intent rather than a mechanism, * and the implementation details may change in future to reflect the intent.</i></p> * * @param fast set to true to request fast compilation; set to false to revert to the optimization options * defined in the Configuration. * @since 9.9 */ public void setFastCompilation(boolean fast) { if (fast) { // The only optimizer option that speeds up compilation is JIT. compilerInfo.setOptimizerOptions(new OptimizerOptions(OptimizerOptions.JIT)); } else { compilerInfo.setOptimizerOptions(getProcessor().getUnderlyingConfiguration().getOptimizerOptions()); } }
/** * Request fast compilation. Fast compilation will generally be achieved at the expense of run-time performance * and quality of diagnostics. Fast compilation is a good trade-off if (a) the stylesheet is known to be correct, * and (b) once compiled, it is only executed once against a document of modest size. * <p>Fast compilation may result in static errors going unreported, especially if they occur in code * that is never executed.</p> * <p><i>The current implementation is equivalent to switching off all optimizations other than just-in-time * compilation of template rules. Setting this option, however, indicates an intent rather than a mechanism, * and the implementation details may change in future to reflect the intent.</i></p> * * @param fast set to true to request fast compilation; set to false to revert to the optimization options * defined in the Configuration. * @since 9.9 */ public void setFastCompilation(boolean fast) { if (fast) { // The only optimizer option that speeds up compilation is JIT. compilerInfo.setOptimizerOptions(new OptimizerOptions(OptimizerOptions.JIT)); } else { compilerInfo.setOptimizerOptions(getProcessor().getUnderlyingConfiguration().getOptimizerOptions()); } }
style = xsltCompiler.getProcessor().getUnderlyingConfiguration().getSystemURIResolver().resolve(stylesheetLocation, base);
style = xsltCompiler.getProcessor().getUnderlyingConfiguration().getSystemURIResolver().resolve(stylesheetLocation, base);