Example usage for org.dom4j.rule Stylesheet applyTemplates

List of usage examples for org.dom4j.rule Stylesheet applyTemplates

Introduction

In this page you can find the example usage for org.dom4j.rule Stylesheet applyTemplates.

Prototype

public void applyTemplates(List<? extends Node> list, String mode) throws Exception 

Source Link

Document

Processes the input object in the given mode.

Usage

From source file:org.apache.taglibs.xtags.xpath.ApplyTemplatesTag.java

License:Apache License

public int doEndTag() throws JspException {
    flush();//from   w  ww .j  av a 2 s .co  m
    Stylesheet stylesheet = getStylesheet();
    if (stylesheet == null) {
        throw new JspException("applytemplates tag requires a Stylesheet to be in scope");
    } else {
        try {
            // Tell the current TemplateTag to put its output in the Stylesheet's output list,
            // otherwise the order of the output will be incorrect.
            TemplateTag templateTag = (TemplateTag) findAncestorWithClass(this, TemplateTag.class);
            templateTag.preApplyTemplates();

            Object context = getInputNodes();
            if (xpath != null) {
                stylesheet.applyTemplates(context, xpath);
            } else {
                stylesheet.applyTemplates(context);
            }
            // restore the context back to what it was
            setInputNodes(context);
        } catch (JspException e) {
            throw e;
        } catch (Exception e) {
            handleException(e);
        }
    }
    return EVAL_PAGE;
}