KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > processor > ProcessorExsltFuncResult


1 /*
2  * Copyright 1999-2004 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 /*
17  * $Id: ProcessorExsltFuncResult.java,v 1.6 2004/02/11 18:15:51 minchau Exp $
18  */

19 package org.apache.xalan.processor;
20
21 import org.apache.xalan.templates.ElemExsltFuncResult;
22 import org.apache.xalan.templates.ElemExsltFunction;
23 import org.apache.xalan.templates.ElemParam;
24 import org.apache.xalan.templates.ElemTemplateElement;
25 import org.apache.xalan.templates.ElemVariable;
26
27 import org.xml.sax.Attributes JavaDoc;
28 import org.xml.sax.SAXException JavaDoc;
29
30 /**
31  * This class processes parse events for an exslt func:result element.
32  * @xsl.usage internal
33  */

34 public class ProcessorExsltFuncResult extends ProcessorTemplateElem
35 {
36   
37   /**
38    * Verify that the func:result element does not appear within a variable,
39    * parameter, or another func:result, and that it belongs to a func:function
40    * element.
41    */

42   public void startElement(
43           StylesheetHandler handler, String JavaDoc uri, String JavaDoc localName, String JavaDoc rawName, Attributes JavaDoc attributes)
44             throws SAXException JavaDoc
45   {
46     String JavaDoc msg = "";
47
48     super.startElement(handler, uri, localName, rawName, attributes);
49     ElemTemplateElement ancestor = handler.getElemTemplateElement().getParentElem();
50     while (ancestor != null && !(ancestor instanceof ElemExsltFunction))
51     {
52       if (ancestor instanceof ElemVariable
53           || ancestor instanceof ElemParam
54           || ancestor instanceof ElemExsltFuncResult)
55       {
56         msg = "func:result cannot appear within a variable, parameter, or another func:result.";
57         handler.error(msg, new SAXException JavaDoc(msg));
58       }
59       ancestor = ancestor.getParentElem();
60     }
61     if (ancestor == null)
62     {
63       msg = "func:result must appear in a func:function element";
64       handler.error(msg, new SAXException JavaDoc(msg));
65     }
66   }
67 }
68
Popular Tags