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: ProcessorText.java 468640 2006-10-28 06:53:53Z minchau $
020     */
021    package org.apache.xalan.processor;
022    
023    import org.apache.xalan.templates.ElemTemplateElement;
024    import org.apache.xalan.templates.ElemText;
025    
026    /**
027     * Process xsl:text.
028     * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
029     * @see <a href="http://www.w3.org/TR/xslt#element-text">element-text in XSLT Specification</a>
030     */
031    public class ProcessorText extends ProcessorTemplateElem
032    {
033        static final long serialVersionUID = 5170229307201307523L;
034    
035      /**
036       * Append the current template element to the current
037       * template element, and then push it onto the current template
038       * element stack.
039       *
040       * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
041       * @param elem non-null reference to a {@link org.apache.xalan.templates.ElemText}.
042       *
043       * @throws org.xml.sax.SAXException Any SAX exception, possibly
044       *            wrapping another exception.
045       */
046      protected void appendAndPush(
047              StylesheetHandler handler, ElemTemplateElement elem)
048                throws org.xml.sax.SAXException
049      {
050    
051        // Don't push this element onto the element stack.
052        ProcessorCharacters charProcessor =
053          (ProcessorCharacters) handler.getProcessorFor(null, "text()", "text");
054    
055        charProcessor.setXslTextElement((ElemText) elem);
056    
057        ElemTemplateElement parent = handler.getElemTemplateElement();
058    
059        parent.appendChild(elem);
060        elem.setDOMBackPointer(handler.getOriginatingNode());
061      }
062    
063      /**
064       * Receive notification of the end of an element.
065       *
066       * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
067       * @param uri The Namespace URI, or an empty string.
068       * @param localName The local name (without prefix), or empty string if not namespace processing.
069       * @param rawName The qualified name (with prefix).
070       */
071      public void endElement(
072              StylesheetHandler handler, String uri, String localName, String rawName)
073                throws org.xml.sax.SAXException
074      {
075    
076        ProcessorCharacters charProcessor 
077          = (ProcessorCharacters) handler.getProcessorFor(null, "text()", "text");
078    
079        charProcessor.setXslTextElement(null);
080    
081      }
082    }