KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > language > markup > xsp > XSPMarkupLanguage


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.language.markup.xsp;
17
18 import org.apache.cocoon.components.language.markup.CocoonMarkupLanguage;
19 import org.apache.cocoon.components.language.markup.LogicsheetFilter;
20 import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
21 import org.apache.cocoon.xml.AbstractXMLPipe;
22
23 /**
24  * This class implements <code>MarkupLanguage</code> for Cocoon's
25  * <a HREF="http://cocoon.apache.org/userdocs/xsp/">XSP</a>.
26  *
27  * @author <a HREF="mailto:ricardo@apache.org">Ricardo Rocha</a>
28  * @author <a HREF="mailto:ssahuc@apache.org">Sebastien Sahuc</a>
29  * @author <a HREF="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
30  * @version $Id: XSPMarkupLanguage.java 306625 2005-10-06 13:07:58Z vgritsenko $
31  */

32 public class XSPMarkupLanguage extends CocoonMarkupLanguage {
33
34     /**
35      * Returns the root element for a valid XSP page: page element!
36      */

37     public String JavaDoc getRootElement() {
38         return "page";
39     }
40
41     /**
42      * Return the filter to preprocess logicsheets expanding {#expr} to
43      * xsp:attribute and xsp:expr elements.
44      */

45     protected LogicsheetFilter getLogicsheetFilter() {
46         return new XSPExpressionFilter(this);
47     }
48
49     /**
50      * Prepare the input source for logicsheet processing and code generation
51      * with a preprocess filter.
52      * The return <code>XMLFilter</code> object is the first filter on the
53      * transformer chain.
54      *
55      * @param filename The source filename
56      * @param language The target programming language
57      * @return The preprocess filter
58      *
59      * @see XSPMarkupLanguage.PreProcessFilter
60      */

61     protected AbstractXMLPipe getPreprocessFilter(String JavaDoc filename,
62                                                   AbstractXMLPipe filter,
63                                                   ProgrammingLanguage language) {
64         PreProcessFilter prefilter = new PreProcessFilter(filter, filename, language, this);
65         prefilter.enableLogging(getLogger());
66         return prefilter;
67     }
68
69 //
70
// Inner classes
71
//
72

73     /**
74      * <code>{@link CocoonMarkupLanguage.PreProcessFilter PreProcessFilter}</code> that replaces
75      * XSP expressions.
76      *
77      * @see org.xml.sax.ContentHandler
78      */

79     protected class PreProcessFilter extends CocoonMarkupLanguage.PreProcessFilter {
80         public PreProcessFilter(AbstractXMLPipe filter, String JavaDoc filename, ProgrammingLanguage language, XSPMarkupLanguage markup) {
81             super(new XSPExpressionFilter.XMLPipeAdapter(new XSPExpressionFilter(markup), filter), filename, language);
82         }
83     }
84 }
85
Popular Tags