net.sf.saxon.event
Class StreamWriterToReceiver

java.lang.Object
  extended by net.sf.saxon.event.StreamWriterToReceiver
All Implemented Interfaces:
XMLStreamWriter

public class StreamWriterToReceiver
extends Object
implements XMLStreamWriter

This class implements the XmlStreamWriter interface, translating the events into Saxon Receiver events. The Receiver can be anything: a serializer, a schema validator, a tree builder.

The class will attempt to generate namespace prefixes where none have been supplied, unless the inventPrefixes option is set to false. The preferred mode of use is to call the versions of writeStartElement and writeAttribute that supply the prefix, URI, and local name in full. If the prefix is omitted, the class attempts to invent a prefix. If the URI is omitted, the name is assumed to be in no namespace. The writeNamespace

method should be called only if there is a need to declare a namespace prefix that is not used on any element or attribute name.

The class will check all names, URIs, and character content for conformance against XML well-formedness rules unless the checkValues option is set to false.

Since:
9.3

Constructor Summary
StreamWriterToReceiver(Receiver receiver)
          Constructor.
 
Method Summary
 void close()
           
 void flush()
           
 NamespaceContext getNamespaceContext()
           
 String getPrefix(String uri)
           
 Object getProperty(String name)
           
 boolean isCheckValues()
          Ask whether names and values are to be checked for conformance with XML rules
 boolean isInventPrefixes()
          Ask whether prefixes are to be invented when none is specified by the user
 void setCheckValues(boolean check)
          Say whether names and values are to be checked for conformance with XML rules
 void setDefaultNamespace(String uri)
           
 void setInventPrefixes(boolean invent)
          Say whether prefixes are to be invented when none is specified by the user
 void setNamespaceContext(NamespaceContext context)
           
 void setPrefix(String prefix, String uri)
           
 void writeAttribute(String localName, String value)
           
 void writeAttribute(String namespaceURI, String localName, String value)
           
 void writeAttribute(String prefix, String namespaceURI, String localName, String value)
           
 void writeCData(String data)
           
 void writeCharacters(char[] text, int start, int len)
           
 void writeCharacters(String text)
           
 void writeComment(String data)
           
 void writeDefaultNamespace(String namespaceURI)
           
 void writeDTD(String dtd)
           
 void writeEmptyElement(String localName)
           
 void writeEmptyElement(String namespaceURI, String localName)
           
 void writeEmptyElement(String prefix, String localName, String namespaceURI)
           
 void writeEndDocument()
           
 void writeEndElement()
           
 void writeEntityRef(String name)
           
 void writeNamespace(String prefix, String namespaceURI)
           
 void writeProcessingInstruction(String target)
           
 void writeProcessingInstruction(String target, String data)
           
 void writeStartDocument()
           
 void writeStartDocument(String version)
           
 void writeStartDocument(String encoding, String version)
           
 void writeStartElement(String localName)
           
 void writeStartElement(String namespaceURI, String localName)
           
 void writeStartElement(String prefix, String localName, String namespaceURI)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamWriterToReceiver

public StreamWriterToReceiver(Receiver receiver)
Constructor. Creates a StreamWriter as a front-end to a given Receiver.

Parameters:
receiver - the Receiver that is to receive the events generated by this StreamWriter.
Method Detail

setInventPrefixes

public void setInventPrefixes(boolean invent)
Say whether prefixes are to be invented when none is specified by the user

Parameters:
invent - true if prefixes are to be invented. Default is true;

isInventPrefixes

public boolean isInventPrefixes()
Ask whether prefixes are to be invented when none is specified by the user

Returns:
true if prefixes are to be invented. Default is true;

setCheckValues

public void setCheckValues(boolean check)
Say whether names and values are to be checked for conformance with XML rules

Parameters:
check - true if names and values are to be checked. Default is true;

isCheckValues

public boolean isCheckValues()
Ask whether names and values are to be checked for conformance with XML rules

Returns:
true if names and values are to be checked. Default is true;

writeStartElement

public void writeStartElement(String localName)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartElement

public void writeStartElement(String namespaceURI,
                              String localName)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartElement

public void writeStartElement(String prefix,
                              String localName,
                              String namespaceURI)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String namespaceURI,
                              String localName)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String prefix,
                              String localName,
                              String namespaceURI)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String localName)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEndElement

public void writeEndElement()
                     throws XMLStreamException
Specified by:
writeEndElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEndDocument

public void writeEndDocument()
                      throws XMLStreamException
Specified by:
writeEndDocument in interface XMLStreamWriter
Throws:
XMLStreamException

close

public void close()
           throws XMLStreamException
Specified by:
close in interface XMLStreamWriter
Throws:
XMLStreamException

flush

public void flush()
           throws XMLStreamException
Specified by:
flush in interface XMLStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String prefix,
                           String namespaceURI,
                           String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String namespaceURI,
                           String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Throws:
XMLStreamException

writeNamespace

public void writeNamespace(String prefix,
                           String namespaceURI)
                    throws XMLStreamException
Specified by:
writeNamespace in interface XMLStreamWriter
Throws:
XMLStreamException

writeDefaultNamespace

public void writeDefaultNamespace(String namespaceURI)
                           throws XMLStreamException
Specified by:
writeDefaultNamespace in interface XMLStreamWriter
Throws:
XMLStreamException

writeComment

public void writeComment(String data)
                  throws XMLStreamException
Specified by:
writeComment in interface XMLStreamWriter
Throws:
XMLStreamException

writeProcessingInstruction

public void writeProcessingInstruction(String target)
                                throws XMLStreamException
Specified by:
writeProcessingInstruction in interface XMLStreamWriter
Throws:
XMLStreamException

writeProcessingInstruction

public void writeProcessingInstruction(String target,
                                       String data)
                                throws XMLStreamException
Specified by:
writeProcessingInstruction in interface XMLStreamWriter
Throws:
XMLStreamException

writeCData

public void writeCData(String data)
                throws XMLStreamException
Specified by:
writeCData in interface XMLStreamWriter
Throws:
XMLStreamException

writeDTD

public void writeDTD(String dtd)
              throws XMLStreamException
Specified by:
writeDTD in interface XMLStreamWriter
Throws:
XMLStreamException

writeEntityRef

public void writeEntityRef(String name)
                    throws XMLStreamException
Specified by:
writeEntityRef in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartDocument

public void writeStartDocument()
                        throws XMLStreamException
Specified by:
writeStartDocument in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartDocument

public void writeStartDocument(String version)
                        throws XMLStreamException
Specified by:
writeStartDocument in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartDocument

public void writeStartDocument(String encoding,
                               String version)
                        throws XMLStreamException
Specified by:
writeStartDocument in interface XMLStreamWriter
Throws:
XMLStreamException

writeCharacters

public void writeCharacters(String text)
                     throws XMLStreamException
Specified by:
writeCharacters in interface XMLStreamWriter
Throws:
XMLStreamException

writeCharacters

public void writeCharacters(char[] text,
                            int start,
                            int len)
                     throws XMLStreamException
Specified by:
writeCharacters in interface XMLStreamWriter
Throws:
XMLStreamException

getPrefix

public String getPrefix(String uri)
                 throws XMLStreamException
Specified by:
getPrefix in interface XMLStreamWriter
Throws:
XMLStreamException

setPrefix

public void setPrefix(String prefix,
                      String uri)
               throws XMLStreamException
Specified by:
setPrefix in interface XMLStreamWriter
Throws:
XMLStreamException

setDefaultNamespace

public void setDefaultNamespace(String uri)
                         throws XMLStreamException
Specified by:
setDefaultNamespace in interface XMLStreamWriter
Throws:
XMLStreamException

setNamespaceContext

public void setNamespaceContext(NamespaceContext context)
                         throws XMLStreamException
Specified by:
setNamespaceContext in interface XMLStreamWriter
Throws:
XMLStreamException

getNamespaceContext

public NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface XMLStreamWriter

getProperty

public Object getProperty(String name)
                   throws IllegalArgumentException
Specified by:
getProperty in interface XMLStreamWriter
Throws:
IllegalArgumentException


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.