Search in sources :

Example 11 with TagFileInfo

use of javax.servlet.jsp.tagext.TagFileInfo in project sling by apache.

the class JspDocumentParser method parseCustomAction.

/*
     * Checks if the XML element with the given tag name is a custom action,
     * and returns the corresponding Node object.
     */
private Node parseCustomAction(String qName, String localName, String uri, Attributes nonTaglibAttrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) throws SAXException {
    // Check if this is a user-defined (custom) tag
    TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
    if (tagLibInfo == null) {
        return null;
    }
    TagInfo tagInfo = tagLibInfo.getTag(localName);
    TagFileInfo tagFileInfo = tagLibInfo.getTagFile(localName);
    if (tagInfo == null && tagFileInfo == null) {
        throw new SAXException(Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri));
    }
    Class tagHandlerClass = null;
    if (tagInfo != null) {
        String handlerClassName = tagInfo.getTagClassName();
        try {
            tagHandlerClass = ctxt.getClassLoader().loadClass(handlerClassName);
        } catch (Exception e) {
            throw new SAXException(Localizer.getMessage("jsp.error.loadclass.taghandler", handlerClassName, qName), e);
        }
    }
    String prefix = "";
    int colon = qName.indexOf(':');
    if (colon != -1) {
        prefix = qName.substring(0, colon);
    }
    Node.CustomTag ret = null;
    if (tagInfo != null) {
        ret = new Node.CustomTag(qName, prefix, localName, uri, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent, tagInfo, tagHandlerClass);
    } else {
        ret = new Node.CustomTag(qName, prefix, localName, uri, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent, tagFileInfo);
    }
    return ret;
}
Also used : TagFileInfo(javax.servlet.jsp.tagext.TagFileInfo) TagInfo(javax.servlet.jsp.tagext.TagInfo) TagLibraryInfo(javax.servlet.jsp.tagext.TagLibraryInfo) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SAXParseException(org.xml.sax.SAXParseException) SAXException(org.xml.sax.SAXException) JasperException(org.apache.sling.scripting.jsp.jasper.JasperException) SAXException(org.xml.sax.SAXException)

Aggregations

TagFileInfo (javax.servlet.jsp.tagext.TagFileInfo)11 TagInfo (javax.servlet.jsp.tagext.TagInfo)9 FileNotFoundException (java.io.FileNotFoundException)4 TagLibraryInfo (javax.servlet.jsp.tagext.TagLibraryInfo)4 JasperException (org.apache.jasper.JasperException)3 JasperException (org.apache.sling.scripting.jsp.jasper.JasperException)3 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 FunctionInfo (javax.servlet.jsp.tagext.FunctionInfo)2 TreeNode (org.apache.sling.scripting.jsp.jasper.xmlparser.TreeNode)2 Attributes (org.xml.sax.Attributes)2 SAXException (org.xml.sax.SAXException)2 SAXParseException (org.xml.sax.SAXParseException)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Enumeration (java.util.Enumeration)1 Hashtable (java.util.Hashtable)1 Vector (java.util.Vector)1 ServletContext (javax.servlet.ServletContext)1 Context (org.apache.catalina.Context)1