2016/05/28 - Apache Tuscany has been retired.
For more information, please explore the Attic.
org.apache.tuscany.sca.databinding.xml
Class StAX2SAXAdapter
java.lang.Object
org.apache.tuscany.sca.databinding.xml.StAX2SAXAdapter
public class StAX2SAXAdapter
- extends java.lang.Object
Adapter that converts from StAX to SAX event streams. Currently the following
SAX events are not generated:
- ignorableWhitespace
- skippedEntity
Also the following StAX events are not mapped:
- CDATA
- COMMENT
- DTD
- ENTITY_DECLARATION
- ENTITY_REFERENCE
- NOTATION_DECLARATION
- SPACE
StAX ATTRIBUTE events are ignored but the equivalent attributes (derived from
the START_ELEMENT event) are supplied in the SAX startElement event's
Attributes parameter. If the adaptor is configured to pass namespace prefixes
then namespace information will also be included in the Attributes; StAX
NAMESPACE events are ignored. Another issue is namespace processing. If
the reader is positioned at a sub-node, we cannot capture all the in-scope
namespace bindings. Therefore we cannot re-create a proper SAX event stream
from a StAX parser. For example <a:root xmlns:a="foo"
xmlns:b="bar"><b:sub>a:foo</b:sub></a:root> And if
you are handed a parser at <b:sub>, then your SAX events should look
like: <b:sub xmlns:a="foo" xmlns:b="bar">a:foo</b:sub>
not: <b:sub>a:foo</b:sub> Proposal: we change the
receiver of SAX events (SDOXMLResourceImpl) so that it uses NamespaceContext
to resolve prefix (as opposed to record start/endPrefixMappings and use it
for resolution.)
Constructor Summary |
StAX2SAXAdapter(boolean namespacePrefixes)
Construct a new StAX to SAX adapter that will convert a StAX event stream
into a SAX event stream. |
Method Summary |
void |
parse(javax.xml.stream.XMLStreamReader reader,
org.xml.sax.ContentHandler handler)
Pull events from the StAX stream and dispatch to the SAX ContentHandler. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StAX2SAXAdapter
public StAX2SAXAdapter(boolean namespacePrefixes)
- Construct a new StAX to SAX adapter that will convert a StAX event stream
into a SAX event stream.
- Parameters:
namespacePrefixes
- whether xmlns attributes should be included in
startElement events;
parse
public void parse(javax.xml.stream.XMLStreamReader reader,
org.xml.sax.ContentHandler handler)
throws javax.xml.stream.XMLStreamException,
org.xml.sax.SAXException
- Pull events from the StAX stream and dispatch to the SAX ContentHandler.
The StAX stream would typically be located on a START_DOCUMENT or
START_ELEMENT event and when this method returns it will be located on
the associated END_DOCUMENT or END_ELEMENT event. Behaviour with other
start events is undefined.
- Parameters:
reader
- StAX event source to readhandler
- SAX ContentHandler for processing events
- Throws:
javax.xml.stream.XMLStreamException
- if there was a problem reading the stream
org.xml.sax.SAXException
- passed through from the ContentHandler