Search in sources :

Example 1 with ExtensionNamespaceSupport

use of org.apache.xalan.extensions.ExtensionNamespaceSupport in project j2objc by google.

the class ElemExsltFunction method compose.

/**
   * Called after everything else has been
   * recomposed, and allows the function 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);
    // Register the function namespace (if not already registered).
    String namespace = getName().getNamespace();
    String handlerClass = sroot.getExtensionHandlerClass();
    Object[] args = { namespace, sroot };
    ExtensionNamespaceSupport extNsSpt = new ExtensionNamespaceSupport(namespace, handlerClass, args);
    sroot.getExtensionNamespacesManager().registerExtension(extNsSpt);
    // -- for isElementAvailable().    
    if (!(namespace.equals(Constants.S_EXSLT_FUNCTIONS_URL))) {
        namespace = Constants.S_EXSLT_FUNCTIONS_URL;
        args = new Object[] { namespace, sroot };
        extNsSpt = new ExtensionNamespaceSupport(namespace, handlerClass, args);
        sroot.getExtensionNamespacesManager().registerExtension(extNsSpt);
    }
}
Also used : ExtensionNamespaceSupport(org.apache.xalan.extensions.ExtensionNamespaceSupport) XObject(org.apache.xpath.objects.XObject)

Example 2 with ExtensionNamespaceSupport

use of org.apache.xalan.extensions.ExtensionNamespaceSupport in project robovm by robovm.

the class ElemExsltFunction method compose.

/**
   * Called after everything else has been
   * recomposed, and allows the function 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);
    // Register the function namespace (if not already registered).
    String namespace = getName().getNamespace();
    String handlerClass = sroot.getExtensionHandlerClass();
    Object[] args = { namespace, sroot };
    ExtensionNamespaceSupport extNsSpt = new ExtensionNamespaceSupport(namespace, handlerClass, args);
    sroot.getExtensionNamespacesManager().registerExtension(extNsSpt);
    // -- for isElementAvailable().    
    if (!(namespace.equals(Constants.S_EXSLT_FUNCTIONS_URL))) {
        namespace = Constants.S_EXSLT_FUNCTIONS_URL;
        args = new Object[] { namespace, sroot };
        extNsSpt = new ExtensionNamespaceSupport(namespace, handlerClass, args);
        sroot.getExtensionNamespacesManager().registerExtension(extNsSpt);
    }
}
Also used : ExtensionNamespaceSupport(org.apache.xalan.extensions.ExtensionNamespaceSupport) XObject(org.apache.xpath.objects.XObject)

Example 3 with ExtensionNamespaceSupport

use of org.apache.xalan.extensions.ExtensionNamespaceSupport in project robovm by robovm.

the class ElemExtensionDecl method compose.

public void compose(StylesheetRoot sroot) throws TransformerException {
    super.compose(sroot);
    String prefix = getPrefix();
    String declNamespace = getNamespaceForPrefix(prefix);
    String lang = null;
    String srcURL = null;
    String scriptSrc = null;
    if (null == declNamespace)
        throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_NAMESPACE_DECL, new Object[] { prefix }));
    //"Prefix " + prefix does not have a corresponding namespace declaration");
    for (ElemTemplateElement child = getFirstChildElem(); child != null; child = child.getNextSiblingElem()) {
        if (Constants.ELEMNAME_EXTENSIONSCRIPT == child.getXSLToken()) {
            ElemExtensionScript sdecl = (ElemExtensionScript) child;
            lang = sdecl.getLang();
            srcURL = sdecl.getSrc();
            ElemTemplateElement childOfSDecl = sdecl.getFirstChildElem();
            if (null != childOfSDecl) {
                if (Constants.ELEMNAME_TEXTLITERALRESULT == childOfSDecl.getXSLToken()) {
                    ElemTextLiteral tl = (ElemTextLiteral) childOfSDecl;
                    char[] chars = tl.getChars();
                    scriptSrc = new String(chars);
                    if (scriptSrc.trim().length() == 0)
                        scriptSrc = null;
                }
            }
        }
    }
    if (null == lang)
        lang = "javaclass";
    if (lang.equals("javaclass") && (scriptSrc != null))
        throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_ELEM_CONTENT_NOT_ALLOWED, new Object[] { scriptSrc }));
    //"Element content not allowed for lang=javaclass " + scriptSrc);
    // Register the extension namespace if it has not already been registered.
    ExtensionNamespaceSupport extNsSpt = null;
    ExtensionNamespacesManager extNsMgr = sroot.getExtensionNamespacesManager();
    if (extNsMgr.namespaceIndex(declNamespace, extNsMgr.getExtensions()) == -1) {
        if (lang.equals("javaclass")) {
            if (null == srcURL) {
                extNsSpt = extNsMgr.defineJavaNamespace(declNamespace);
            } else if (extNsMgr.namespaceIndex(srcURL, extNsMgr.getExtensions()) == -1) {
                extNsSpt = extNsMgr.defineJavaNamespace(declNamespace, srcURL);
            }
        } else // not java
        {
            String handler = "org.apache.xalan.extensions.ExtensionHandlerGeneral";
            Object[] args = { declNamespace, this.m_elements, this.m_functions, lang, srcURL, scriptSrc, getSystemId() };
            extNsSpt = new ExtensionNamespaceSupport(declNamespace, handler, args);
        }
    }
    if (extNsSpt != null)
        extNsMgr.registerExtension(extNsSpt);
}
Also used : ExtensionNamespaceSupport(org.apache.xalan.extensions.ExtensionNamespaceSupport) TransformerException(javax.xml.transform.TransformerException) ExtensionNamespacesManager(org.apache.xalan.extensions.ExtensionNamespacesManager)

Example 4 with ExtensionNamespaceSupport

use of org.apache.xalan.extensions.ExtensionNamespaceSupport in project j2objc by google.

the class ElemExtensionDecl method compose.

public void compose(StylesheetRoot sroot) throws TransformerException {
    super.compose(sroot);
    String prefix = getPrefix();
    String declNamespace = getNamespaceForPrefix(prefix);
    String lang = null;
    String srcURL = null;
    String scriptSrc = null;
    if (null == declNamespace)
        throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_NAMESPACE_DECL, new Object[] { prefix }));
    //"Prefix " + prefix does not have a corresponding namespace declaration");
    for (ElemTemplateElement child = getFirstChildElem(); child != null; child = child.getNextSiblingElem()) {
        if (Constants.ELEMNAME_EXTENSIONSCRIPT == child.getXSLToken()) {
            ElemExtensionScript sdecl = (ElemExtensionScript) child;
            lang = sdecl.getLang();
            srcURL = sdecl.getSrc();
            ElemTemplateElement childOfSDecl = sdecl.getFirstChildElem();
            if (null != childOfSDecl) {
                if (Constants.ELEMNAME_TEXTLITERALRESULT == childOfSDecl.getXSLToken()) {
                    ElemTextLiteral tl = (ElemTextLiteral) childOfSDecl;
                    char[] chars = tl.getChars();
                    scriptSrc = new String(chars);
                    if (scriptSrc.trim().length() == 0)
                        scriptSrc = null;
                }
            }
        }
    }
    if (null == lang)
        lang = "javaclass";
    if (lang.equals("javaclass") && (scriptSrc != null))
        throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_ELEM_CONTENT_NOT_ALLOWED, new Object[] { scriptSrc }));
    //"Element content not allowed for lang=javaclass " + scriptSrc);
    // Register the extension namespace if it has not already been registered.
    ExtensionNamespaceSupport extNsSpt = null;
    ExtensionNamespacesManager extNsMgr = sroot.getExtensionNamespacesManager();
    if (extNsMgr.namespaceIndex(declNamespace, extNsMgr.getExtensions()) == -1) {
        if (lang.equals("javaclass")) {
            if (null == srcURL) {
                extNsSpt = extNsMgr.defineJavaNamespace(declNamespace);
            } else if (extNsMgr.namespaceIndex(srcURL, extNsMgr.getExtensions()) == -1) {
                extNsSpt = extNsMgr.defineJavaNamespace(declNamespace, srcURL);
            }
        } else // not java
        {
            String handler = "org.apache.xalan.extensions.ExtensionHandlerGeneral";
            Object[] args = { declNamespace, this.m_elements, this.m_functions, lang, srcURL, scriptSrc, getSystemId() };
            extNsSpt = new ExtensionNamespaceSupport(declNamespace, handler, args);
        }
    }
    if (extNsSpt != null)
        extNsMgr.registerExtension(extNsSpt);
}
Also used : ExtensionNamespaceSupport(org.apache.xalan.extensions.ExtensionNamespaceSupport) TransformerException(javax.xml.transform.TransformerException) ExtensionNamespacesManager(org.apache.xalan.extensions.ExtensionNamespacesManager)

Aggregations

ExtensionNamespaceSupport (org.apache.xalan.extensions.ExtensionNamespaceSupport)4 TransformerException (javax.xml.transform.TransformerException)2 ExtensionNamespacesManager (org.apache.xalan.extensions.ExtensionNamespacesManager)2 XObject (org.apache.xpath.objects.XObject)2