KickJava   Java API By Example, From Geeks To Geeks.

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


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

19 package org.apache.xalan.templates;
20
21 import org.apache.xpath.XPath;
22
23 /**
24  * Implement xsl:when.
25  * <pre>
26  * <!ELEMENT xsl:when %template;>
27  * <!ATTLIST xsl:when
28  * test %expr; #REQUIRED
29  * %space-att;
30  * >
31  * </pre>
32  * @see <a HREF="http://www.w3.org/TR/xslt#section-Conditional-Processing-with-xsl:choose">XXX in XSLT Specification</a>
33  * @xsl.usage advanced
34  */

35 public class ElemWhen extends ElemTemplateElement
36 {
37
38   /**
39    * Each xsl:when element has a single attribute, test,
40    * which specifies an expression.
41    * @serial
42    */

43   private XPath m_test;
44
45   /**
46    * Set the "test" attribute.
47    * Each xsl:when element has a single attribute, test,
48    * which specifies an expression.
49    *
50    * @param v Value to set for the "test" attribute.
51    */

52   public void setTest(XPath v)
53   {
54     m_test = v;
55   }
56
57   /**
58    * Get the "test" attribute.
59    * Each xsl:when element has a single attribute, test,
60    * which specifies an expression.
61    *
62    * @return Value of the "test" attribute.
63    */

64   public XPath getTest()
65   {
66     return m_test;
67   }
68
69   /**
70    * Get an integer representation of the element type.
71    *
72    * @return An integer representation of the element, defined in the
73    * Constants class.
74    * @see org.apache.xalan.templates.Constants
75    */

76   public int getXSLToken()
77   {
78     return Constants.ELEMNAME_WHEN;
79   }
80   
81   /**
82    * This function is called after everything else has been
83    * recomposed, and allows the template to set remaining
84    * values that may be based on some other property that
85    * depends on recomposition.
86    */

87   public void compose(StylesheetRoot sroot)
88     throws javax.xml.transform.TransformerException JavaDoc
89   {
90     super.compose(sroot);
91     java.util.Vector JavaDoc vnames = sroot.getComposeState().getVariableNames();
92     if(null != m_test)
93       m_test.fixupVariables(vnames, sroot.getComposeState().getGlobalsSize());
94   }
95
96   /**
97    * Return the node name.
98    *
99    * @return The node name
100    */

101   public String JavaDoc getNodeName()
102   {
103     return Constants.ELEMNAME_WHEN_STRING;
104   }
105
106   /**
107    * Constructor ElemWhen
108    *
109    */

110   public ElemWhen(){}
111   
112   /**
113    * Call the children visitors.
114    * @param visitor The visitor whose appropriate method will be called.
115    */

116   protected void callChildVisitors(XSLTVisitor visitor, boolean callAttrs)
117   {
118     if(callAttrs)
119         m_test.getExpression().callVisitors(m_test, visitor);
120     super.callChildVisitors(visitor, callAttrs);
121   }
122
123 }
124
Popular Tags