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$ 20 */ 21 package org.apache.xalan.trace; 22 23 import org.apache.xalan.transformer.TransformerImpl; 24 import org.xml.sax.Attributes; 25 26 /** 27 * Event generated by the XSL processor after it generates a new node in the result tree. 28 * This event responds to and is modeled on the SAX events that are sent to the 29 * formatter listener FormatterToXXX)classes. 30 * 31 * @see org.apache.xml.utils.DOMBuilder 32 * @see org.apache.xml.serializer.ToHTMLStream 33 * @see org.apache.xml.serializer.ToTextStream 34 * @see org.apache.xml.serializer.ToXMLStream 35 * 36 * @xsl.usage advanced 37 */ 38 public class GenerateEvent implements java.util.EventListener 39 { 40 41 /** 42 * The XSLT Transformer, which either directly or indirectly contains most needed information. 43 * 44 * @see org.apache.xalan.transformer.TransformerImpl 45 */ 46 public TransformerImpl m_processor; 47 48 /** 49 * The type of SAX event that was generated, as enumerated in the EVENTTYPE_XXX constants below. 50 */ 51 public int m_eventtype; 52 53 54 /** 55 * Character data from a character or cdata event. 56 */ 57 public char m_characters[]; 58 59 /** 60 * The start position of the current data in m_characters. 61 */ 62 public int m_start; 63 64 /** 65 * The length of the current data in m_characters. 66 */ 67 public int m_length; 68 69 /** 70 * The name of the element or PI. 71 */ 72 public String m_name; 73 74 /** 75 * The string data in the element (comments and PIs). 76 */ 77 public String m_data; 78 79 /** 80 * The current attribute list. 81 */ 82 public Attributes m_atts; 83 84 /** 85 * Constructor for startDocument, endDocument events. 86 * 87 * @param processor The XSLT TransformerFactory instance. 88 * @param eventType One of the EVENTTYPE_XXX constants. 89 */ GenerateEvent(TransformerImpl processor, int eventType)90 public GenerateEvent(TransformerImpl processor, int eventType) 91 { 92 m_processor = processor; 93 m_eventtype = eventType; 94 } 95 96 /** 97 * Constructor for startElement, endElement events. 98 * 99 * @param processor The XSLT TransformerFactory Instance. 100 * @param eventType One of the EVENTTYPE_XXX constants. 101 * @param name The name of the element. 102 * @param atts The SAX attribute list. 103 */ GenerateEvent(TransformerImpl processor, int eventType, String name, Attributes atts)104 public GenerateEvent(TransformerImpl processor, int eventType, String name, 105 Attributes atts) 106 { 107 108 m_name = name; 109 m_atts = atts; 110 m_processor = processor; 111 m_eventtype = eventType; 112 } 113 114 /** 115 * Constructor for characters, cdate events. 116 * 117 * @param processor The XSLT TransformerFactory instance. 118 * @param eventType One of the EVENTTYPE_XXX constants. 119 * @param ch The char array from the SAX event. 120 * @param start The start offset to be used in the char array. 121 * @param length The end offset to be used in the chara array. 122 */ GenerateEvent(TransformerImpl processor, int eventType, char ch[], int start, int length)123 public GenerateEvent(TransformerImpl processor, int eventType, char ch[], 124 int start, int length) 125 { 126 127 m_characters = ch; 128 m_start = start; 129 m_length = length; 130 m_processor = processor; 131 m_eventtype = eventType; 132 } 133 134 /** 135 * Constructor for processingInstruction events. 136 * 137 * @param processor The instance of the XSLT processor. 138 * @param eventType One of the EVENTTYPE_XXX constants. 139 * @param name The name of the processing instruction. 140 * @param data The processing instruction data. 141 */ GenerateEvent(TransformerImpl processor, int eventType, String name, String data)142 public GenerateEvent(TransformerImpl processor, int eventType, String name, 143 String data) 144 { 145 146 m_name = name; 147 m_data = data; 148 m_processor = processor; 149 m_eventtype = eventType; 150 } 151 152 /** 153 * Constructor for comment and entity ref events. 154 * 155 * @param processor The XSLT processor instance. 156 * @param eventType One of the EVENTTYPE_XXX constants. 157 * @param data The comment or entity ref data. 158 */ GenerateEvent(TransformerImpl processor, int eventType, String data)159 public GenerateEvent(TransformerImpl processor, int eventType, String data) 160 { 161 162 m_data = data; 163 m_processor = processor; 164 m_eventtype = eventType; 165 } 166 } 167