/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: ToSAXHandler.java,v 1.2.4.1 2005/09/22 11:03:15 pvedula Exp $
*/
/**
* This class is used to provide a base behavior to be inherited
* by other To...SAXHandler serializers.
*
* This class is not a public API.
*
* @xsl.usage internal
*/
{
public ToSAXHandler()
{
}
public ToSAXHandler(
{
}
{
}
/**
* Underlying SAX handler. Taken from XSLTC
*/
/**
* Underlying LexicalHandler. Taken from XSLTC
*/
/**
* A startPrefixMapping() call on a ToSAXHandler will pass that call
* on to the wrapped ContentHandler, but should we also mirror these calls
* with matching attributes, if so this field is true.
* For example if this field is true then a call such as
* startPrefixMapping("prefix1","uri1") will also cause the additional
* internally generated attribute xmlns:prefix1="uri1" to be effectively added
* to the attributes passed to the wrapped ContentHandler.
*/
private boolean m_shouldGenerateNSAttribute = true;
/** If this is true, then the content handler wrapped by this
* serializer implements the TransformState interface which
* will give the content handler access to the state of
* the transform. */
/**
* Pass callback to the SAX Handler
*/
{
{
super.startDocumentInternal();
m_needToCallStartDocument = false;
}
}
/**
* Do nothing.
* @see org.xml.sax.ext.LexicalHandler#startDTD(String, String, String)
*/
throws SAXException
{
// do nothing for now
}
/**
* Receive notification of character data.
*
* @param characters The string of characters to process.
*
* @throws org.xml.sax.SAXException
*
* @see ExtendedContentHandler#characters(String)
*/
{
{
}
}
/**
* Receive notification of a comment.
*
* @see ExtendedLexicalHandler#comment(String)
*/
{
flushPending();
// Ignore if a lexical handler has not been set
if (m_lexHandler != null)
{
{
}
// time to fire off comment event
}
}
/**
* Do nothing as this is an abstract class. All subclasses will need to
* define their behavior if it is different.
* @see org.xml.sax.ContentHandler#processingInstruction(String, String)
*/
throws SAXException
{
// Redefined in SAXXMLOutput
}
{
}
{
// Redefined in SAXXMLOutput
}
/**
* Receive notification of the beginning of an element, although this is a
* SAX method additional namespace or attribute information can occur before
* or after this call, that is associated with this element.
*
* @throws org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ContentHandler#startElement
* @see org.xml.sax.ContentHandler#endElement
* @see org.xml.sax.AttributeList
*
* @throws org.xml.sax.SAXException
*
* @see org.xml.sax.ContentHandler#startElement(String,String,String,Attributes)
*/
public void startElement(
throws SAXException
{
}
// fire off the start element event
super.fireStartElem(arg2);
}
/**
* Sets the LexicalHandler.
* @param _lexHandler The LexicalHandler to set
*/
{
this.m_lexHandler = _lexHandler;
}
/**
* Sets the SAX ContentHandler.
* @param _saxHandler The ContentHandler to set
*/
{
this.m_saxHandler = _saxHandler;
{
// we are not overwriting an existing LexicalHandler, and _saxHandler
// is also implements LexicalHandler, so lets use it
}
}
/**
* Does nothing. The setting of CDATA section elements has an impact on
* stream serializers.
* @see SerializationHandler#setCdataSectionElements(java.util.Vector)
*/
{
// do nothing
}
/** Set whether or not namespace declarations (e.g.
* xmlns:foo) should appear as attributes of
* elements
* @param doOutputNSAttr whether or not namespace declarations
* should appear as attributes
*/
{
}
/**
* Returns true if namespace declarations from calls such as
* startPrefixMapping("prefix1","uri1") should
* also be mirrored with self generated additional attributes of elements
* that declare the namespace, for example the attribute xmlns:prefix1="uri1"
*/
boolean getShouldOutputNSAttr()
{
return m_shouldGenerateNSAttribute;
}
/**
* This method flushes any pending events, which can be startDocument()
* closing the opening tag of an element, or closing an open CDATA section.
*/
{
{
m_needToCallStartDocument = false;
}
{
m_elemContext.m_startTagOpen = false;
}
if (m_cdataTagOpen)
{
closeCDATA();
m_cdataTagOpen = false;
}
}
/**
* Pass in a reference to a TransformState object, which
* can be used during SAX ContentHandler events to obtain
* information about he state of the transformation. This
* method will be called before each startDocument event.
*
* @param ts A reference to a TransformState object
*/
}
/**
* Receives notification that an element starts, but attributes are not
* fully known yet.
*
* @param uri the URI of the namespace of the element (optional)
* @param localName the element name, but without prefix (optional)
* @param qName the element name, with prefix, if any (required)
*
* @see ExtendedContentHandler#startElement(String, String, String)
*/
throws SAXException {
}
// fire off the start element event
super.fireStartElem(qName);
}
/**
* An element starts, but attributes are not fully known yet.
*
* @param qName the element name, with prefix (if any).
* @see ExtendedContentHandler#startElement(String)
*/
}
// fire off the start element event
super.fireStartElem(qName);
}
/**
* This method gets the node's value as a String and uses that String as if
* it were an input character notification.
* @param node the Node to serialize
* @throws org.xml.sax.SAXException
*/
{
// remember the current node
{
}
// Get the node's value as a String and use that String as if
// it were an input character notification.
this.characters(data);
}
}
/**
* @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
*/
super.fatalError(exc);
m_needToCallStartDocument = false;
if (m_saxHandler instanceof ErrorHandler) {
}
}
/**
* @see org.xml.sax.ErrorHandler#error(SAXParseException)
*/
if (m_saxHandler instanceof ErrorHandler)
}
/**
* @see org.xml.sax.ErrorHandler#warning(SAXParseException)
*/
if (m_saxHandler instanceof ErrorHandler)
}
/**
* Try's to reset the super class and reset this class for
* re-use, so that you don't need to create a new serializer
* (mostly for performance reasons).
*
* @return true if the class was successfuly reset.
* @see Serializer#reset()
*/
public boolean reset()
{
boolean wasReset = false;
if (super.reset())
{
wasReset = true;
}
return wasReset;
}
/**
* Reset all of the fields owned by ToSAXHandler class
*
*/
private void resetToSAXHandler()
{
this.m_lexHandler = null;
this.m_saxHandler = null;
this.m_shouldGenerateNSAttribute = false;
}
/**
* Add a unique attribute
*/
throws SAXException
{
}
}