com.ssx.xml.output.sinks
Class SaxSink

java.lang.Object
  extended bycom.ssx.xml.output.sinks.SaxSink
All Implemented Interfaces:
XmlSink

public class SaxSink
extends Object
implements XmlSink

Output XML to a SAX2 interface. This sink currently provides no support for the SAX2 LexicalHandler or ErrorHandler. Support for the LexicalHandler should be added soon. Support for the ErrorHandler might be added if there is a need - prehaps to report warnings? Support for the SAX2 LocationHandler is not provided and probably will not be. There is no line or column number available when the XML is generated from code. (unless we could determine the line and column number of the method call that generate the event?) No DTD handling of any kind is performed because the concept does not exist in the XmlOutput interface.


Constructor Summary
SaxSink(ContentHandler out, boolean namespaceAttribs)
          Create a sink that produces SAX events
 
Method Summary
 void close()
          The user has finished providing XML.
 void comment(String content)
          Add a comment
 void endElement(Namespace namespace, String name, List namespaceList, boolean empty)
          End an element.
 void instruction(String target, String data)
          Add a processing instruction
 void open()
          This method will be called before any other methods, after the user has provided the first xml node
 void startElement(Namespace namespace, String name, AttributeList attributes, List namespaceList, boolean empty)
          Start a new element
 void text(String text)
          Add character data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SaxSink

public SaxSink(ContentHandler out,
               boolean namespaceAttribs)
Create a sink that produces SAX events

Parameters:
out - The SAX2 Content handler that XML events will be reported to.
namespaceAttribs - Should namespace attributes be reported
Method Detail

open

public void open()
Description copied from interface: XmlSink
This method will be called before any other methods, after the user has provided the first xml node

Specified by:
open in interface XmlSink
See Also:
XmlSink.open()

comment

public void comment(String content)
Description copied from interface: XmlSink
Add a comment

Specified by:
comment in interface XmlSink
Parameters:
content - The text content of the comment
See Also:
XmlSink.comment(String)

endElement

public void endElement(Namespace namespace,
                       String name,
                       List namespaceList,
                       boolean empty)
Description copied from interface: XmlSink
End an element. If empty is true it indicates that the body of the element is empty.

Specified by:
endElement in interface XmlSink
Parameters:
namespace - The element namespace
name - The element name
namespaceList - The namespaces that were declared in this element
empty - True if the element contains no other nodes
See Also:
XmlSink.endElement( Namespace, String, List, boolean)

instruction

public void instruction(String target,
                        String data)
Description copied from interface: XmlSink
Add a processing instruction

Specified by:
instruction in interface XmlSink
Parameters:
target - The PI target
data - The PI data - structure depends on the PI
See Also:
XmlSink.instruction(String, String)

startElement

public void startElement(Namespace namespace,
                         String name,
                         AttributeList attributes,
                         List namespaceList,
                         boolean empty)
Description copied from interface: XmlSink
Start a new element

Specified by:
startElement in interface XmlSink
Parameters:
namespace - The element namespace
name - The element name
attributes - The element attributes
namespaceList - The namespaces declared in this element
empty - True if the element contains no other nodes
See Also:
XmlSink.startElement( com.ssx.xml.output.Namespace, java.lang.String, AttributeList, List, boolean)

text

public void text(String text)
Description copied from interface: XmlSink
Add character data

Specified by:
text in interface XmlSink
Parameters:
text - The String to add as character data
See Also:
XmlSink.text(String)

close

public void close()
Description copied from interface: XmlSink
The user has finished providing XML. No other methods will be called after this.

Specified by:
close in interface XmlSink
See Also:
XmlSink.close()