286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 2001-2004 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * This class converts SAX or SAX-like calls to a 286N/A * serialized xml document. The xsl:output method is "xml". 286N/A * This class is used explicitly in code generated by XSLTC, 286N/A * so it is "public", but it should 286N/A * be viewed as internal or package private, this is not an API. 286N/A * remembers if we need to write out "]]>" to close the CDATA 286N/A * Map that tells which XML characters should have special treatment, and it 286N/A * provides character to entity name lookup. 286N/A // initialize namespaces 286N/A * Copy properties from another SerializerToXML. 286N/A * @param xmlListener non-null reference to a SerializerToXML object. 286N/A // m_outputStream = xmlListener.m_outputStream; 286N/A * Receive notification of the beginning of a document. 286N/A * @throws org.xml.sax.SAXException Any SAX exception, possibly 286N/A * wrapping another exception. 286N/A * @throws org.xml.sax.SAXException 286N/A /* The call to getXMLVersion() might emit an error message 286N/A * and we should emit this message regardless of if we are 286N/A * writing out an XML header or not. 293N/A // We almost never put a newline after the XML 293N/A // header because this XML could be used as 293N/A // an extenal general parsed entity 293N/A // and we don't know the context into which it 293N/A // will be used in the future. Only when 293N/A // standalone, or a doctype system or public is 293N/A // specified are we free to insert a new line 293N/A // after the header. Is it even worth bothering 293N/A // in these rare cases? 286N/A * Receive notification of the end of a document. 286N/A * @throws org.xml.sax.SAXException Any SAX exception, possibly 286N/A * wrapping another exception. 286N/A * @throws org.xml.sax.SAXException 286N/A * Starts a whitespace preserving section. All characters printed 286N/A * within a preserving section are printed without indentation and 286N/A * without consolidating multiple spaces. This is equivalent to 286N/A * the <tt>xml:space="preserve"</tt> attribute. Only XML 286N/A * and HTML serializers need to support this method. 286N/A * The contents of the whitespace preserving section will be delivered 286N/A * through the regular <tt>characters</tt> event. 286N/A * @throws org.xml.sax.SAXException 286N/A // Not sure this is really what we want. -sb 286N/A * Ends a whitespace preserving section. 286N/A * @see #startPreserving 286N/A * @throws org.xml.sax.SAXException 286N/A // Not sure this is really what we want. -sb 286N/A * Receive notification of a processing instruction. 286N/A * @param target The processing instruction target. 286N/A * @param data The processing instruction data, or null if 286N/A * @throws org.xml.sax.SAXException Any SAX exception, possibly 286N/A * wrapping another exception. 286N/A * @throws org.xml.sax.SAXException 286N/A // See XSLT spec on error recovery of "?>" in PIs. 331N/A * Before Xalan 1497, a newline char was printed out if not inside of an 358N/A * element. The whitespace is not significant is the output is standalone 293N/A * Don't write out any indentation whitespace now, 293N/A * because there may be non-whitespace text after this. 293N/A * Simply mark that at this point if we do decide 293N/A * to indent that we should 293N/A * add a newline on the end of the current line before 293N/A * the indentation at the start of the next line. 286N/A * Receive notivication of a entityReference. 286N/A * @param name The name of the entity. 286N/A * @throws org.xml.sax.SAXException 286N/A * This method is used to add an attribute to the currently open element. 286N/A * The caller has guaranted that this attribute is unique, which means that it 286N/A * not been seen before and will not be seen again. 286N/A * @param name the qualified name of the attribute 286N/A * @param value the value of the attribute which can contain only 286N/A * ASCII printable characters characters in the range 32 to 127 inclusive. 286N/A * @param flags the bit values of this integer give optimization information. 286N/A // "flags" has indicated that the characters 286N/A // '>' '<' '&' and '"' are not in the value and 286N/A // m_htmlcharInfo has recorded that there are no other 286N/A // entities in the range 32 to 127 so we write out the 286N/A * Add an attribute to the current element. 286N/A * @param uri the URI associated with the element name 286N/A * @param localName local part of the attribute name 286N/A * @param rawName prefix:localName 286N/A * @param value the value of the attribute 286N/A * @param xslAttribute true if this attribute is from an xsl:attribute, 286N/A * false if declared within the elements opening tag. 286N/A * We don't run this block of code if: 286N/A * 1. The attribute value was only replaced (was_added is false). 286N/A * 2. The attribute is from an xsl:attribute element (that is handled 286N/A * in the addAttributeAlways() call just above. 286N/A * 3. The name starts with "xmlns", i.e. it is a namespace declaration. 286N/A // use a different raw name, with the prefix used in the 286N/A // generated namespace declaration 286N/A * The startTag is closed, yet we are adding an attribute? 286N/A * Section: 7.1.3 Creating Attributes Adding an attribute to an 286N/A * element after a PI (for example) has been added to it is an 286N/A * error. The attributes can be ignored. The spec doesn't explicitly 286N/A * say this is disallowed, as it does for child elements, but it 286N/A * makes sense to have the same treatment. 286N/A * We choose to ignore the attribute which is added too late. 286N/A // Generate a warning of the ignored attributes 286N/A // Create the warning message 286N/A // Prepare to issue the warning message 286N/A // Issue the warning message 286N/A * @see ExtendedContentHandler#endElement(String) 286N/A * This method is used to notify the serializer of a namespace mapping (or node) 286N/A * that applies to the current element whose startElement() call has already been seen. 286N/A * The official SAX startPrefixMapping(prefix,uri) is to define a mapping for a child 286N/A * element that is soon to be seen with a startElement() call. The official SAX call 286N/A * does not apply to the current element, hence the reason for this method. 286N/A // hack for XSLTC with finding URI for default namespace 286N/A // the elements URI is not known yet, and it 286N/A // doesn't have a prefix, and we are currently 286N/A // setting the uri for prefix "", so we have 286N/A // the uri for the element... lets remember it 286N/A * Declare a prefix to point to a namespace URI. Inform SAX handler 286N/A * if this is a new prefix mapping. 286N/A * Try's to reset the super class and reset this class for 286N/A * re-use, so that you don't need to create a new serializer 286N/A * (mostly for performance reasons). 286N/A * @return true if the class was successfuly reset. 286N/A * Reset all of the fields owned by ToStream class 286N/A * This method checks for the XML version of output document. 286N/A * If XML version of output document is not specified, then output 286N/A * document is of version XML 1.0. 286N/A * If XML version of output doucment is specified, but it is not either 286N/A * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of 286N/A * output document is set to XML 1.0 and processing continues. 286N/A * @return string (XML version) 286N/A // Prepare to issue the warning message 286N/A // Issue the warning message