| Method from com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler Detail: |
public void addAttribute(String uri,
String localName,
String rawName,
String type,
String value,
boolean XSLAttribute) throws SAXException {
if (m_elemContext.m_startTagOpen)
{
ensurePrefixIsDeclared(uri, rawName);
addAttributeAlways(uri, localName, rawName, type, value, false);
}
}
Adds the given attribute to the set of attributes, and also makes sure
that the needed prefix/uri mapping is declared, but only if there is a
currently open element. |
public void attributeDecl(String arg0,
String arg1,
String arg2,
String arg3,
String arg4) throws SAXException {
}
|
public void characters(String chars) throws SAXException {
final int length = chars.length();
if (length > m_charsBuff.length)
{
m_charsBuff = new char[length*2 + 1];
}
chars.getChars(0, length, m_charsBuff, 0);
this.characters(m_charsBuff, 0, length);
}
|
public void characters(char[] ch,
int off,
int len) throws SAXException {
// We do the first two things in flushPending() but we don't
// close any open CDATA calls.
if (m_needToCallStartDocument)
{
startDocumentInternal();
m_needToCallStartDocument = false;
}
if (m_elemContext.m_startTagOpen)
{
closeStartTag();
m_elemContext.m_startTagOpen = false;
}
if (m_elemContext.m_isCdataSection && !m_cdataTagOpen
&& m_lexHandler != null)
{
m_lexHandler.startCDATA();
// We have made a call to m_lexHandler.startCDATA() with
// no balancing call to m_lexHandler.endCDATA()
// so we set m_cdataTagOpen true to remember this.
m_cdataTagOpen = true;
}
/* If there are any occurances of "]] >" in the character data
* let m_saxHandler worry about it, we've already warned them with
* the previous call of m_lexHandler.startCDATA();
*/
m_saxHandler.characters(ch, off, len);
// time to generate characters event
if (m_tracer != null)
fireCharEvent(ch, off, len);
}
|
public void closeCDATA() throws SAXException {
// Output closing bracket - "]] >"
if (m_lexHandler != null && m_cdataTagOpen) {
m_lexHandler.endCDATA();
}
// There are no longer any calls made to
// m_lexHandler.startCDATA() without a balancing call to
// m_lexHandler.endCDATA()
// so we set m_cdataTagOpen to false to remember this.
m_cdataTagOpen = false;
}
Closes ane open cdata tag, and
unlike the this.endCDATA() method (from the LexicalHandler) interface,
this "internal" method will send the endCDATA() call to the wrapped
handler. |
protected void closeStartTag() throws SAXException {
m_elemContext.m_startTagOpen = false;
final String localName = getLocalName(m_elemContext.m_elementName);
final String uri = getNamespaceURI(m_elemContext.m_elementName, true);
// Now is time to send the startElement event
if (m_needToCallStartDocument)
{
startDocumentInternal();
}
m_saxHandler.startElement(uri, localName, m_elemContext.m_elementName, m_attributes);
// we've sent the official SAX attributes on their way,
// now we don't need them anymore.
m_attributes.clear();
if(m_state != null)
m_state.setCurrentNode(null);
}
This method is called when all the data needed for a call to the
SAX handler's startElement() method has been gathered. |
public void comment(char[] arg0,
int arg1,
int arg2) throws SAXException {
flushPending();
if (m_lexHandler != null)
m_lexHandler.comment(arg0, arg1, arg2);
if (m_tracer != null)
super.fireCommentEvent(arg0, arg1, arg2);
}
|
public void elementDecl(String arg0,
String arg1) throws SAXException {
}
|
public void endCDATA() throws SAXException {
/* Normally we would do somthing with this but we ignore it.
* The neccessary call to m_lexHandler.endCDATA() will be made
* in flushPending().
*
* This is so that if we get calls like these:
* this.startCDATA();
* this.characters(chars1, off1, len1);
* this.endCDATA();
* this.startCDATA();
* this.characters(chars2, off2, len2);
* this.endCDATA();
*
* that we will only make these calls to the wrapped handlers:
*
* m_lexHandler.startCDATA();
* m_saxHandler.characters(chars1, off1, len1);
* m_saxHandler.characters(chars1, off2, len2);
* m_lexHandler.endCDATA();
*
* We will merge adjacent CDATA blocks.
*/
}
|
public void endDTD() throws SAXException {
if (m_lexHandler != null)
m_lexHandler.endDTD();
}
|
public void endDocument() throws SAXException {
flushPending();
// Close output document
m_saxHandler.endDocument();
if (m_tracer != null)
super.fireEndDoc();
}
Receives notification of the end of the document. |
public void endElement(String elemName) throws SAXException {
endElement(null, null, elemName);
}
|
public void endElement(String namespaceURI,
String localName,
String qName) throws SAXException {
// Close any open elements etc.
flushPending();
if (namespaceURI == null)
{
if (m_elemContext.m_elementURI != null)
namespaceURI = m_elemContext.m_elementURI;
else
namespaceURI = getNamespaceURI(qName, true);
}
if (localName == null)
{
if (m_elemContext.m_elementLocalName != null)
localName = m_elemContext.m_elementLocalName;
else
localName = getLocalName(qName);
}
m_saxHandler.endElement(namespaceURI, localName, qName);
if (m_tracer != null)
super.fireEndElem(qName);
/* Pop all namespaces at the current element depth.
* We are not waiting for official endPrefixMapping() calls.
*/
m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth,
m_saxHandler);
m_elemContext = m_elemContext.m_prev;
}
|
public void endPrefixMapping(String prefix) throws SAXException {
/* poping all prefix mappings should have been done
* in endElement() already
*/
return;
}
|
public void externalEntityDecl(String arg0,
String arg1,
String arg2) throws SAXException {
}
|
public Properties getOutputFormat() {
return null;
}
|
public OutputStream getOutputStream() {
return null;
}
|
public Writer getWriter() {
return null;
}
|
public void ignorableWhitespace(char[] arg0,
int arg1,
int arg2) throws SAXException {
m_saxHandler.ignorableWhitespace(arg0,arg1,arg2);
}
|
public void indent(int n) throws SAXException {
}
|
public void internalEntityDecl(String arg0,
String arg1) throws SAXException {
}
|
public void namespaceAfterStartElement(String prefix,
String uri) throws SAXException {
startPrefixMapping(prefix,uri,false);
}
Send a namespace declaration in the output document. The namespace
declaration will not be include if the namespace is already in scope
with the same prefix. |
protected boolean popNamespace(String prefix) {
try
{
if (m_prefixMap.popNamespace(prefix))
{
m_saxHandler.endPrefixMapping(prefix);
return true;
}
}
catch (SAXException e)
{
// falls through
}
return false;
}
Undeclare the namespace that is currently pointed to by a given
prefix. Inform SAX handler if prefix was previously mapped. |
public void processingInstruction(String target,
String data) throws SAXException {
flushPending();
// Pass the processing instruction to the SAX handler
m_saxHandler.processingInstruction(target, data);
// we don't want to leave serializer to fire off this event,
// so do it here.
if (m_tracer != null)
super.fireEscapingEvent(target, data);
}
|
public boolean reset() {
boolean wasReset = false;
if (super.reset())
{
resetToXMLSAXHandler();
wasReset = true;
}
return wasReset;
}
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). |
public void serialize(Node node) throws IOException {
}
|
public void setDocumentLocator(Locator arg0) {
super.setDocumentLocator(arg0);
m_saxHandler.setDocumentLocator(arg0);
}
|
public boolean setEscaping(boolean escape) throws SAXException {
boolean oldEscapeSetting = m_escapeSetting;
m_escapeSetting = escape;
if (escape) {
processingInstruction(Result.PI_ENABLE_OUTPUT_ESCAPING, "");
} else {
processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "");
}
return oldEscapeSetting;
}
|
public void setOutputFormat(Properties format) {
}
|
public void setOutputStream(OutputStream output) {
}
|
public void setWriter(Writer writer) {
}
|
public void skippedEntity(String arg0) throws SAXException {
m_saxHandler.skippedEntity(arg0);
}
|
public void startCDATA() throws SAXException {
/* m_cdataTagOpen can only be true here if we have ignored the
* previous call to this.endCDATA() and the previous call
* this.startCDATA() before that is still "open". In this way
* we merge adjacent CDATA. If anything else happened after the
* ignored call to this.endCDATA() and this call then a call to
* flushPending() would have been made which would have
* closed the CDATA and set m_cdataTagOpen to false.
*/
if (!m_cdataTagOpen )
{
flushPending();
if (m_lexHandler != null) {
m_lexHandler.startCDATA();
// We have made a call to m_lexHandler.startCDATA() with
// no balancing call to m_lexHandler.endCDATA()
// so we set m_cdataTagOpen true to remember this.
m_cdataTagOpen = true;
}
}
}
|
public void startElement(String elementName) throws SAXException {
startElement(null, null, elementName, null);
}
|
public void startElement(String elementNamespaceURI,
String elementLocalName,
String elementName) throws SAXException {
startElement(
elementNamespaceURI,elementLocalName,elementName, null);
}
Start an element in the output document. This might be an XML element
(data type) or a CDATA section. |
public void startElement(String namespaceURI,
String localName,
String name,
Attributes atts) throws SAXException {
flushPending();
super.startElement(namespaceURI, localName, name, atts);
// Handle document type declaration (for first element only)
if (m_needToOutputDocTypeDecl)
{
String doctypeSystem = getDoctypeSystem();
if (doctypeSystem != null && m_lexHandler != null)
{
String doctypePublic = getDoctypePublic();
if (doctypeSystem != null)
m_lexHandler.startDTD(
name,
doctypePublic,
doctypeSystem);
}
m_needToOutputDocTypeDecl = false;
}
m_elemContext = m_elemContext.push(namespaceURI, localName, name);
// ensurePrefixIsDeclared depends on the current depth, so
// the previous increment is necessary where it is.
if (namespaceURI != null)
ensurePrefixIsDeclared(namespaceURI, name);
// add the attributes to the collected ones
if (atts != null)
addAttributes(atts);
// do we really need this CDATA section state?
m_elemContext.m_isCdataSection = isCdataSection();
}
|
public void startEntity(String arg0) throws SAXException {
if (m_lexHandler != null)
m_lexHandler.startEntity(arg0);
}
|
public void startPrefixMapping(String prefix,
String uri) throws SAXException {
startPrefixMapping(prefix, uri, true);
}
|
public boolean startPrefixMapping(String prefix,
String uri,
boolean shouldFlush) throws SAXException {
/* Remember the mapping, and at what depth it was declared
* This is one greater than the current depth because these
* mappings will apply to the next depth. This is in
* consideration that startElement() will soon be called
*/
boolean pushed;
int pushDepth;
if (shouldFlush)
{
flushPending();
// the prefix mapping applies to the child element (one deeper)
pushDepth = m_elemContext.m_currentElemDepth + 1;
}
else
{
// the prefix mapping applies to the current element
pushDepth = m_elemContext.m_currentElemDepth;
}
pushed = m_prefixMap.pushNamespace(prefix, uri, pushDepth);
if (pushed)
{
m_saxHandler.startPrefixMapping(prefix,uri);
if (getShouldOutputNSAttr())
{
/* Brian M.: don't know if we really needto do this. The
* callers of this object should have injected both
* startPrefixMapping and the attributes. We are
* just covering our butt here.
*/
String name;
if (EMPTYSTRING.equals(prefix))
{
name = "xmlns";
addAttributeAlways(XMLNS_URI, name, name,"CDATA",uri, false);
}
else
{
if (!EMPTYSTRING.equals(uri)) // hack for XSLTC attribset16 test
{ // that maps ns1 prefix to "" URI
name = "xmlns:" + prefix;
/* for something like xmlns:abc="w3.pretend.org"
* the uri is the value, that is why we pass it in the
* value, or 5th slot of addAttributeAlways()
*/
addAttributeAlways(XMLNS_URI, prefix, name,"CDATA",uri, false );
}
}
}
}
return pushed;
}
Remember the prefix/uri mapping at the current nested element depth. |