Search in sources :

Example 6 with TagLibraryInfo

use of javax.servlet.jsp.tagext.TagLibraryInfo 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

TagLibraryInfo (javax.servlet.jsp.tagext.TagLibraryInfo)6 FileNotFoundException (java.io.FileNotFoundException)4 TagFileInfo (javax.servlet.jsp.tagext.TagFileInfo)4 TagInfo (javax.servlet.jsp.tagext.TagInfo)4 IOException (java.io.IOException)2 JasperException (org.apache.jasper.JasperException)2 JasperException (org.apache.sling.scripting.jsp.jasper.JasperException)2 Attributes (org.xml.sax.Attributes)2 SAXException (org.xml.sax.SAXException)2 SAXParseException (org.xml.sax.SAXParseException)2 TldResourcePath (org.apache.tomcat.util.descriptor.tld.TldResourcePath)1