/** * Only instantiate an ExtensionNamespacesManager if one is called for * (i.e., if the stylesheet contains extension functions and/or elements). */ public ExtensionNamespacesManager getExtensionNamespacesManager() { if (m_extNsMgr == null) m_extNsMgr = new ExtensionNamespacesManager(); return m_extNsMgr; }
/** * Get the vector of extension namespaces. Used to provide * the extensions table access to a list of extension * namespaces encountered during composition of a stylesheet. */ public Vector getExtensions() { return m_extNsMgr != null ? m_extNsMgr.getExtensions() : null; }
/** * An ExtensionNamespacesManager is instantiated the first time an extension function or * element is found in the stylesheet. During initialization, a vector of ExtensionNamespaceSupport * objects is created, one for each predefined extension namespace. */ public ExtensionNamespacesManager() { setPredefinedNamespaces(); }
/** * Register the extension namespace for an ElemExtensionDecl or ElemFunction, * and prepare a support object to launch the appropriate ExtensionHandler at * transformation runtime. */ public void registerExtension(ExtensionNamespaceSupport extNsSpt) { String namespace = extNsSpt.getNamespace(); if (namespaceIndex(namespace, m_extensions) == -1) { m_extensions.add(extNsSpt); if (m_unregisteredExtensions.contains(namespace)) m_unregisteredExtensions.remove(namespace); } }
/** * @see javax.xml.xpath.XPathFunction#evaluate(java.util.List) */ public Object evaluate(List args) throws XPathFunctionException { Vector argsVec = listToVector(args); try { // The method key and ExpressionContext are set to null. return m_handler.callFunction(m_funcName, argsVec, null, null); } catch (TransformerException e) { throw new XPathFunctionException(e); } }
/** * For any extension namespace that is not either predefined or defined * by a "component" declaration or exslt function declaration, attempt * to create an ExtensionNamespaceSuport object for the appropriate * Java class or Java package Extension Handler. * * Called by StylesheetRoot.recompose(), after all ElemTemplate compose() * operations have taken place, in order to set up handlers for * the remaining extension namespaces. * * @param ns The extension namespace URI. * @return An ExtensionNamespaceSupport object for this namespace * (which defines the ExtensionHandler to be used), or null if such * an object cannot be created. * * @throws javax.xml.transform.TransformerException */ public ExtensionNamespaceSupport defineJavaNamespace(String ns) { return defineJavaNamespace(ns, ns); } public ExtensionNamespaceSupport defineJavaNamespace(String ns, String classOrPackage)
public boolean functionAvailable(String ns, String funcName) throws javax.xml.transform.TransformerException { return getExtensionsTable().functionAvailable(ns, funcName); }
public boolean elementAvailable(String ns, String elemName) throws javax.xml.transform.TransformerException { return getExtensionsTable().elementAvailable(ns, elemName); }
/** * Does the EXSLT function exist? * * @param funcName Local name of the function. * @return true if the function exists. */ public boolean isFunctionAvailable(String funcName) { return getFunction(funcName)!= null; }
public Iterator getPrefixes(String namespace) { final String result = getPrefix(namespace); return new Iterator () { private boolean isFirstIteration = (result != null); public boolean hasNext() { return isFirstIteration; } public Object next() { if (isFirstIteration) { isFirstIteration = false; return result; } else return null; } public void remove() { throw new UnsupportedOperationException(); } }; } }
/** * Finds the implementation Class object in the specified order. The * specified order is the following: * <ol> * <li>query the system property using <code>System.getProperty</code> * <li>read <code>META-INF/services/<i>factoryId</i></code> file * <li>use fallback classname * </ol> * * @return instance of factory, never null * * @param factoryId Name of the factory to find, same as * a property name * @param fallbackClassName Implementation class name, if nothing else * is found. Use null to mean no fallback. * * @exception ObjectFactory.ConfigurationError */ static Object createObject(String factoryId, String fallbackClassName) throws ConfigurationError { return createObject(factoryId, null, fallbackClassName); } // createObject(String,String):Object
/** * Construct a new extension namespace handler given all the information * needed. * @param namespaceUri the extension namespace URI that I'm implementing * @param scriptLang language of code implementing the extension * @param className the fully qualified class name of the class */ public ExtensionHandlerJavaClass(String namespaceUri, String scriptLang, String className) { super(namespaceUri, scriptLang, className); try { m_classObj = getClassForName(className); } catch (ClassNotFoundException e) { // For now, just let this go. We'll catch it when we try to invoke a method. } }
/** * Register the extension namespace for an ElemExtensionDecl or ElemFunction, * and prepare a support object to launch the appropriate ExtensionHandler at * transformation runtime. */ public void registerExtension(ExtensionNamespaceSupport extNsSpt) { String namespace = extNsSpt.getNamespace(); if (namespaceIndex(namespace, m_extensions) == -1) { m_extensions.add(extNsSpt); if (m_unregisteredExtensions.contains(namespace)) m_unregisteredExtensions.remove(namespace); } }
/** * Attempt to register any unregistered extension namespaces. */ public void registerUnregisteredNamespaces() { for (int i = 0; i < m_unregisteredExtensions.size(); i++) { String ns = (String)m_unregisteredExtensions.get(i); ExtensionNamespaceSupport extNsSpt = defineJavaNamespace(ns); if (extNsSpt != null) m_extensions.add(extNsSpt); } }
/** * Only instantiate an ExtensionNamespacesManager if one is called for * (i.e., if the stylesheet contains extension functions and/or elements). */ public ExtensionNamespacesManager getExtensionNamespacesManager() { if (m_extNsMgr == null) m_extNsMgr = new ExtensionNamespacesManager(); return m_extNsMgr; }
/** * Get the vector of extension namespaces. Used to provide * the extensions table access to a list of extension * namespaces encountered during composition of a stylesheet. */ public Vector getExtensions() { return m_extNsMgr != null ? m_extNsMgr.getExtensions() : null; }
/** * An ExtensionNamespacesManager is instantiated the first time an extension function or * element is found in the stylesheet. During initialization, a vector of ExtensionNamespaceSupport * objects is created, one for each predefined extension namespace. */ public ExtensionNamespacesManager() { setPredefinedNamespaces(); }
public boolean functionAvailable(String ns, String funcName) throws javax.xml.transform.TransformerException { return getExtensionsTable().functionAvailable(ns, funcName); }
public boolean elementAvailable(String ns, String elemName) throws javax.xml.transform.TransformerException { return getExtensionsTable().elementAvailable(ns, elemName); }
/** * Attempt to register any unregistered extension namespaces. */ public void registerUnregisteredNamespaces() { for (int i = 0; i < m_unregisteredExtensions.size(); i++) { String ns = (String)m_unregisteredExtensions.get(i); ExtensionNamespaceSupport extNsSpt = defineJavaNamespace(ns); if (extNsSpt != null) m_extensions.add(extNsSpt); } }