19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one
39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file
49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information
59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file
69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the  "License");
79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License.
89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at
99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software
139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and
169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License.
179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: ElemContext.java 468654 2006-10-28 07:09:23Z minchau $
209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xml.serializer;
229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/**
249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This class is a stack frame that consists of
259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * information about the element currently being processed
269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * by a serializer. Consider this example:
279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <pre>
289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *   <A>
299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     <B1>
309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     </B1>
319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     <B2>
329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     </B2>
339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *   <A>
349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * </pre>
359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * A stack frame will be pushed for "A" at depth 1,
379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * then another one for "B1" at depth 2.
389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Then "B1" stackframe is popped.  When the stack frame for "B2" is
399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * pushed, this implementation re-uses the old stack fram object used
409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * by "B1" to be efficient at not creating too many of these object.
419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This is by no means a public class, and neither are its fields or methods,
439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * they are all helper fields for a serializer.
449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The purpose of this class is to be more consistent with pushing information
469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * when a new element is being serialized and more quickly restoring the old
479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * information about the parent element with a simple pop() when the
489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * child element is done.  Previously there was some redundant and error-prone
499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * calculations going on to retore information.
509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @xsl.usage internal
529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonfinal class ElemContext
549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{
559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Fields that form the context of the element
569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * The nesting depth of the element inside other elements.
599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    final int m_currentElemDepth;
619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /** HTML field, the element description of the HTML element */
639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    ElemDesc m_elementDesc = null;
649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * The local name of the element.
679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    String m_elementLocalName = null;
699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * The fully qualified name of the element (with prefix, if any).
729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    String m_elementName = null;
749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * The URI of the element.
779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * If this value is null it means that the URI is not yet determined
789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * for the element. Valid values are the empty string "", meaning
799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * that it is in no namespace, or a string of non-zero length.
809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    String m_elementURI = null;
829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /** If the element is in the cdata-section-names list
849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * then the value is true. If it is true the text children of the element
859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * should be output in CDATA section blocks.
869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    boolean m_isCdataSection;
889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /** True if the current element has output escaping disabled.
909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * This is true for SCRIPT and STYLE elements.
919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    boolean m_isRaw = false;
939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /** The next element "stack frame". This value will only be
959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * set once as deeper stack frames are not deleted when popped off,
969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * but are rather re-used when a push is required.
979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     *
989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * This makes for very fast pushing and popping of stack frames
999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * because very few stack frame objects are ever created, they are
1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * mostly re-used.  This re-use saves object creation but it also means
1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * that connections between the frames via m_next and m_prev
1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * never changes either. Just the contents of the frames change
1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * as they are re-used. Only the reference to the current stack frame, which
1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * is held by the serializer is changed via a quick pop() or push().
1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    private ElemContext m_next;
1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /** The previous element "stack frame". */
1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    final ElemContext m_prev;
1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * Set to true when a start tag is started, or open, but not all the
1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * attributes or namespace information is yet collected.
1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    boolean m_startTagOpen = false;
1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * Constructor to create the root of the element contexts.
1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     *
1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    ElemContext()
1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // this assignment means can never pop this context off
1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        m_prev = this;
1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // depth 0 because it doesn't correspond to any element
1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        m_currentElemDepth = 0;
1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * Constructor to create the "stack frame" for a given element depth.
1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     *
1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * This implementation will re-use the context at each depth. If
1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * a documents deepest element depth is N then there will be (N+1)
1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * such objects created, no more than that.
1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     *
1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * @param previous The "stack frame" corresponding to the new
1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * elements parent element.
1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    private ElemContext(final ElemContext previous)
1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        m_prev = previous;
1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        m_currentElemDepth = previous.m_currentElemDepth + 1;
1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * Pop the current "stack frame".
1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * @return Returns the parent "stack frame" of the one popped.
1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    final ElemContext pop()
1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /* a very simple pop.  No clean up is done of the deeper
1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * stack frame.  All deeper stack frames are still attached
1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * but dormant, just waiting to be re-used.
1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        return this.m_prev;
1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * This method pushes an element "stack frame"
1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * but with no initialization of values in that frame.
1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * This method is used for optimization purposes, like when pushing
1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * a stack frame for an HTML "IMG" tag which has no children and
1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * the stack frame will almost immediately be popped.
1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    final ElemContext push()
1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        ElemContext frame = this.m_next;
1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        if (frame == null)
1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            /* We have never been at this depth yet, and there is no
1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson             * stack frame to re-use, so we now make a new one.
1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson             */
1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            frame = new ElemContext(this);
1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            this.m_next = frame;
1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /*
1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * We shouldn't need to set this true because we should just
1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * be pushing a dummy stack frame that will be instantly popped.
1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Yet we need to be ready in case this element does have
1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * unexpected children.
1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        frame.m_startTagOpen = true;
1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        return frame;
1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**
1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * Push an element context on the stack. This context keeps track of
1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * information gathered about the element.
1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * @param uri The URI for the namespace for the element name,
1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * can be null if it is not yet known.
1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * @param localName The local name of the element (no prefix),
1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * can be null.
1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * @param qName The qualified name (with prefix, if any)
1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     * of the element, this parameter is required.
1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson     */
1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    final ElemContext push(
1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        final String uri,
1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        final String localName,
1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        final String qName)
2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        ElemContext frame = this.m_next;
2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        if (frame == null)
2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            /* We have never been at this depth yet, and there is no
2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson             * stack frame to re-use, so we now make a new one.
2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson             */
2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            frame = new ElemContext(this);
2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            this.m_next = frame;
2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Initialize, or reset values in the new or re-used stack frame.
2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        frame.m_elementName = qName;
2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        frame.m_elementLocalName = localName;
2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        frame.m_elementURI = uri;
2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        frame.m_isCdataSection = false;
2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        frame.m_startTagOpen = true;
2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // is_Raw is already set in the HTML startElement() method
2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // frame.m_isRaw = false;
2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        return frame;
2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson}
223