/** * Associate this Controller with a compiled stylesheet. * <p> * This method is intended for internal use only. * * @param sheet the compiled stylesheet */ public void setPreparedStylesheet(PreparedStylesheet sheet) { preparedStylesheet = sheet; executable = sheet.getExecutable(); //setOutputProperties(sheet.getOutputProperties()); // above line deleted for bug 490964 - may have side-effects }
/** * Associate this Controller with a compiled stylesheet. * <p> * This method is intended for internal use only. * * @param sheet the compiled stylesheet */ public void setPreparedStylesheet(PreparedStylesheet sheet) { preparedStylesheet = sheet; executable = sheet.getExecutable(); //setOutputProperties(sheet.getOutputProperties()); // above line deleted for bug 490964 - may have side-effects }
/** * Load a PreparedStylesheet from a compiled stylesheet stored in a file. * @param config The Configuration. <b>This method changes the NamePool used by this configuration * to be the NamePool that was stored with the compiled stylesheet. The method must therefore not * be used in a multi-threaded environment where the Configuration (and NamePool) are shared between * multiple concurrent transformations.</b> * @param ois The ObjectInputStream containing the compiled stylesheet (which is just the Java serialization * of a PreparedStylesheet object). * @return the PreparedStylesheet, which can be used in JAXP interfaces as the Templates object */ public static PreparedStylesheet loadCompiledStylesheet(Configuration config, ObjectInputStream ois) throws IOException, ClassNotFoundException { PreparedStylesheet sheet = (PreparedStylesheet)ois.readObject(); ois.close(); NamePool compiledNamePool = sheet.getTargetNamePool(); sheet.setConfiguration(config); sheet.getExecutable().setConfiguration(config); config.setNamePool(compiledNamePool); NamePool.setDefaultNamePool(compiledNamePool); return sheet; }
/** * Load a PreparedStylesheet from a compiled stylesheet stored in a file. * @param config The Configuration. <b>This method changes the NamePool used by this configuration * to be the NamePool that was stored with the compiled stylesheet. The method must therefore not * be used in a multi-threaded environment where the Configuration (and NamePool) are shared between * multiple concurrent transformations.</b> * @param ois The ObjectInputStream containing the compiled stylesheet (which is just the Java serialization * of a PreparedStylesheet object). * @return the PreparedStylesheet, which can be used in JAXP interfaces as the Templates object */ public static PreparedStylesheet loadCompiledStylesheet(Configuration config, ObjectInputStream ois) throws IOException, ClassNotFoundException { PreparedStylesheet sheet = (PreparedStylesheet)ois.readObject(); ois.close(); NamePool compiledNamePool = sheet.getTargetNamePool(); sheet.setConfiguration(config); sheet.getExecutable().setConfiguration(config); config.setNamePool(compiledNamePool); NamePool.setDefaultNamePool(compiledNamePool); return sheet; }
XPathContext getXPathContext(TestEntry test, String sourcesName, XdmNode contextNode) throws Exception { XPathContext context = null; if (test.usesContext()) { XsltExecutable xe = engine.loadExecutable(test, sourcesName); Executable ex = xe.getUnderlyingCompiledStylesheet() .getExecutable(); context = new XPathContextMajor(contextNode.getUnderlyingNode(), ex); } return context; }
XPathContext getXPathContext(TestEntry test, String sourcesName, XdmNode contextNode) throws Exception { XPathContext context = null; if (test.usesContext()) { XsltExecutable xe = engine.loadExecutable(test, sourcesName); Executable ex = xe.getUnderlyingCompiledStylesheet() .getExecutable(); context = new XPathContextMajor(contextNode.getUnderlyingNode(), ex); } return context; }
/** * Produce an XML representation of the compiled and optimized stylesheet * @param presenter defines the destination and format of the output */ public void explain(ExpressionPresenter presenter) { presenter.startElement("stylesheet"); getExecutable().getKeyManager().explainKeys(presenter); getExecutable().explainGlobalVariables(presenter); getExecutable().getRuleManager().explainTemplateRules(presenter); getExecutable().explainNamedTemplates(presenter); FunctionLibraryList libList = (FunctionLibraryList)getExecutable().getFunctionLibrary(); List libraryList = libList.getLibraryList(); presenter.startElement("functions"); for (int i=0; i<libraryList.size(); i++) { FunctionLibrary lib = (FunctionLibrary)libraryList.get(i); if (lib instanceof ExecutableFunctionLibrary) { for (Iterator f = ((ExecutableFunctionLibrary)lib).iterateFunctions(); f.hasNext();) { UserFunction func = (UserFunction)f.next(); presenter.startElement("function"); presenter.emitAttribute("name", func.getFunctionName().getDisplayName()); presenter.emitAttribute("line", func.getLineNumber()+""); presenter.emitAttribute("module", func.getSystemId()); func.getBody().explain(presenter); presenter.endElement(); } } } presenter.endElement(); presenter.endElement(); }
/** * Produce an XML representation of the compiled and optimized stylesheet * @param presenter defines the destination and format of the output */ public void explain(ExpressionPresenter presenter) { presenter.startElement("stylesheet"); getExecutable().getKeyManager().explainKeys(presenter); getExecutable().explainGlobalVariables(presenter); getExecutable().getRuleManager().explainTemplateRules(presenter); getExecutable().explainNamedTemplates(presenter); FunctionLibraryList libList = (FunctionLibraryList)getExecutable().getFunctionLibrary(); List libraryList = libList.getLibraryList(); presenter.startElement("functions"); for (int i=0; i<libraryList.size(); i++) { FunctionLibrary lib = (FunctionLibrary)libraryList.get(i); if (lib instanceof ExecutableFunctionLibrary) { for (Iterator f = ((ExecutableFunctionLibrary)lib).iterateFunctions(); f.hasNext();) { UserFunction func = (UserFunction)f.next(); presenter.startElement("function"); presenter.emitAttribute("name", func.getFunctionName().getDisplayName()); presenter.emitAttribute("line", func.getLineNumber()+""); presenter.emitAttribute("module", func.getSystemId()); func.getBody().explain(presenter); presenter.endElement(); } } } presenter.endElement(); presenter.endElement(); }
String msg = ((PreparedStylesheet)sheet).getExecutable().getReasonUnableToCompile(); if (msg != null) { System.err.println(msg);
String msg = ((PreparedStylesheet)sheet).getExecutable().getReasonUnableToCompile(); if (msg != null) { System.err.println(msg);