/** * Static factory method: Compile an XSLT stylesheet consisting of a single package * * @param config the Saxon Configuration * @param compilerInfo the compilation options * @param source the source of the root stylesheet module in the package to be compiled. This may * contain an xsl:package element at its root, or it may be a conventional xsl:stylesheet or xsl:transform, * or a "simplified stylesheet" rooted at a literal result element * @return the PreparedStylesheet representing the result of the compilation * @throws XPathException if any errors occur. The errors will have been reported to the ErrorListener * contained in the CompilerInfo. */ public static PreparedStylesheet compileSingletonPackage(Configuration config, CompilerInfo compilerInfo, Source source) throws XPathException { try { Compilation compilation = new Compilation(config, compilerInfo); return StylesheetModule.loadStylesheet(source, compilation); } catch (XPathException err) { if (!err.hasBeenReported()) { try { compilerInfo.getErrorListener().fatalError(err); } catch (TransformerException e2) { // ignore error } } throw err; } }
/** * Static factory method: Compile an XSLT stylesheet consisting of a single package * * @param config the Saxon Configuration * @param compilerInfo the compilation options * @param source the source of the root stylesheet module in the package to be compiled. This may * contain an xsl:package element at its root, or it may be a conventional xsl:stylesheet or xsl:transform, * or a "simplified stylesheet" rooted at a literal result element * @return the PreparedStylesheet representing the result of the compilation * @throws XPathException if any errors occur. The errors will have been reported to the ErrorListener * contained in the CompilerInfo. */ public static PreparedStylesheet compileSingletonPackage(Configuration config, CompilerInfo compilerInfo, Source source) throws XPathException { try { Compilation compilation = new Compilation(config, compilerInfo); return StylesheetModule.loadStylesheet(source, compilation); } catch (XPathException err) { if (!err.hasBeenReported()) { try { compilerInfo.getErrorListener().fatalError(err); } catch (TransformerException e2) { // ignore error } } throw err; } }
testForCycles(details, disallowed); details.beingProcessed = Thread.currentThread(); Compilation compilation = new Compilation(config, compilerInfo); compilation.setUsingPackages(disallowed); compilation.setExpectedNameAndVersion(details.nameAndVersion);
testForCycles(details, disallowed); details.beingProcessed = Thread.currentThread(); Compilation compilation = new Compilation(config, compilerInfo); compilation.setUsingPackages(disallowed); compilation.setExpectedNameAndVersion(details.nameAndVersion);
/** * Link this package with the packages it uses, to form an executable stylesheet. This process fixes * up any cross-package references to files, templates, and other components, and checks to ensure * that all such references are consistent. * * @return the resulting XsltExecutable * @throws SaxonApiException if any error is found during the linking process, for example * if the constituent packages containing duplicate component names, or if abstract components * are not resolved. */ public XsltExecutable link() throws SaxonApiException { try { Configuration config = processor.getUnderlyingConfiguration(); CompilerInfo info = config.makeCompilerInfo(); Compilation compilation = new Compilation(config, info); stylesheetPackage.checkForAbstractComponents(); PreparedStylesheet pss = new PreparedStylesheet(compilation); stylesheetPackage.updatePreparedStylesheet(pss); pss.addPackage(stylesheetPackage); return new XsltExecutable(processor, pss); } catch (XPathException e) { throw new SaxonApiException(e); } }
/** * Link this package with the packages it uses, to form an executable stylesheet. This process fixes * up any cross-package references to files, templates, and other components, and checks to ensure * that all such references are consistent. * * @return the resulting XsltExecutable * @throws SaxonApiException if any error is found during the linking process, for example * if the constituent packages containing duplicate component names, or if abstract components * are not resolved. */ public XsltExecutable link() throws SaxonApiException { try { Configuration config = getProcessor().getUnderlyingConfiguration(); CompilerInfo info = compiler.getUnderlyingCompilerInfo(); Compilation compilation = new Compilation(config, info); compilation.setPackageData(stylesheetPackage); stylesheetPackage.checkForAbstractComponents(); PreparedStylesheet pss = new PreparedStylesheet(compilation); stylesheetPackage.updatePreparedStylesheet(pss); pss.addPackage(stylesheetPackage); return new XsltExecutable(getProcessor(), pss); } catch (XPathException e) { throw new SaxonApiException(e); } }
compilation = ((StyleElement)((DocumentImpl) source).getDocumentElement()).getCompilation(); } else { compilation = new Compilation(config, new CompilerInfo(compilerInfo));
compilation = ((StyleElement)((DocumentImpl) source).getDocumentElement()).getCompilation(); } else { compilation = new Compilation(config, new CompilerInfo(compilerInfo));
/** * Create a TemplatesHandlerImpl and initialise variables. The constructor is protected, because * the Filter should be created using newTemplatesHandler() in the SAXTransformerFactory * class * * @param processor the Saxon s9api processor */ protected TemplatesHandlerImpl(Processor processor) { this.processor = processor; Configuration config = processor.getUnderlyingConfiguration(); setPipelineConfiguration(config.makePipelineConfiguration()); CompilerInfo info = new CompilerInfo(config.getDefaultXsltCompilerInfo()); Compilation compilation = new Compilation(config, info); nodeFactory = compilation.getStyleNodeFactory(true); builder = new LinkedTreeBuilder(getPipelineConfiguration()); builder.setNodeFactory(nodeFactory); builder.setLineNumbering(true); UseWhenFilter useWhenFilter = new UseWhenFilter(compilation, builder, NestedIntegerValue.TWO); StartTagBuffer startTagBuffer = new StartTagBuffer(useWhenFilter); useWhenFilter.setStartTagBuffer(startTagBuffer); StylesheetSpaceStrippingRule rule = new StylesheetSpaceStrippingRule(config.getNamePool()); Stripper styleStripper = new Stripper(rule, startTagBuffer); CommentStripper commentStripper = new CommentStripper(styleStripper); setReceiver(commentStripper); }
/** * Create a TemplatesHandlerImpl and initialise variables. The constructor is protected, because * the Filter should be created using newTemplatesHandler() in the SAXTransformerFactory * class * * @param processor the Saxon s9api processor */ protected TemplatesHandlerImpl(Processor processor) { this.processor = processor; Configuration config = processor.getUnderlyingConfiguration(); setPipelineConfiguration(config.makePipelineConfiguration()); CompilerInfo info = new CompilerInfo(config.getDefaultXsltCompilerInfo()); Compilation compilation = new Compilation(config, info); nodeFactory = compilation.getStyleNodeFactory(true); builder = new LinkedTreeBuilder(getPipelineConfiguration()); builder.setNodeFactory(nodeFactory); builder.setLineNumbering(true); UseWhenFilter useWhenFilter = new UseWhenFilter(compilation, builder, NestedIntegerValue.TWO); StartTagBuffer startTagBuffer = new StartTagBuffer(useWhenFilter); useWhenFilter.setStartTagBuffer(startTagBuffer); StylesheetSpaceStrippingRule rule = new StylesheetSpaceStrippingRule(config.getNamePool()); Stripper styleStripper = new Stripper(rule, startTagBuffer); CommentStripper commentStripper = new CommentStripper(styleStripper); setReceiver(commentStripper); }