/** * 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); }
/** * 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 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 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; } }
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); } }); }
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); } }); }
/** * Make a pattern in the context of this stylesheet element * * @param pattern the source text of the pattern * @return the compiled pattern */ public Pattern makePattern(String pattern, String attributeName) { try { StaticContext env = getStaticContext(new StructuredQName("", "", attributeName)); Pattern p = Pattern.make(pattern, env, getCompilation().getPackageData()); p.setLocation(allocateLocation()); return p; } catch (XPathException err) { if ("XPST0003".equals(err.getErrorCodeLocalPart())) { err.setErrorCode("XTSE0340"); } compileError(err); NodeTestPattern nsp = new NodeTestPattern(AnyNodeTest.getInstance()); nsp.setLocation(allocateLocation()); return nsp; } }
/** * Make a pattern in the context of this stylesheet element * * @param pattern the source text of the pattern * @return the compiled pattern */ public Pattern makePattern(String pattern, String attributeName) { try { StaticContext env = getStaticContext(new StructuredQName("", "", attributeName)); Pattern p = Pattern.make(pattern, env, getCompilation().getPackageData()); p.setLocation(allocateLocation()); return p; } catch (XPathException err) { if ("XPST0003".equals(err.getErrorCodeLocalPart())) { err.setErrorCode("XTSE0340"); } compileError(err); NodeTestPattern nsp = new NodeTestPattern(AnyNodeTest.getInstance()); nsp.setLocation(allocateLocation()); return nsp; } }
prepareAttributes(); UserFunction fn = getConfiguration().newUserFunction(memoFunction, streamability); fn.setPackageData(getCompilation().getPackageData()); fn.setFunctionName(getObjectName()); setParameterDefinitions(fn);
prepareAttributes(); UserFunction fn = getConfiguration().newUserFunction(memoFunction, streamability); fn.setPackageData(getCompilation().getPackageData()); fn.setFunctionName(getObjectName()); setParameterDefinitions(fn);
/** * Create a static context for evaluating use-when expressions * * @param compilation the package compilation episode * @param namespaceContext the namespace context in which the static expression appears */ public UseWhenStaticContext(Compilation compilation, NamespaceResolver namespaceContext) { Configuration config = compilation.getConfiguration(); setConfiguration(config); this.compilation = compilation; setPackageData(compilation.getPackageData()); this.namespaceContext = namespaceContext; setXPathLanguageLevel(31); FunctionLibraryList lib = new FunctionLibraryList(); lib.addFunctionLibrary(config.getUseWhenFunctionSet()); lib.addFunctionLibrary(getConfiguration().getBuiltInExtensionLibraryList()); lib.addFunctionLibrary(new ConstructorFunctionLibrary(getConfiguration())); lib.addFunctionLibrary(config.getIntegratedFunctionLibrary()); config.addExtensionBinders(lib); functionLibrary = lib; }
/** * Create a static context for evaluating use-when expressions * * @param compilation the package compilation episode * @param namespaceContext the namespace context in which the static expression appears */ public UseWhenStaticContext(Compilation compilation, NamespaceResolver namespaceContext) { Configuration config = compilation.getConfiguration(); setConfiguration(config); this.compilation = compilation; setPackageData(compilation.getPackageData()); this.namespaceContext = namespaceContext; setXPathLanguageLevel(31); FunctionLibraryList lib = new FunctionLibraryList(); lib.addFunctionLibrary(config.getUseWhenFunctionSet()); lib.addFunctionLibrary(getConfiguration().getBuiltInExtensionLibraryList()); lib.addFunctionLibrary(new ConstructorFunctionLibrary(getConfiguration())); lib.addFunctionLibrary(config.getIntegratedFunctionLibrary()); config.addExtensionBinders(lib); functionLibrary = lib; }
/** * 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(); }
/** * 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(); }
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); }
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); }
/** * Compile a global xsl:param element: this ensures space is available for local variables declared within * this global variable */ public void compileDeclaration(Compilation compilation, ComponentDeclaration decl) throws XPathException { if (sourceBinding.isStatic()) { super.compileDeclaration(compilation, decl); } else if (!redundant) { sourceBinding.handleSequenceConstructor(compilation, decl); GlobalParam binding = (GlobalParam)compiledVariable; binding.setPackageData(getCompilation().getPackageData()); binding.makeDeclaringComponent(Visibility.PUBLIC, getContainingPackage()); Expression select = sourceBinding.getSelectExpression(); binding.setSelectExpression(select); binding.setVariableQName(sourceBinding.getVariableQName()); initializeBinding(binding); binding.setRequiredType(getRequiredType()); binding.setRequiredParam(sourceBinding.hasProperty(SourceBinding.REQUIRED)); binding.setImplicitlyRequiredParam(sourceBinding.hasProperty(SourceBinding.IMPLICITLY_REQUIRED)); sourceBinding.fixupBinding(binding); //compiledVariable = binding; Component overridden = getOverriddenComponent(); if (overridden != null) { checkCompatibility(overridden); } } }
/** * Compile a global xsl:param element: this ensures space is available for local variables declared within * this global variable */ public void compileDeclaration(Compilation compilation, ComponentDeclaration decl) throws XPathException { if (sourceBinding.isStatic()) { super.compileDeclaration(compilation, decl); } else if (!redundant) { sourceBinding.handleSequenceConstructor(compilation, decl); GlobalParam binding = (GlobalParam)compiledVariable; binding.setPackageData(getCompilation().getPackageData()); binding.makeDeclaringComponent(Visibility.PUBLIC, getContainingPackage()); Expression select = sourceBinding.getSelectExpression(); binding.setSelectExpression(select); binding.setVariableQName(sourceBinding.getVariableQName()); initializeBinding(binding); binding.setRequiredType(getRequiredType()); binding.setRequiredParam(sourceBinding.hasProperty(SourceBinding.REQUIRED)); binding.setImplicitlyRequiredParam(sourceBinding.hasProperty(SourceBinding.IMPLICITLY_REQUIRED)); sourceBinding.fixupBinding(binding); //compiledVariable = binding; Component overridden = getOverriddenComponent(); if (overridden != null) { checkCompatibility(overridden); } } }
/** * Get the corresponding Procedure object that results from the compilation of this * StylesheetProcedure */ public Actor getActor() throws XPathException { GlobalVariable gv = getCompiledVariable(); if (gv == null) { gv = this instanceof XSLGlobalParam ? new GlobalParam() : new GlobalVariable(); gv.setPackageData(getCompilation().getPackageData()); gv.makeDeclaringComponent(getVisibility(), getContainingPackage()); gv.setRequiredType(sourceBinding.getDeclaredType()); gv.setDeclaredVisibility(getDeclaredVisibility()); gv.setVariableQName(sourceBinding.getVariableQName()); gv.setSystemId(getSystemId()); gv.setLineNumber(getLineNumber()); RetainedStaticContext rsc = makeRetainedStaticContext(); gv.setRetainedStaticContext(rsc); if (gv.getBody() != null) { gv.getBody().setRetainedStaticContext(rsc); } compiledVariable = gv; } return gv; }
/** * Get the corresponding Procedure object that results from the compilation of this * StylesheetProcedure */ public Actor getActor() throws XPathException { GlobalVariable gv = getCompiledVariable(); if (gv == null) { gv = this instanceof XSLGlobalParam ? new GlobalParam() : new GlobalVariable(); gv.setPackageData(getCompilation().getPackageData()); gv.makeDeclaringComponent(getVisibility(), getContainingPackage()); gv.setRequiredType(sourceBinding.getDeclaredType()); gv.setDeclaredVisibility(getDeclaredVisibility()); gv.setVariableQName(sourceBinding.getVariableQName()); gv.setSystemId(getSystemId()); gv.setLineNumber(getLineNumber()); RetainedStaticContext rsc = makeRetainedStaticContext(); gv.setRetainedStaticContext(rsc); if (gv.getBody() != null) { gv.getBody().setRetainedStaticContext(rsc); } compiledVariable = gv; } return gv; }