KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > templates > ElemExsltFuncResult


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: ElemExsltFuncResult.java,v 1.9 2004/02/16 20:32:32 minchau Exp $
18  */

19 package org.apache.xalan.templates;
20
21 import javax.xml.transform.TransformerException JavaDoc;
22
23 import org.apache.xalan.transformer.TransformerImpl;
24 import org.apache.xpath.XPathContext;
25 import org.apache.xpath.objects.XObject;
26
27 /**
28  * Handles the EXSLT result element within an EXSLT function element.
29  */

30 public class ElemExsltFuncResult extends ElemVariable
31 {
32  
33   /**
34    * Generate the EXSLT function return value, and assign it to the variable
35    * index slot assigned for it in ElemExsltFunction compose().
36    *
37    */

38   public void execute(TransformerImpl transformer) throws TransformerException JavaDoc
39   {
40     XPathContext context = transformer.getXPathContext();
41
42     if (TransformerImpl.S_DEBUG)
43       transformer.getTraceManager().fireTraceEvent(this);
44     
45     // Verify that result has not already been set by another result
46
// element. Recursion is allowed: intermediate results are cleared
47
// in the owner ElemExsltFunction execute().
48
if (transformer.currentFuncResultSeen()) {
49         throw new TransformerException JavaDoc("An EXSLT function cannot set more than one result!");
50     }
51
52     int sourceNode = context.getCurrentNode();
53
54     // Set the return value;
55
XObject var = getValue(transformer, sourceNode);
56     transformer.popCurrentFuncResult();
57     transformer.pushCurrentFuncResult(var);
58
59     if (TransformerImpl.S_DEBUG)
60       transformer.getTraceManager().fireTraceEndEvent(this);
61   }
62
63   /**
64    * Get an integer representation of the element type.
65    *
66    * @return An integer representation of the element, defined in the
67    * Constants class.
68    * @see org.apache.xalan.templates.Constants
69    */

70   public int getXSLToken()
71   {
72     return Constants.EXSLT_ELEMNAME_FUNCRESULT;
73   }
74   
75   /**
76    * Return the node name, defined in the
77    * Constants class.
78    * @see org.apache.xalan.templates.Constants
79    * @return The node name
80    *
81    */

82    public String JavaDoc getNodeName()
83   {
84     return Constants.EXSLT_ELEMNAME_FUNCRESULT_STRING;
85   }
86 }
87
Popular Tags