001    /* 
002     * This file is part of the Echo Point Project.  This project is a collection
003     * of Components that have extended the Echo Web Application Framework.
004     *
005     * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006     *
007     * The contents of this file are subject to the Mozilla Public License Version
008     * 1.1 (the "License"); you may not use this file except in compliance with
009     * the License. You may obtain a copy of the License at
010     * http://www.mozilla.org/MPL/
011     *
012     * Software distributed under the License is distributed on an "AS IS" basis,
013     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014     * for the specific language governing rights and limitations under the
015     * License.
016     *
017     * Alternatively, the contents of this file may be used under the terms of
018     * either the GNU General Public License Version 2 or later (the "GPL"), or
019     * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020     * in which case the provisions of the GPL or the LGPL are applicable instead
021     * of those above. If you wish to allow use of your version of this file only
022     * under the terms of either the GPL or the LGPL, and not to allow others to
023     * use your version of this file under the terms of the MPL, indicate your
024     * decision by deleting the provisions above and replace them with the notice
025     * and other provisions required by the GPL or the LGPL. If you do not delete
026     * the provisions above, a recipient may use your version of this file under
027     * the terms of any one of the MPL, the GPL or the LGPL.
028     */
029    package echopoint.template.ui;
030    
031    import nextapp.echo.webcontainer.Connection;
032    
033    import org.w3c.dom.Element;
034    
035    import echopoint.template.TemplateDataSource;
036    
037    /** 
038     * <code>TemplateCompiler</code> are responsible for
039     * compiling template data into a XHTML DOM element, ready
040     * to be inserted into the rendering output.
041     * <p>
042     * A peer lookup mechanism is used to find the 
043     * TemplateCompiler for a given content type.  This
044     * is done via the <code>TemplateCompilerLoader</code>
045     * class.
046     * <p>
047     * The source data need not be in XHTML format however
048     * you must compile it into a XHTML DOM Element.  For 
049     * example you could right your own custom XML/XSLT 
050     * implementation that produced XHTML. 
051     * <p>
052     * The resultant XHTML DOM tree can have special marker Elements for 
053     * component and string replacement.
054     * <p>
055     * <code>&lt;component name="xxx" style="xxx" /&gt;</code> markers will be replaced
056     * with the named component and a CSS style will be created for the style
057     * attribute and applied to the component.
058     * <p>
059     * <code>&lt;text name="xxx" /&gt;</code> markers will be replaced
060     * with the named string data.
061     * 
062     * @see echopoint.template.ui.TemplateCompilerLoader
063     */
064    public interface TemplateCompiler {
065    
066            /**
067             * This method is called to compile a template data source
068             * of template data into a DOM XHTML Element.
069             * 
070             * @param c - the connection
071             * @param tds - the template data source
072             * 
073             * @return a DOM Element in XHTML or null if it cant be compiled
074             * 
075             * @throws Exception - can Throw exceptions such as parse exceptions etc..
076             */
077            public Element compileTemplateDataIntoXHTML(Connection c, TemplateDataSource tds) throws Exception;
078    
079        public String templateDataAsString(Connection c, TemplateDataSource tds) throws Exception;
080    }