/** * Determine at run-time whether a particular instruction is available. Returns true * only in the case of XSLT instructions and Saxon extension instructions; returns false * for user-defined extension instructions * @param uri the namespace URI of the element * @param localname the local part of the element name * @param context the XPath evaluation context * @return true if the instruction is available, in the sense of the XSLT element-available() function */ private boolean isElementAvailable(String uri, String localname, XPathContext context) { // This is horribly inefficient. But hopefully it's hardly ever executed, because there // is very little point calling element-available() with a dynamically-constructed argument. // And the inefficiency is only incurred once, on the first call. // Note: this requires the compile-time classes to be available at run-time; it will need // changing if we ever want to build a run-time JAR file. try { if (styleNodeFactory==null) { Configuration config = context.getConfiguration(); styleNodeFactory = new StyleNodeFactory(config, context.getController().getErrorListener()); } return styleNodeFactory.isElementAvailable(uri, localname); } catch (Exception err) { //err.printStackTrace(); return false; } }
/** * Method to support the element-available() function * @param uri the namespace URI * @param localName the local Name * @return true if an extension element of this name is recognized */ public boolean isElementAvailable(String uri, String localName) { int fingerprint = namePool.getFingerprint(uri, localName); if (uri.equals(NamespaceConstant.XSLT)) { if (fingerprint==-1) return false; // all names are pre-registered StyleElement e = makeXSLElement(fingerprint); if (e!=null) return e.isInstruction(); } if (uri.equals(NamespaceConstant.SAXON)) { if (fingerprint==-1) return false; // all names are pre-registered StyleElement e = makeSaxonElement(fingerprint); if (e!=null) return e.isInstruction(); } if (!allowExtensions) { // extension elements are disabled return false; } short uriCode = namePool.getCodeForURI(uri); ExtensionElementFactory factory = getFactory(uriCode); if (factory==null) return false; Class actualClass = factory.getExtensionClass(localName); return (actualClass != null); }
/** * Get the StyleNodeFactory used to build the stylesheet tree * * @param topLevel true if the factory is for the top-level (package) module of a package * @return the StyleNodeFactory */ public StyleNodeFactory getStyleNodeFactory(boolean topLevel) { StyleNodeFactory factory = getConfiguration().makeStyleNodeFactory(this); factory.setTopLevelModule(topLevel); return factory; }
/** * Factory method to make the StyleNodeFactory, used for constructing elements * in a stylesheet document * * @param compilation the compilation episode (compiling one package) * @return the StyleNodeFactory used in this Configuration */ public StyleNodeFactory makeStyleNodeFactory(Compilation compilation) { return new StyleNodeFactory(this, compilation); }
/** * Determine if an extension element is available * * @throws XPathException if the name is invalid or the prefix is not declared */ public boolean isElementAvailable(String qname) throws XPathException { try { String[] parts = NameChecker.getQNameParts(qname); String uri; if (parts[0].isEmpty()) { uri = getDefaultElementNamespace(); } else { uri = element.getURIForPrefix(parts[0], false); } return element.getCompilation().getStyleNodeFactory(true).isElementAvailable(uri, parts[1], true); } catch (QNameException e) { XPathException err = new XPathException("Invalid element name. " + e.getMessage()); err.setErrorCode("XTDE1440"); throw err; } }
/** * Method to support the element-available() function * * * @param uri the namespace URI * @param localName the local Name * @param instructionsOnly true if only instruction elements qualify * @return true if an extension element of this name is recognized */ public boolean isElementAvailable(String uri, String localName, boolean instructionsOnly) { int fingerprint = namePool.getFingerprint(uri, localName); if (uri.equals(NamespaceConstant.XSLT)) { if (fingerprint == -1) { return false; // all names are pre-registered } StyleElement e = makeXSLElement(fingerprint, null); if (e != null) { return !instructionsOnly || e.isInstruction(); } } return false; }
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); }
PrincipalStylesheetModule psm = factory.newPrincipalModule(xslpackage); StylesheetPackage pack = psm.getStylesheetPackage(); pack.setVersion(xslpackage.getVersion());
/** * Factory method to make the StyleNodeFactory, used for constructing elements * in a stylesheet document * * @param compilation the compilation episode (compiling one package) * @return the StyleNodeFactory used in this Configuration */ public StyleNodeFactory makeStyleNodeFactory(Compilation compilation) { return new StyleNodeFactory(this, compilation); }
/** * Determine if an extension element is available * * @throws net.sf.saxon.trans.XPathException * if the name is invalid or the prefix is not declared */ public boolean isElementAvailable(String qname) throws XPathException { try { String[] parts = NameChecker.getQNameParts(qname); String uri; if (parts[0].isEmpty()) { uri = getDefaultElementNamespace(); } else { uri = namespaceContext.getURIForPrefix(parts[0], false); } StyleNodeFactory factory = getConfiguration().makeStyleNodeFactory(compilation); return factory.isElementAvailable(uri, parts[1], true); } catch (QNameException e) { XPathException err = new XPathException("Invalid element name. " + e.getMessage()); err.setErrorCode("XTDE1440"); throw err; } }
/** * Method to support the element-available() function * * * @param uri the namespace URI * @param localName the local Name * @param instructionsOnly true if only instruction elements qualify * @return true if an extension element of this name is recognized */ public boolean isElementAvailable(String uri, String localName, boolean instructionsOnly) { int fingerprint = namePool.getFingerprint(uri, localName); if (uri.equals(NamespaceConstant.XSLT)) { if (fingerprint == -1) { return false; // all names are pre-registered } StyleElement e = makeXSLElement(fingerprint, null); if (e != null) { return !instructionsOnly || e.isInstruction(); } } return false; }
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); }
PrincipalStylesheetModule psm = factory.newPrincipalModule(xslpackage); StylesheetPackage pack = psm.getStylesheetPackage(); pack.setVersion(xslpackage.getVersion());
/** * Method to support the element-available() function * @param uri the namespace URI * @param localName the local Name * @return true if an extension element of this name is recognized */ public boolean isElementAvailable(String uri, String localName) { int fingerprint = namePool.getFingerprint(uri, localName); if (uri.equals(NamespaceConstant.XSLT)) { if (fingerprint==-1) return false; // all names are pre-registered StyleElement e = makeXSLElement(fingerprint); if (e!=null) return e.isInstruction(); } if (uri.equals(NamespaceConstant.SAXON)) { if (fingerprint==-1) return false; // all names are pre-registered StyleElement e = makeSaxonElement(fingerprint); if (e!=null) return e.isInstruction(); } if (!allowExtensions) { // extension elements are disabled return false; } short uriCode = namePool.getCodeForURI(uri); ExtensionElementFactory factory = getFactory(uriCode); if (factory==null) return false; Class actualClass = factory.getExtensionClass(localName); return (actualClass != null); }
/** * Determine at run-time whether a particular instruction is available. Returns true * only in the case of XSLT instructions and Saxon extension instructions; returns false * for user-defined extension instructions * @param uri the namespace URI of the element * @param localname the local part of the element name * @param context the XPath evaluation context * @return true if the instruction is available, in the sense of the XSLT element-available() function */ private boolean isElementAvailable(String uri, String localname, XPathContext context) { // This is horribly inefficient. But hopefully it's hardly ever executed, because there // is very little point calling element-available() with a dynamically-constructed argument. // And the inefficiency is only incurred once, on the first call. // Note: this requires the compile-time classes to be available at run-time; it will need // changing if we ever want to build a run-time JAR file. try { if (styleNodeFactory==null) { Configuration config = context.getConfiguration(); styleNodeFactory = new StyleNodeFactory(config, context.getController().getErrorListener()); } return styleNodeFactory.isElementAvailable(uri, localname); } catch (Exception err) { //err.printStackTrace(); return false; } }
nodeFactory = new StyleNodeFactory(config, errorListener); DocumentImpl doc; try {
/** * Determine if an extension element is available * * @throws XPathException if the name is invalid or the prefix is not declared */ public boolean isElementAvailable(String qname) throws XPathException { try { String[] parts = NameChecker.getQNameParts(qname); String uri; if (parts[0].isEmpty()) { uri = getDefaultElementNamespace(); } else { uri = element.getURIForPrefix(parts[0], false); } return element.getCompilation().getStyleNodeFactory(true).isElementAvailable(uri, parts[1], true); } catch (QNameException e) { XPathException err = new XPathException("Invalid element name. " + e.getMessage()); err.setErrorCode("XTDE1440"); throw err; } }
StyleElement e = makeXSLElement(f, (NodeImpl)parent); if ((e instanceof XSLStylesheet || e instanceof XSLPackage) && parent.getNodeKind() != Type.DOCUMENT) { e = new AbsentExtensionElement();
/** * Get the StyleNodeFactory used to build the stylesheet tree * * @param topLevel true if the factory is for the top-level (package) module of a package * @return the StyleNodeFactory */ public StyleNodeFactory getStyleNodeFactory(boolean topLevel) { StyleNodeFactory factory = getConfiguration().makeStyleNodeFactory(this); factory.setTopLevelModule(topLevel); return factory; }
/** * Method to support the element-available() function * @param uri the namespace URI * @param localName the local Name * @return true if an extension element of this name is recognized */ public boolean isElementAvailable(String uri, String localName) { int fingerprint = namePool.getFingerprint(uri, localName); if (uri.equals(NamespaceConstant.XSLT)) { if (fingerprint==-1) return false; // all names are pre-registered StyleElement e = makeXSLElement(fingerprint); if (e!=null) return e.isInstruction(); } if (uri.equals(NamespaceConstant.SAXON)) { if (fingerprint==-1) return false; // all names are pre-registered StyleElement e = makeSaxonElement(fingerprint); if (e!=null) return e.isInstruction(); } if (!allowExtensions) { // extension elements are disabled return false; } short uriCode = namePool.getCodeForURI(uri); ExtensionElementFactory factory = getFactory(uriCode); if (factory==null) return false; Class actualClass = factory.getExtensionClass(localName); return (actualClass != null); }