1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 1999 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xalan" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, Lotus
  53. * Development Corporation., http://www.lotus.com. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package org.apache.xalan.transformer;
  58. import java.util.Stack;
  59. import java.util.Vector;
  60. import org.apache.xml.utils.ObjectPool;
  61. import org.xml.sax.Attributes;
  62. import org.apache.xml.dtm.DTMIterator;
  63. import org.apache.xml.utils.MutableAttrListImpl;
  64. import org.apache.xalan.templates.ElemTemplateElement;
  65. import org.apache.xalan.templates.ElemTemplate;
  66. /**
  67. * This class acts as a base for ResultTreeHandler, and keeps
  68. * queud stack events. In truth, we don't need a stack,
  69. * so I may change this down the line a bit.
  70. */
  71. public abstract class QueuedEvents
  72. {
  73. /** The number of events queued */
  74. protected int m_eventCount = 0;
  75. /** Queued start document */
  76. // QueuedStartDocument m_startDoc = new QueuedStartDocument();
  77. /** Queued start element */
  78. // QueuedStartElement m_startElement = new QueuedStartElement();
  79. public boolean m_docPending = false;
  80. protected boolean m_docEnded = false;
  81. /** Flag indicating that an event is pending. Public for
  82. * fast access by ElemForEach. */
  83. public boolean m_elemIsPending = false;
  84. /** Flag indicating that an event is ended */
  85. public boolean m_elemIsEnded = false;
  86. /**
  87. * The pending attributes. We have to delay the call to
  88. * m_flistener.startElement(name, atts) because of the
  89. * xsl:attribute and xsl:copy calls. In other words,
  90. * the attributes have to be fully collected before you
  91. * can call startElement.
  92. */
  93. protected MutableAttrListImpl m_attributes = new MutableAttrListImpl();
  94. /**
  95. * Flag to try and get the xmlns decls to the attribute list
  96. * before other attributes are added.
  97. */
  98. protected boolean m_nsDeclsHaveBeenAdded = false;
  99. /**
  100. * The pending element, namespace, and local name.
  101. */
  102. protected String m_name;
  103. /** Namespace URL of the element */
  104. protected String m_url;
  105. /** Local part of qualified name of the element */
  106. protected String m_localName;
  107. /** Vector of namespaces for this element */
  108. protected Vector m_namespaces = null;
  109. // /**
  110. // * Get the queued element.
  111. // *
  112. // * @return the queued element.
  113. // */
  114. // QueuedStartElement getQueuedElem()
  115. // {
  116. // return (m_eventCount > 1) ? m_startElement : null;
  117. // }
  118. /**
  119. * To re-initialize the document and element events
  120. *
  121. */
  122. protected void reInitEvents()
  123. {
  124. }
  125. /**
  126. * Push document event and re-initialize events
  127. *
  128. */
  129. public void reset()
  130. {
  131. pushDocumentEvent();
  132. reInitEvents();
  133. }
  134. /**
  135. * Push the document event. This never gets popped.
  136. */
  137. void pushDocumentEvent()
  138. {
  139. // m_startDoc.setPending(true);
  140. // initQSE(m_startDoc);
  141. m_docPending = true;
  142. m_eventCount++;
  143. }
  144. /**
  145. * Pop element event
  146. *
  147. */
  148. void popEvent()
  149. {
  150. m_elemIsPending = false;
  151. m_attributes.clear();
  152. m_nsDeclsHaveBeenAdded = false;
  153. m_name = null;
  154. m_url = null;
  155. m_localName = null;
  156. m_namespaces = null;
  157. m_eventCount--;
  158. }
  159. /** Instance of a serializer */
  160. private org.apache.xalan.serialize.Serializer m_serializer;
  161. /**
  162. * This is only for use of object pooling, so that
  163. * it can be reset.
  164. *
  165. * @param s non-null instance of a serializer
  166. */
  167. void setSerializer(org.apache.xalan.serialize.Serializer s)
  168. {
  169. m_serializer = s;
  170. }
  171. /**
  172. * This is only for use of object pooling, so the that
  173. * it can be reset.
  174. *
  175. * @return The serializer
  176. */
  177. org.apache.xalan.serialize.Serializer getSerializer()
  178. {
  179. return m_serializer;
  180. }
  181. }