Methods Summary |
---|
public void | addAttribute(java.lang.String uri, java.lang.String localName, java.lang.String rawName, java.lang.String type, java.lang.String value)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.
if (m_elemContext.m_startTagOpen)
{
ensurePrefixIsDeclared(uri, rawName);
addAttributeAlways(uri, localName, rawName, type, value);
}
|
public void | attributeDecl(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4)
|
public void | characters(java.lang.String chars)
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)
// 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()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.
// 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;
|
protected void | closeStartTag()This method is called when all the data needed for a call to the
SAX handler's startElement() method has been gathered.
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);
|
public void | comment(char[] arg0, int arg1, int arg2)
flushPending();
if (m_lexHandler != null)
m_lexHandler.comment(arg0, arg1, arg2);
if (m_tracer != null)
super.fireCommentEvent(arg0, arg1, arg2);
|
public void | elementDecl(java.lang.String arg0, java.lang.String arg1)
|
public void | endCDATA()
/* 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()
if (m_lexHandler != null)
m_lexHandler.endDTD();
|
public void | endDocument()Receives notification of the end of the document.
flushPending();
// Close output document
m_saxHandler.endDocument();
if (m_tracer != null)
super.fireEndDoc();
|
public void | endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
// 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 | endElement(java.lang.String elemName)
endElement(null, null, elemName);
|
public void | endPrefixMapping(java.lang.String prefix)
/* poping all prefix mappings should have been done
* in endElement() already
*/
return;
|
private void | ensurePrefixIsDeclared(java.lang.String ns, java.lang.String rawName)
if (ns != null && ns.length() > 0)
{
int index;
String prefix =
(index = rawName.indexOf(":")) < 0
? ""
: rawName.substring(0, index);
if (null != prefix)
{
String foundURI = m_prefixMap.lookupNamespace(prefix);
if ((null == foundURI) || !foundURI.equals(ns))
{
this.startPrefixMapping(prefix, ns, false);
if (getShouldOutputNSAttr()) {
// Bugzilla1133: Generate attribute as well as namespace event.
// SAX does expect both.
this.addAttributeAlways(
"http://www.w3.org/2000/xmlns/",
prefix,
"xmlns" + (prefix.length() == 0 ? "" : ":") + prefix,
"CDATA",
ns);
}
}
}
}
|
public void | externalEntityDecl(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)
|
public java.util.Properties | getOutputFormat()
return null;
|
public java.io.OutputStream | getOutputStream()
return null;
|
public java.io.Writer | getWriter()
return null;
|
public void | ignorableWhitespace(char[] arg0, int arg1, int arg2)
m_saxHandler.ignorableWhitespace(arg0,arg1,arg2);
|
public void | indent(int n)Do nothing for SAX.
|
public void | internalEntityDecl(java.lang.String arg0, java.lang.String arg1)
|
public void | namespaceAfterStartElement(java.lang.String prefix, java.lang.String uri)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.
startPrefixMapping(prefix,uri,false);
|
protected boolean | popNamespace(java.lang.String prefix)Undeclare the namespace that is currently pointed to by a given
prefix. Inform SAX handler if prefix was previously mapped.
try
{
if (m_prefixMap.popNamespace(prefix))
{
m_saxHandler.endPrefixMapping(prefix);
return true;
}
}
catch (SAXException e)
{
// falls through
}
return false;
|
public void | processingInstruction(java.lang.String target, java.lang.String data)
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()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).
boolean wasReset = false;
if (super.reset())
{
resetToXMLSAXHandler();
wasReset = true;
}
return wasReset;
|
private void | resetToXMLSAXHandler()Reset all of the fields owned by ToXMLSAXHandler class
this.m_escapeSetting = false;
|
public void | serialize(org.w3c.dom.Node node)
|
public void | setDocumentLocator(org.xml.sax.Locator arg0)
m_saxHandler.setDocumentLocator(arg0);
|
public boolean | setEscaping(boolean escape)
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(java.util.Properties format)
|
public void | setOutputStream(java.io.OutputStream output)
|
public void | setWriter(java.io.Writer writer)
|
public void | skippedEntity(java.lang.String arg0)
m_saxHandler.skippedEntity(arg0);
|
public void | startCDATA()
/* 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(java.lang.String elementNamespaceURI, java.lang.String elementLocalName, java.lang.String elementName)Start an element in the output document. This might be an XML element
(data type) or a CDATA section.
startElement(
elementNamespaceURI,elementLocalName,elementName, null);
|
public void | startElement(java.lang.String elementName)
startElement(null, null, elementName, null);
|
public void | startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes atts)
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(java.lang.String arg0)
if (m_lexHandler != null)
m_lexHandler.startEntity(arg0);
|
public void | startPrefixMapping(java.lang.String prefix, java.lang.String uri)
startPrefixMapping(prefix, uri, true);
|
public boolean | startPrefixMapping(java.lang.String prefix, java.lang.String uri, boolean shouldFlush)Remember the prefix/uri mapping at the current nested element depth.
/* 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())
{
/* bjm: 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, prefix, name,"CDATA",uri);
}
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);
}
}
}
}
return pushed;
|