testForCycles(details, disallowed); details.beingProcessed = Thread.currentThread(); Compilation compilation = new Compilation(config, compilerInfo); compilation.setUsingPackages(disallowed); compilation.setExpectedNameAndVersion(details.nameAndVersion); compilation.clearParameters(); compilation.setLibraryPackage(true); if (details.staticParams != null) { for (Map.Entry<StructuredQName, GroundedValue<?>> entry : details.staticParams.entrySet()) { compilation.setParameter(entry.getKey(), entry.getValue()); PrincipalStylesheetModule psm = compilation.compilePackage(details.sourceLocation); details.beingProcessed = null; if (compilation.getErrorCount() > 0) { throw new XPathException("Errors found in package " + details.nameAndVersion.packageName);
/** * Prepare Stylesheet to render the analyzed XML data out. * This method can be overridden in a subclass to produce the output in a different format. */ /*@NotNull*/ protected PreparedStylesheet getStyleSheet() throws XPathException { InputStream in = getStylesheetInputStream(); StreamSource ss = new StreamSource(in, "profile.xsl"); CompilerInfo info = config.getDefaultXsltCompilerInfo(); info.setParameter(new StructuredQName("", "", "lang"), new StringValue(this.lang == Configuration.XSLT ? "XSLT" : "XQuery")); return Compilation.compileSingletonPackage(config, info, ss); }
private static void gatherUsePackageDeclarations(Compilation compilation, StyleElement wrapper, List<XSLUsePackage> declarations) throws XPathException { wrapper.iterateAxis(AxisInfo.CHILD).forEachOrFail(use -> { if (use instanceof XSLUsePackage) { declarations.add((XSLUsePackage) use); } else if (use instanceof XSLInclude) { String href = Whitespace.trim(use.getAttributeValue("", "href")); URIResolver resolver = compilation.getCompilerInfo().getURIResolver(); DocumentURI key = DocumentFn.computeDocumentKey(href, use.getBaseURI(), compilation.getPackageData(), resolver, false); TreeInfo includedTree = compilation.getStylesheetModules().get(key); StyleElement incWrapper = (StyleElement) ((DocumentImpl) includedTree.getRootNode()).getDocumentElement(); gatherUsePackageDeclarations(compilation, incWrapper, declarations); } }); }
public void setMinimalPackageData() { if (getPackageData() == null) { // Create a temporary PackageData for use during use-when processing PackageData pd = new PackageData(getConfiguration()); pd.setHostLanguage(Configuration.XSLT); pd.setTargetEdition(compilerInfo.getTargetEdition()); pd.setSchemaAware(schemaAware); packageData = pd; } }
public Expression compile(Compilation exec, ComponentDeclaration decl) { CopyOf inst = new CopyOf(select, copyNamespaces, validation, schemaType, false); inst.setCopyAccumulators(copyAccumulators); inst.setCopyLineNumbers(exec.getConfiguration().isLineNumbering()); inst.setSchemaAware(exec.isSchemaAware()); return inst; }
compilation.getConfiguration().getBooleanProperty(Feature.IGNORE_SAX_SOURCE_PARSER)) { if (systemId != null && compilation.getImportStack().contains(docURI)) { throw new XPathException("The stylesheet module includes/imports itself directly or indirectly", "XTSE0180"); compilation.getImportStack().push(docURI); compilation.setMinimalPackageData(); Configuration config = compilation.getConfiguration(); PipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setErrorListener(compilation.getCompilerInfo().getErrorListener()); pipe.setURIResolver(compilation.getCompilerInfo().getURIResolver()); styleBuilder.setSystemId(styleSource.getSystemId()); styleBuilder.setNodeFactory(compilation.getStyleNodeFactory(true)); styleBuilder.setLineNumbering(true); compilation.setPackageData(pack); PreparedStylesheet pss = new PreparedStylesheet(compilation); pack.checkForAbstractComponents(); compilation.getImportStack().pop(); PrincipalStylesheetModule psm = compilation.compilePackage(doc); if (compilation.getErrorCount() > 0) { XPathException e = new XPathException("Errors were reported during stylesheet compilation"); e.setHasBeenReported(true); // only intended as an exception message, not something to report to ErrorListener
setMinimalPackageData(); NodeInfo document; NodeInfo outermost = null; if (!e.hasBeenReported()) { try { getCompilerInfo().getErrorListener().fatalError(e); } catch (TransformerException e1) { CompilerInfo info = getCompilerInfo(); StyleNodeFactory factory = getStyleNodeFactory(true); PrincipalStylesheetModule psm = factory.newPrincipalModule(xslpackage); StylesheetPackage pack = psm.getStylesheetPackage(); pack.setPackageVersion(xslpackage.getPackageVersion()); pack.setPackageName(xslpackage.getName()); pack.setSchemaAware(info.isSchemaAware() || isSchemaAware()); pack.createFunctionLibrary(); if (info.getExtensionFunctionLibrary() != null) { setPrincipalStylesheetModule(psm); packageData = null; satisfyPackageDependencies(xslpackage); if (getErrorCount() == 0) { try { psm.fixup(); } catch (XPathException e) {
if (systemId != null && compilation.getImportStack().contains(docURI)) { throw new XPathException("The stylesheet module includes/imports itself directly or indirectly", "XTSE0180"); compilation.getImportStack().push(docURI); Configuration config = compilation.getConfiguration(); PipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setErrorListener(compilation.getCompilerInfo().getErrorListener()); LinkedTreeBuilder styleBuilder = new LinkedTreeBuilder(pipe); pipe.setURIResolver(compilation.getCompilerInfo().getURIResolver()); styleBuilder.setSystemId(styleSource.getSystemId()); styleBuilder.setNodeFactory(compilation.getStyleNodeFactory(topLevelModule)); styleBuilder.setLineNumbering(true); compilation.getImportStack().pop(); return doc; } catch (XPathException err) { if (topLevelModule && !err.hasBeenReported()) { // bug 2244 compilation.reportError(err);
/** * Constructor - deliberately protected * * @param compilation Compilation options */ public PreparedStylesheet(Compilation compilation) { super(compilation.getConfiguration()); CompilerInfo compilerInfo = compilation.getCompilerInfo(); setHostLanguage(Configuration.XSLT); if (compilerInfo.isSchemaAware()) { int localLic = compilation.getPackageData().getLocalLicenseId(); getConfiguration().checkLicensedFeature(Configuration.LicenseFeature.ENTERPRISE_XSLT, "schema-aware XSLT", localLic); schemaAware = true; } //setSchemaAware(compilerInfo.isSchemaAware()); if (compilerInfo.getErrorListener() == null) { compilerInfo.setErrorListener(getConfiguration().getErrorListener()); } defaultInitialMode = compilerInfo.getDefaultInitialMode(); defaultInitialTemplate = compilerInfo.getDefaultInitialTemplate(); recoveryPolicy = compilerInfo.getRecoveryPolicy(); messageReceiverClassName = compilerInfo.getMessageReceiverClassName(); outputURIResolver = compilerInfo.getOutputURIResolver(); compileTimeParams = compilation.getParameters(); }
compilation = ((StyleElement)((DocumentImpl) source).getDocumentElement()).getCompilation(); } else { compilation = new Compilation(config, new CompilerInfo(compilerInfo)); compilation.setLibraryPackage(true); XsltPackage pack = new XsltPackage(this, compilation.compilePackage(source).getStylesheetPackage()); int errors = compilation.getErrorCount(); if (errors > 0) { String count = errors == 1 ? "one error" : errors + " errors";
URIResolver resolver = compilation.getCompilerInfo().getURIResolver(); String baseUriStr = baseUri.toString(); DocumentURI key = DocumentFn.computeDocumentKey(href, baseUriStr, compilation.getPackageData(), resolver, false); Map<DocumentURI, TreeInfo> map = compilation.getStylesheetModules(); if (map.containsKey(key)) { compilation.reportError(e);
/** * Get the optimization options in use. By default these are taken from the * {@link Configuration} * * @return the optimization options in use * @since 9.9 */ @Override public OptimizerOptions getOptimizerOptions() { return element.getCompilation().getCompilerInfo().getOptimizerOptions(); }
KeyManager km = getCompilation().getPrincipalStylesheetModule().getKeyManager(); SymbolicName symbolicName = new SymbolicName(StandardNames.XSL_KEY, keyName); KeyDefinition keydef = new KeyDefinition(symbolicName, match, use, collationName, collator); keydef.setPackageData(getCompilation().getPackageData()); keydef.setRangeKey(rangeKey); keydef.setIndexedItemType(useType); keydef.makeDeclaringComponent(Visibility.PRIVATE, getContainingPackage()); try { km.addKeyDefinition(keyName, keydef, !sensitive, compilation.getConfiguration()); } catch (XPathException err) { compileError(err);
SequenceType requiredType = SequenceType.ANY_SEQUENCE; int languageLevel = compilation.getConfiguration().getConfigurationProperty(Feature.XPATH_VERSION_FOR_XSLT); if (languageLevel == 30) { languageLevel = 305; // XPath 3.0 + XSLT extensions XPathParser parser = compilation.getConfiguration().newExpressionParser("XP", false, languageLevel); requiredType = parser.parseSequenceType(asStr, staticContext); boolean isSupplied = isParam && compilation.getParameters().containsKey(varName); AttributeLocation attLoc = new AttributeLocation(elemName.getStructuredQName(), new StructuredQName("", "", "select"), location); Sequence<?> suppliedValue = compilation.getParameters() .convertParameterValue(varName, requiredType, true, staticContext.makeEarlyEvaluationContext()); compilation.declareStaticVariable(varName, suppliedValue.materialize(), precedence, isParam); } else { value = asStr == null ? StringValue.EMPTY_STRING : EmptySequence.getInstance(); compilation.declareStaticVariable(varName, value, precedence, isParam); value = seq.materialize(); try { compilation.declareStaticVariable(varName, value, precedence, isParam); } catch (XPathException e) { throw createXPathException(e.getMessage(), e.getErrorCodeLocalPart(), attLoc);
public Configuration getConfiguration() { return compilation.getConfiguration(); }
/** * Say that this compilation is schema-aware. This method is called internally during the course * of a compilation if an <code>xsl:import-schema</code> declaration is encountered. * * @param schemaAware true if the compilation is schema-aware. */ public void setSchemaAware(boolean schemaAware) { this.schemaAware = schemaAware; getPackageData().setSchemaAware(schemaAware); }
public void index(ComponentDeclaration decl, PrincipalStylesheetModule top) throws XPathException { if (accumulator.getAccumulatorName() == null) { prepareSimpleAttributes(); } accumulator.setImportPrecedence(decl.getPrecedence()); if (top.getAccumulatorManager() == null) { StyleNodeFactory styleNodeFactory = getCompilation().getStyleNodeFactory(true); AccumulatorRegistry manager = styleNodeFactory.makeAccumulatorManager(); top.setAccumulatorManager(manager); getCompilation().getPackageData().setAccumulatorRegistry(manager); } AccumulatorRegistry mgr = top.getAccumulatorManager(); Accumulator existing = mgr.getAccumulator(accumulator.getAccumulatorName()); if (existing != null) { int existingPrec = existing.getImportPrecedence(); if (existingPrec == decl.getPrecedence()) { compileError("There are two accumulators with the same name (" + accumulator.getAccumulatorName().getDisplayName() + ") and the same import precedence", "XTSE3350"); } if (existingPrec > decl.getPrecedence()) { return; } } mgr.addAccumulator(accumulator); }
/** * 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); }
if (!jitCompilationDone) { jitCompilationDone = true; compilation.setPreScan(false); processAllAttributes(); if (compilation.getErrorCount() > 0) { XPathException e = new XPathException("Errors were reported during stylesheet compilation"); e.setHasBeenReported(true); // only intended as an exception message, not something to report to ErrorListener if (compilation.getErrorCount() > 0) { XPathException e = new XPathException("Errors were reported during stylesheet compilation"); e.setHasBeenReported(true); // only intended as an exception message, not something to report to ErrorListener if (compilation.getErrorCount() > 0) { XPathException e = new XPathException("Errors were reported during stylesheet compilation"); e.setHasBeenReported(true); // only intended as an exception message, not something to report to ErrorListener
if (inst == null) { inst = new GlobalVariable(); inst.setPackageData(getCompilation().getPackageData()); inst.makeDeclaringComponent(getVisibility(), getContainingPackage()); inst.setVariableQName(sourceBinding.getVariableQName()); inst.setStatic(true); GroundedValue<?> value = compilation.getStaticVariable(sourceBinding.getVariableQName()); if (value == null) { throw new AssertionError();