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 receives notification of SAX-like events, and with gathered 286N/A * information over these calls it will invoke the equivalent SAX methods 286N/A * on a handler, the ultimate xsl:output method is known to be "xml". 286N/A * This class is not a public API, it is only public because it is used by Xalan. 286N/A * Keeps track of whether output escaping is currently enabled 286N/A // default constructor (need to set content handler ASAP !) 286N/A * @see Serializer#getOutputFormat() 286N/A * @see Serializer#getOutputStream() 286N/A * @see Serializer#getWriter() 286N/A * @see DOMSerializer#serialize(Node) 286N/A * @see SerializationHandler#setEscaping(boolean) 286N/A * @see Serializer#setOutputFormat(Properties) 286N/A * @see Serializer#setOutputStream(OutputStream) 286N/A * @see Serializer#setWriter(Writer) 286N/A * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String) 286N/A * @see org.xml.sax.ext.DeclHandler#elementDecl(String, String) 286N/A * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String) 286N/A * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String) 286N/A * Receives notification of the end of the document. 286N/A // Close output document 286N/A * This method is called when all the data needed for a call to the 286N/A * SAX handler's startElement() method has been gathered. 286N/A // Now is time to send the startElement event 286N/A // we've sent the official SAX attributes on their way, 286N/A // now we don't need them anymore. 286N/A * Closes ane open cdata tag, and 286N/A * unlike the this.endCDATA() method (from the LexicalHandler) interface, 286N/A * this "internal" method will send the endCDATA() call to the wrapped 286N/A // Output closing bracket - "]]>" 286N/A // There are no longer any calls made to 286N/A // m_lexHandler.startCDATA() without a balancing call to 286N/A // m_lexHandler.endCDATA() 286N/A // so we set m_cdataTagOpen to false to remember this. 286N/A * @see org.xml.sax.ContentHandler#endElement(String, String, String) 286N/A // Close any open elements etc. 286N/A /* Pop all namespaces at the current element depth. 286N/A * We are not waiting for official endPrefixMapping() calls. 286N/A * @see org.xml.sax.ContentHandler#endPrefixMapping(String) 286N/A /* poping all prefix mappings should have been done 286N/A * in endElement() already 286N/A * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int) 286N/A * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator) 286N/A * @see org.xml.sax.ContentHandler#startPrefixMapping(String, String) 286N/A * @param prefix The prefix that maps to the URI 286N/A * @param uri The URI for the namespace 286N/A * Remember the prefix/uri mapping at the current nested element depth. 286N/A * @see org.xml.sax.ContentHandler#startPrefixMapping(String, String) 286N/A * @param prefix The prefix that maps to the URI 286N/A * @param uri The URI for the namespace 286N/A * @param shouldFlush a flag indicating if the mapping applies to the 286N/A * current element or an up coming child (not used). 286N/A /* Remember the mapping, and at what depth it was declared 286N/A * This is one greater than the current depth because these 286N/A * mappings will apply to the next depth. This is in 286N/A * consideration that startElement() will soon be called 286N/A // the prefix mapping applies to the child element (one deeper) 286N/A // the prefix mapping applies to the current element 286N/A /* Brian M.: don't know if we really needto do this. The 286N/A * callers of this object should have injected both 286N/A * startPrefixMapping and the attributes. We are 286N/A * just covering our butt here. 286N/A {
// that maps ns1 prefix to "" URI 286N/A /* for something like xmlns:abc="w3.pretend.org" 286N/A * the uri is the value, that is why we pass it in the 286N/A * value, or 5th slot of addAttributeAlways() 286N/A * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int) 286N/A /* Normally we would do somthing with this but we ignore it. 286N/A * The neccessary call to m_lexHandler.endCDATA() will be made 286N/A * This is so that if we get calls like these: 286N/A * this.characters(chars1, off1, len1); 286N/A * this.characters(chars2, off2, len2); 286N/A * that we will only make these calls to the wrapped handlers: 286N/A * m_lexHandler.startCDATA(); 286N/A * m_saxHandler.characters(chars1, off1, len1); 286N/A * m_saxHandler.characters(chars1, off2, len2); 286N/A * m_lexHandler.endCDATA(); 286N/A * We will merge adjacent CDATA blocks. 286N/A * @see ExtendedContentHandler#characters(String) 286N/A /////////////////// from XSLTC ////////////// 286N/A * Start an element in the output document. This might be an XML element 286N/A * (<elem>data</elem> type) or a CDATA section. 286N/A // We do the first two things in flushPending() but we don't 286N/A // close any open CDATA calls. 286N/A // We have made a call to m_lexHandler.startCDATA() with 286N/A // no balancing call to m_lexHandler.endCDATA() 286N/A // so we set m_cdataTagOpen true to remember this. 286N/A /* If there are any occurances of "]]>" in the character data 286N/A * let m_saxHandler worry about it, we've already warned them with 286N/A * the previous call of m_lexHandler.startCDATA(); 286N/A // time to generate characters event 286N/A * @see ExtendedContentHandler#endElement(String) 286N/A * Send a namespace declaration in the output document. The namespace 286N/A * declaration will not be include if the namespace is already in scope 286N/A * with the same prefix. 286N/A * @see org.xml.sax.ContentHandler#processingInstruction(String, String) 286N/A * Send a processing instruction to the output document 286N/A // Pass the processing instruction to the SAX handler 286N/A // we don't want to leave serializer to fire off this event, 286N/A * Undeclare the namespace that is currently pointed to by a given 286N/A * prefix. Inform SAX handler if prefix was previously mapped. 286N/A /* m_cdataTagOpen can only be true here if we have ignored the 286N/A * previous call to this.endCDATA() and the previous call 286N/A * this.startCDATA() before that is still "open". In this way 286N/A * we merge adjacent CDATA. If anything else happened after the 286N/A * ignored call to this.endCDATA() and this call then a call to 286N/A * flushPending() would have been made which would have 286N/A * closed the CDATA and set m_cdataTagOpen to false. 286N/A // We have made a call to m_lexHandler.startCDATA() with 286N/A // no balancing call to m_lexHandler.endCDATA() 286N/A // so we set m_cdataTagOpen true to remember this. 286N/A * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes) 286N/A // Handle document type declaration (for first element only) 286N/A // ensurePrefixIsDeclared depends on the current depth, so 286N/A // the previous increment is necessary where it is. 286N/A // add the attributes to the collected ones 286N/A // do we really need this CDATA section state? 286N/A // Bugzilla1133: Generate attribute as well as namespace event. 286N/A // SAX does expect both. 286N/A * Adds the given attribute to the set of attributes, and also makes sure 286N/A * that the needed prefix/uri mapping is declared, but only if there is a 286N/A * currently open element. 286N/A * @param uri the URI of the attribute 286N/A * @param localName the local name of the attribute 286N/A * @param rawName the qualified name of the attribute 286N/A * @param type the type of the attribute (probably CDATA) 286N/A * @param value the value of the attribute 286N/A * @param XSLAttribute true if this attribute is coming from an xsl:attribute element 286N/A * @see ExtendedContentHandler#addAttribute(String, String, String, String, String) 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 * @see Serializer#reset() 286N/A * Reset all of the fields owned by ToXMLSAXHandler class