Home | History | Annotate | Download | only in templates
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one
      3  * or more contributor license agreements. See the NOTICE file
      4  * distributed with this work for additional information
      5  * regarding copyright ownership. The ASF licenses this file
      6  * to you under the Apache License, Version 2.0 (the  "License");
      7  * you may not use this file except in compliance with the License.
      8  * You may obtain a copy of the License at
      9  *
     10  *     http://www.apache.org/licenses/LICENSE-2.0
     11  *
     12  * Unless required by applicable law or agreed to in writing, software
     13  * distributed under the License is distributed on an "AS IS" BASIS,
     14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15  * See the License for the specific language governing permissions and
     16  * limitations under the License.
     17  */
     18 /*
     19  * $Id: AVTPart.java 468643 2006-10-28 06:56:03Z minchau $
     20  */
     21 package org.apache.xalan.templates;
     22 
     23 import org.apache.xml.utils.FastStringBuffer;
     24 import org.apache.xpath.XPathContext;
     25 
     26 /**
     27  * Class to hold a part, either a string or XPath,
     28  * of an Attribute Value Template.
     29  * @xsl.usage internal
     30  */
     31 public abstract class AVTPart implements java.io.Serializable, XSLTVisitable
     32 {
     33     static final long serialVersionUID = -1747749903613916025L;
     34 
     35   /**
     36    * Construct a part.
     37    */
     38   public AVTPart(){}
     39 
     40   /**
     41    * Get the AVT part as the original string.
     42    *
     43    * @return the AVT part as the original string.
     44    */
     45   public abstract String getSimpleString();
     46 
     47   /**
     48    * Write the evaluated value into the given
     49    * string buffer.
     50    *
     51    * @param xctxt The XPath context to use to evaluate this AVT.
     52    * @param buf Buffer to write into.
     53    * @param context The current source tree context.
     54    * @param nsNode The current namespace context (stylesheet tree context).
     55    *
     56    * @throws javax.xml.transform.TransformerException
     57    */
     58   public abstract void evaluate(
     59     XPathContext xctxt, FastStringBuffer buf, int context,
     60       org.apache.xml.utils.PrefixResolver nsNode)
     61         throws javax.xml.transform.TransformerException;
     62 
     63   /**
     64    * Set the XPath support.
     65    *
     66    * @param support XPathContext to set.
     67    */
     68   public void setXPathSupport(XPathContext support){}
     69 
     70   /**
     71    * Tell if this expression or it's subexpressions can traverse outside
     72    * the current subtree.
     73    *
     74    * @return true if traversal outside the context node's subtree can occur.
     75    */
     76    public boolean canTraverseOutsideSubtree()
     77    {
     78     return false;
     79    }
     80 
     81   /**
     82    * This function is used to fixup variables from QNames to stack frame
     83    * indexes at stylesheet build time.
     84    * @param vars List of QNames that correspond to variables.  This list
     85    * should be searched backwards for the first qualified name that
     86    * corresponds to the variable reference qname.  The position of the
     87    * QName in the vector from the start of the vector will be its position
     88    * in the stack frame (but variables above the globalsTop value will need
     89    * to be offset to the current stack frame).
     90    */
     91   public abstract void fixupVariables(java.util.Vector vars, int globalsSize);
     92 
     93 
     94 }
     95