/** * 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; }
if (extNsMgr.namespaceIndex(declNamespace, extNsMgr.getExtensions()) == -1) extNsSpt = extNsMgr.defineJavaNamespace(declNamespace); else if (extNsMgr.namespaceIndex(srcURL, extNsMgr.getExtensions()) == -1) extNsSpt = extNsMgr.defineJavaNamespace(declNamespace, srcURL); extNsMgr.registerExtension(extNsSpt);
/** * 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(); }
/** * 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)
/** * If necessary, register the extension namespace found compiling a function or * creating an extension element. * * If it is a predefined namespace, create a * support object to simplify the instantiate of an appropriate ExtensionHandler * during transformation runtime. Otherwise, add the namespace, if necessary, * to a vector of undefined extension namespaces, to be defined later. * */ public void registerExtension(String namespace) { if (namespaceIndex(namespace, m_extensions) == -1) { int predef = namespaceIndex(namespace, m_predefExtensions); if (predef !=-1) m_extensions.add(m_predefExtensions.get(predef)); else if (!(m_unregisteredExtensions.contains(namespace))) m_unregisteredExtensions.add(namespace); } }
/** * If the function is an extension function, register the namespace. * * @param owner The current XPath object that owns the expression. * @param func The function currently being visited. * * @return true to continue the visit in the subtree, if any. */ public boolean visitFunction(ExpressionOwner owner, Function func) { if (func instanceof FuncExtFunction) { String namespace = ((FuncExtFunction)func).getNamespace(); m_sroot.getExtensionNamespacesManager().registerExtension(namespace); } else if (func instanceof FuncExtFunctionAvailable) { String arg = ((FuncExtFunctionAvailable)func).getArg0().toString(); if (arg.indexOf(":") > 0) { String prefix = arg.substring(0,arg.indexOf(":")); String namespace = this.m_sroot.getNamespaceForPrefix(prefix); m_sroot.getExtensionNamespacesManager().registerExtension(namespace); } } return true; }
/** * 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; }
m_extNsMgr.registerUnregisteredNamespaces();
/** * 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)
/** * If necessary, register the extension namespace found compiling a function or * creating an extension element. * * If it is a predefined namespace, create a * support object to simplify the instantiate of an appropriate ExtensionHandler * during transformation runtime. Otherwise, add the namespace, if necessary, * to a vector of undefined extension namespaces, to be defined later. * */ public void registerExtension(String namespace) { if (namespaceIndex(namespace, m_extensions) == -1) { int predef = namespaceIndex(namespace, m_predefExtensions); if (predef !=-1) m_extensions.add(m_predefExtensions.get(predef)); else if (!(m_unregisteredExtensions.contains(namespace))) m_unregisteredExtensions.add(namespace); } }
/** * If the function is an extension function, register the namespace. * * @param owner The current XPath object that owns the expression. * @param func The function currently being visited. * * @return true to continue the visit in the subtree, if any. */ public boolean visitFunction(ExpressionOwner owner, Function func) { if (func instanceof FuncExtFunction) { String namespace = ((FuncExtFunction)func).getNamespace(); m_sroot.getExtensionNamespacesManager().registerExtension(namespace); } else if (func instanceof FuncExtFunctionAvailable) { String arg = ((FuncExtFunctionAvailable)func).getArg0().toString(); if (arg.indexOf(":") > 0) { String prefix = arg.substring(0,arg.indexOf(":")); String namespace = this.m_sroot.getNamespaceForPrefix(prefix); m_sroot.getExtensionNamespacesManager().registerExtension(namespace); } } return true; }
/** * 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; }
m_extNsMgr.registerUnregisteredNamespaces();
if (extNsMgr.namespaceIndex(declNamespace, extNsMgr.getExtensions()) == -1) extNsSpt = extNsMgr.defineJavaNamespace(declNamespace); else if (extNsMgr.namespaceIndex(srcURL, extNsMgr.getExtensions()) == -1) extNsSpt = extNsMgr.defineJavaNamespace(declNamespace, srcURL); extNsMgr.registerExtension(extNsSpt);
/** * 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); } }
/** * 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); } }
/** * This function is called after everything else has been * recomposed, and allows the template to set remaining * values that may be based on some other property that * depends on recomposition. */ public void compose(StylesheetRoot sroot) throws TransformerException { super.compose(sroot); m_extns = this.getNamespace(); m_decl = getElemExtensionDecl(sroot, m_extns); // Register the extension namespace if the extension does not have // an ElemExtensionDecl ("component"). if (m_decl == null) sroot.getExtensionNamespacesManager().registerExtension(m_extns); }
/** * 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; }
/** * 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; }
/** * 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(); }