286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2001-2004 The Apache Software Foundation.
286N/A *
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 *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
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 */
286N/A/*
286N/A * $Id: ToXMLSAXHandler.java,v 1.3 2005/09/28 13:49:08 pvedula Exp $
286N/A */
286N/A package com.sun.org.apache.xml.internal.serializer;
286N/A
286N/Aimport java.io.IOException;
286N/Aimport java.io.OutputStream;
286N/Aimport java.io.Writer;
286N/Aimport java.util.Properties;
286N/A
286N/Aimport javax.xml.transform.Result;
286N/A
286N/Aimport org.w3c.dom.Node;
286N/Aimport org.xml.sax.Attributes;
286N/Aimport org.xml.sax.ContentHandler;
286N/Aimport org.xml.sax.Locator;
286N/Aimport org.xml.sax.SAXException;
286N/Aimport org.xml.sax.ext.LexicalHandler;
286N/A
286N/A/**
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 *
286N/A * This class is not a public API, it is only public because it is used by Xalan.
286N/A * @xsl.usage internal
286N/A */
286N/Apublic final class ToXMLSAXHandler extends ToSAXHandler
286N/A{
286N/A
286N/A /**
286N/A * Keeps track of whether output escaping is currently enabled
286N/A */
293N/A protected boolean m_escapeSetting = true;
286N/A
286N/A public ToXMLSAXHandler()
286N/A {
286N/A // default constructor (need to set content handler ASAP !)
286N/A m_prefixMap = new NamespaceMappings();
286N/A initCDATA();
286N/A }
286N/A
286N/A /**
286N/A * @see Serializer#getOutputFormat()
286N/A */
286N/A public Properties getOutputFormat()
286N/A {
286N/A return null;
286N/A }
286N/A
286N/A /**
286N/A * @see Serializer#getOutputStream()
286N/A */
286N/A public OutputStream getOutputStream()
286N/A {
286N/A return null;
286N/A }
286N/A
286N/A /**
286N/A * @see Serializer#getWriter()
286N/A */
286N/A public Writer getWriter()
286N/A {
286N/A return null;
286N/A }
286N/A
286N/A /**
286N/A * Do nothing for SAX.
286N/A */
286N/A public void indent(int n) throws SAXException
286N/A {
286N/A }
286N/A
286N/A
286N/A /**
286N/A * @see DOMSerializer#serialize(Node)
286N/A */
286N/A public void serialize(Node node) throws IOException
286N/A {
286N/A }
286N/A
286N/A /**
286N/A * @see SerializationHandler#setEscaping(boolean)
286N/A */
286N/A public boolean setEscaping(boolean escape) throws SAXException
286N/A {
286N/A boolean oldEscapeSetting = m_escapeSetting;
286N/A m_escapeSetting = escape;
286N/A
286N/A if (escape) {
286N/A processingInstruction(Result.PI_ENABLE_OUTPUT_ESCAPING, "");
286N/A } else {
286N/A processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "");
286N/A }
286N/A
286N/A return oldEscapeSetting;
286N/A }
286N/A
286N/A /**
286N/A * @see Serializer#setOutputFormat(Properties)
286N/A */
286N/A public void setOutputFormat(Properties format)
286N/A {
286N/A }
286N/A
286N/A /**
286N/A * @see Serializer#setOutputStream(OutputStream)
286N/A */
286N/A public void setOutputStream(OutputStream output)
286N/A {
286N/A }
286N/A
286N/A /**
286N/A * @see Serializer#setWriter(Writer)
286N/A */
286N/A public void setWriter(Writer writer)
286N/A {
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
286N/A */
286N/A public void attributeDecl(
286N/A String arg0,
286N/A String arg1,
286N/A String arg2,
286N/A String arg3,
286N/A String arg4)
286N/A throws SAXException
286N/A {
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
286N/A */
286N/A public void elementDecl(String arg0, String arg1) throws SAXException
286N/A {
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
286N/A */
286N/A public void externalEntityDecl(String arg0, String arg1, String arg2)
286N/A throws SAXException
286N/A {
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)
286N/A */
286N/A public void internalEntityDecl(String arg0, String arg1)
286N/A throws SAXException
286N/A {
286N/A }
286N/A
286N/A /**
286N/A * Receives notification of the end of the document.
286N/A * @see org.xml.sax.ContentHandler#endDocument()
286N/A */
286N/A public void endDocument() throws SAXException
286N/A {
286N/A
286N/A flushPending();
286N/A
286N/A // Close output document
286N/A m_saxHandler.endDocument();
286N/A
286N/A if (m_tracer != null)
286N/A super.fireEndDoc();
286N/A }
286N/A
286N/A /**
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 */
286N/A protected void closeStartTag() throws SAXException
286N/A {
286N/A
286N/A m_elemContext.m_startTagOpen = false;
286N/A
286N/A final String localName = getLocalName(m_elemContext.m_elementName);
286N/A final String uri = getNamespaceURI(m_elemContext.m_elementName, true);
286N/A
286N/A // Now is time to send the startElement event
286N/A if (m_needToCallStartDocument)
286N/A {
286N/A startDocumentInternal();
286N/A }
286N/A m_saxHandler.startElement(uri, localName, m_elemContext.m_elementName, m_attributes);
286N/A // we've sent the official SAX attributes on their way,
286N/A // now we don't need them anymore.
286N/A m_attributes.clear();
286N/A
286N/A if(m_state != null)
286N/A m_state.setCurrentNode(null);
286N/A }
286N/A
286N/A /**
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 * handler.
286N/A *
286N/A */
286N/A public void closeCDATA() throws SAXException
286N/A {
286N/A
286N/A // Output closing bracket - "]]>"
286N/A if (m_lexHandler != null && m_cdataTagOpen) {
286N/A m_lexHandler.endCDATA();
286N/A }
286N/A
286N/A
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 m_cdataTagOpen = false;
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ContentHandler#endElement(String, String, String)
286N/A */
286N/A public void endElement(String namespaceURI, String localName, String qName)
286N/A throws SAXException
286N/A {
286N/A // Close any open elements etc.
286N/A flushPending();
286N/A
286N/A if (namespaceURI == null)
286N/A {
286N/A if (m_elemContext.m_elementURI != null)
286N/A namespaceURI = m_elemContext.m_elementURI;
286N/A else
286N/A namespaceURI = getNamespaceURI(qName, true);
286N/A }
286N/A
286N/A if (localName == null)
286N/A {
286N/A if (m_elemContext.m_elementLocalName != null)
286N/A localName = m_elemContext.m_elementLocalName;
286N/A else
286N/A localName = getLocalName(qName);
286N/A }
286N/A
286N/A m_saxHandler.endElement(namespaceURI, localName, qName);
286N/A
286N/A if (m_tracer != null)
286N/A super.fireEndElem(qName);
286N/A
286N/A /* Pop all namespaces at the current element depth.
286N/A * We are not waiting for official endPrefixMapping() calls.
286N/A */
286N/A m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth,
286N/A m_saxHandler);
286N/A m_elemContext = m_elemContext.m_prev;
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ContentHandler#endPrefixMapping(String)
286N/A */
286N/A public void endPrefixMapping(String prefix) throws SAXException
286N/A {
286N/A /* poping all prefix mappings should have been done
286N/A * in endElement() already
286N/A */
286N/A return;
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
286N/A */
286N/A public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
286N/A throws SAXException
286N/A {
286N/A m_saxHandler.ignorableWhitespace(arg0,arg1,arg2);
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
286N/A */
286N/A public void setDocumentLocator(Locator arg0)
286N/A {
286N/A super.setDocumentLocator(arg0);
286N/A m_saxHandler.setDocumentLocator(arg0);
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ContentHandler#skippedEntity(String)
286N/A */
286N/A public void skippedEntity(String arg0) throws SAXException
286N/A {
286N/A m_saxHandler.skippedEntity(arg0);
286N/A }
286N/A
286N/A /**
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 */
286N/A public void startPrefixMapping(String prefix, String uri)
286N/A throws SAXException
286N/A {
286N/A startPrefixMapping(prefix, uri, true);
286N/A }
286N/A
286N/A /**
286N/A * Remember the prefix/uri mapping at the current nested element depth.
286N/A *
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 */
286N/A
286N/A public boolean startPrefixMapping(
286N/A String prefix,
286N/A String uri,
286N/A boolean shouldFlush)
286N/A throws org.xml.sax.SAXException
286N/A {
286N/A
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 */
286N/A
286N/A boolean pushed;
286N/A int pushDepth;
286N/A if (shouldFlush)
286N/A {
286N/A flushPending();
286N/A // the prefix mapping applies to the child element (one deeper)
286N/A pushDepth = m_elemContext.m_currentElemDepth + 1;
286N/A }
286N/A else
286N/A {
286N/A // the prefix mapping applies to the current element
286N/A pushDepth = m_elemContext.m_currentElemDepth;
286N/A }
286N/A pushed = m_prefixMap.pushNamespace(prefix, uri, pushDepth);
286N/A
286N/A if (pushed)
286N/A {
286N/A m_saxHandler.startPrefixMapping(prefix,uri);
286N/A
286N/A if (getShouldOutputNSAttr())
286N/A {
286N/A
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 */
286N/A String name;
286N/A if (EMPTYSTRING.equals(prefix))
286N/A {
286N/A name = "xmlns";
286N/A addAttributeAlways(XMLNS_URI, name, name,"CDATA",uri, false);
286N/A }
286N/A else
286N/A {
286N/A if (!EMPTYSTRING.equals(uri)) // hack for XSLTC attribset16 test
286N/A { // that maps ns1 prefix to "" URI
286N/A name = "xmlns:" + prefix;
286N/A
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 */
286N/A addAttributeAlways(XMLNS_URI, prefix, name,"CDATA",uri, false );
286N/A }
286N/A }
286N/A }
286N/A }
286N/A return pushed;
286N/A }
286N/A
286N/A
286N/A /**
286N/A * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
286N/A */
286N/A public void comment(char[] arg0, int arg1, int arg2) throws SAXException
286N/A {
286N/A flushPending();
286N/A if (m_lexHandler != null)
286N/A m_lexHandler.comment(arg0, arg1, arg2);
286N/A
286N/A if (m_tracer != null)
286N/A super.fireCommentEvent(arg0, arg1, arg2);
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ext.LexicalHandler#endCDATA()
286N/A */
286N/A public void endCDATA() throws SAXException
286N/A {
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 * in flushPending().
286N/A *
286N/A * This is so that if we get calls like these:
286N/A * this.startCDATA();
286N/A * this.characters(chars1, off1, len1);
286N/A * this.endCDATA();
286N/A * this.startCDATA();
286N/A * this.characters(chars2, off2, len2);
286N/A * this.endCDATA();
286N/A *
286N/A * that we will only make these calls to the wrapped handlers:
286N/A *
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 *
286N/A * We will merge adjacent CDATA blocks.
286N/A */
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ext.LexicalHandler#endDTD()
286N/A */
286N/A public void endDTD() throws SAXException
286N/A {
286N/A if (m_lexHandler != null)
286N/A m_lexHandler.endDTD();
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ext.LexicalHandler#startEntity(String)
286N/A */
286N/A public void startEntity(String arg0) throws SAXException
286N/A {
286N/A if (m_lexHandler != null)
286N/A m_lexHandler.startEntity(arg0);
286N/A }
286N/A
286N/A /**
286N/A * @see ExtendedContentHandler#characters(String)
286N/A */
286N/A public void characters(String chars) throws SAXException
286N/A {
286N/A final int length = chars.length();
286N/A if (length > m_charsBuff.length)
286N/A {
286N/A m_charsBuff = new char[length*2 + 1];
286N/A }
286N/A chars.getChars(0, length, m_charsBuff, 0);
286N/A this.characters(m_charsBuff, 0, length);
286N/A }
286N/A
286N/A /////////////////// from XSLTC //////////////
286N/A public ToXMLSAXHandler(ContentHandler handler, String encoding)
286N/A {
286N/A super(handler, encoding);
286N/A
286N/A initCDATA();
286N/A // initNamespaces();
286N/A m_prefixMap = new NamespaceMappings();
286N/A }
286N/A
286N/A public ToXMLSAXHandler(
286N/A ContentHandler handler,
286N/A LexicalHandler lex,
286N/A String encoding)
286N/A {
286N/A super(handler, lex, encoding);
286N/A
286N/A initCDATA();
286N/A // initNamespaces();
286N/A m_prefixMap = new NamespaceMappings();
286N/A }
286N/A
286N/A /**
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 */
286N/A public void startElement(
286N/A String elementNamespaceURI,
286N/A String elementLocalName,
286N/A String elementName) throws SAXException
286N/A {
286N/A startElement(
286N/A elementNamespaceURI,elementLocalName,elementName, null);
286N/A
286N/A
286N/A }
286N/A public void startElement(String elementName) throws SAXException
286N/A {
286N/A startElement(null, null, elementName, null);
286N/A }
286N/A
286N/A
286N/A public void characters(char[] ch, int off, int len) throws SAXException
286N/A {
286N/A // We do the first two things in flushPending() but we don't
286N/A // close any open CDATA calls.
286N/A if (m_needToCallStartDocument)
286N/A {
286N/A startDocumentInternal();
286N/A m_needToCallStartDocument = false;
286N/A }
286N/A
286N/A if (m_elemContext.m_startTagOpen)
286N/A {
286N/A closeStartTag();
286N/A m_elemContext.m_startTagOpen = false;
286N/A }
286N/A
286N/A if (m_elemContext.m_isCdataSection && !m_cdataTagOpen
286N/A && m_lexHandler != null)
286N/A {
286N/A m_lexHandler.startCDATA();
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 m_cdataTagOpen = true;
286N/A }
286N/A
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 */
286N/A m_saxHandler.characters(ch, off, len);
286N/A
286N/A // time to generate characters event
286N/A if (m_tracer != null)
286N/A fireCharEvent(ch, off, len);
286N/A }
286N/A
286N/A
286N/A /**
286N/A * @see ExtendedContentHandler#endElement(String)
286N/A */
286N/A public void endElement(String elemName) throws SAXException
286N/A {
286N/A endElement(null, null, elemName);
286N/A }
286N/A
286N/A
286N/A /**
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 */
286N/A public void namespaceAfterStartElement(
286N/A final String prefix,
286N/A final String uri)
286N/A throws SAXException
286N/A {
286N/A startPrefixMapping(prefix,uri,false);
286N/A }
286N/A
286N/A /**
286N/A *
286N/A * @see org.xml.sax.ContentHandler#processingInstruction(String, String)
286N/A * Send a processing instruction to the output document
286N/A */
286N/A public void processingInstruction(String target, String data)
286N/A throws SAXException
286N/A {
286N/A flushPending();
286N/A
286N/A // Pass the processing instruction to the SAX handler
286N/A m_saxHandler.processingInstruction(target, data);
286N/A
286N/A // we don't want to leave serializer to fire off this event,
286N/A // so do it here.
286N/A if (m_tracer != null)
286N/A super.fireEscapingEvent(target, data);
286N/A }
286N/A
286N/A /**
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 */
286N/A protected boolean popNamespace(String prefix)
286N/A {
286N/A try
286N/A {
286N/A if (m_prefixMap.popNamespace(prefix))
286N/A {
286N/A m_saxHandler.endPrefixMapping(prefix);
286N/A return true;
286N/A }
286N/A }
286N/A catch (SAXException e)
286N/A {
286N/A // falls through
286N/A }
286N/A return false;
286N/A }
286N/A
286N/A public void startCDATA() throws SAXException
286N/A {
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 */
286N/A if (!m_cdataTagOpen )
286N/A {
286N/A flushPending();
286N/A if (m_lexHandler != null) {
286N/A m_lexHandler.startCDATA();
286N/A
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 m_cdataTagOpen = true;
286N/A }
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
286N/A */
286N/A public void startElement(
286N/A String namespaceURI,
286N/A String localName,
286N/A String name,
286N/A Attributes atts)
286N/A throws SAXException
286N/A {
286N/A flushPending();
286N/A super.startElement(namespaceURI, localName, name, atts);
286N/A
286N/A // Handle document type declaration (for first element only)
286N/A if (m_needToOutputDocTypeDecl)
286N/A {
286N/A String doctypeSystem = getDoctypeSystem();
286N/A if (doctypeSystem != null && m_lexHandler != null)
286N/A {
286N/A String doctypePublic = getDoctypePublic();
286N/A if (doctypeSystem != null)
286N/A m_lexHandler.startDTD(
286N/A name,
286N/A doctypePublic,
286N/A doctypeSystem);
286N/A }
286N/A m_needToOutputDocTypeDecl = false;
286N/A }
286N/A m_elemContext = m_elemContext.push(namespaceURI, localName, name);
286N/A
286N/A // ensurePrefixIsDeclared depends on the current depth, so
286N/A // the previous increment is necessary where it is.
286N/A if (namespaceURI != null)
286N/A ensurePrefixIsDeclared(namespaceURI, name);
286N/A
286N/A // add the attributes to the collected ones
286N/A if (atts != null)
286N/A addAttributes(atts);
286N/A
286N/A
286N/A // do we really need this CDATA section state?
286N/A m_elemContext.m_isCdataSection = isCdataSection();
286N/A
286N/A }
286N/A
286N/A private void ensurePrefixIsDeclared(String ns, String rawName)
286N/A throws org.xml.sax.SAXException
286N/A {
286N/A
286N/A if (ns != null && ns.length() > 0)
286N/A {
286N/A int index;
286N/A final boolean no_prefix = ((index = rawName.indexOf(":")) < 0);
286N/A String prefix = (no_prefix) ? "" : rawName.substring(0, index);
286N/A
286N/A
286N/A if (null != prefix)
286N/A {
286N/A String foundURI = m_prefixMap.lookupNamespace(prefix);
286N/A
286N/A if ((null == foundURI) || !foundURI.equals(ns))
286N/A {
286N/A this.startPrefixMapping(prefix, ns, false);
286N/A
286N/A if (getShouldOutputNSAttr()) {
286N/A // Bugzilla1133: Generate attribute as well as namespace event.
286N/A // SAX does expect both.
286N/A this.addAttributeAlways(
286N/A "http://www.w3.org/2000/xmlns/",
286N/A no_prefix ? "xmlns" : prefix, // local name
286N/A no_prefix ? "xmlns" : ("xmlns:"+ prefix), // qname
286N/A "CDATA",
286N/A ns,
286N/A false);
286N/A }
286N/A }
286N/A
286N/A }
286N/A }
286N/A }
286N/A /**
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 *
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 */
286N/A public void addAttribute(
286N/A String uri,
286N/A String localName,
286N/A String rawName,
286N/A String type,
286N/A String value,
286N/A boolean XSLAttribute)
286N/A throws SAXException
286N/A {
286N/A if (m_elemContext.m_startTagOpen)
286N/A {
286N/A ensurePrefixIsDeclared(uri, rawName);
286N/A addAttributeAlways(uri, localName, rawName, type, value, false);
286N/A }
286N/A
286N/A }
286N/A
286N/A /**
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 *
286N/A * @return true if the class was successfuly reset.
286N/A * @see Serializer#reset()
286N/A */
286N/A public boolean reset()
286N/A {
286N/A boolean wasReset = false;
286N/A if (super.reset())
286N/A {
286N/A resetToXMLSAXHandler();
286N/A wasReset = true;
286N/A }
286N/A return wasReset;
286N/A }
286N/A
286N/A /**
286N/A * Reset all of the fields owned by ToXMLSAXHandler class
286N/A *
286N/A */
286N/A private void resetToXMLSAXHandler()
286N/A {
293N/A this.m_escapeSetting = true;
286N/A }
286N/A
286N/A}