001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the  "License");
007     * you may not use this file except in compliance with the License.
008     * You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    /*
019     * $Id: AVTPart.java 468643 2006-10-28 06:56:03Z minchau $
020     */
021    package org.apache.xalan.templates;
022    
023    import org.apache.xml.utils.FastStringBuffer;
024    import org.apache.xpath.XPathContext;
025    
026    /**
027     * Class to hold a part, either a string or XPath,
028     * of an Attribute Value Template.
029     * @xsl.usage internal
030     */
031    public abstract class AVTPart implements java.io.Serializable, XSLTVisitable
032    {
033        static final long serialVersionUID = -1747749903613916025L;
034    
035      /**
036       * Construct a part.
037       */
038      public AVTPart(){}
039    
040      /**
041       * Get the AVT part as the original string.
042       *
043       * @return the AVT part as the original string.
044       */
045      public abstract String getSimpleString();
046    
047      /**
048       * Write the evaluated value into the given
049       * string buffer.
050       *
051       * @param xctxt The XPath context to use to evaluate this AVT.
052       * @param buf Buffer to write into.
053       * @param context The current source tree context.
054       * @param nsNode The current namespace context (stylesheet tree context).
055       *
056       * @throws javax.xml.transform.TransformerException
057       */
058      public abstract void evaluate(
059        XPathContext xctxt, FastStringBuffer buf, int context,
060          org.apache.xml.utils.PrefixResolver nsNode)
061            throws javax.xml.transform.TransformerException;
062    
063      /**
064       * Set the XPath support.
065       *
066       * @param support XPathContext to set. 
067       */
068      public void setXPathSupport(XPathContext support){}
069      
070      /**
071       * Tell if this expression or it's subexpressions can traverse outside 
072       * the current subtree.
073       * 
074       * @return true if traversal outside the context node's subtree can occur.
075       */
076       public boolean canTraverseOutsideSubtree()
077       {
078        return false;
079       }
080       
081      /**
082       * This function is used to fixup variables from QNames to stack frame 
083       * indexes at stylesheet build time.
084       * @param vars List of QNames that correspond to variables.  This list 
085       * should be searched backwards for the first qualified name that 
086       * corresponds to the variable reference qname.  The position of the 
087       * QName in the vector from the start of the vector will be its position 
088       * in the stack frame (but variables above the globalsTop value will need 
089       * to be offset to the current stack frame).
090       */
091      public abstract void fixupVariables(java.util.Vector vars, int globalsSize);
092    
093    
094    }