Class StAXWriter

    • Field Detail

      • m_writer

        private javax.xml.stream.XMLStreamWriter m_writer
        Target for parse event stream.
    • Constructor Detail

      • StAXWriter

        public StAXWriter​(java.lang.String[] uris)
        Constructor.
        Parameters:
        uris - ordered array of URIs for namespaces used in document (must be constant; the value in position 0 must always be the empty string "", and the value in position 1 must always be the XML namespace "http://www.w3.org/XML/1998/namespace")
      • StAXWriter

        public StAXWriter​(java.lang.String[] uris,
                          javax.xml.stream.XMLStreamWriter wrtr)
        Constructor with writer supplied.
        Parameters:
        uris - ordered array of URIs for namespaces used in document (must be constant; the value in position 0 must always be the empty string "", and the value in position 1 must always be the XML namespace "http://www.w3.org/XML/1998/namespace")
        wrtr - StAX writer for parse event output
      • StAXWriter

        public StAXWriter​(StAXWriter base,
                          java.lang.String[] uris)
        Copy constructor. This initializes the writer and extension namespace information from an existing instance.
        Parameters:
        base - existing instance
        uris - ordered array of URIs for namespaces used in document
    • Method Detail

      • init

        public void init()
        Initialize writer.
        Specified by:
        init in interface IXMLWriter
      • setWriter

        public void setWriter​(javax.xml.stream.XMLStreamWriter wrtr)
        Set StAX writer.
        Parameters:
        wrtr - StAX writer for parse event output
      • defineNamespace

        protected void defineNamespace​(int index,
                                       java.lang.String prefix)
                                throws java.io.IOException
        Description copied from class: XMLWriterNamespaceBase
        Report to subclass that namespace has been defined.
        Specified by:
        defineNamespace in class XMLWriterNamespaceBase
        Parameters:
        index - post-translation namespace URI index number
        prefix - prefix used for namespace
        Throws:
        java.io.IOException - if error writing to document
      • undefineNamespace

        protected void undefineNamespace​(int index)
        Description copied from class: XMLWriterNamespaceBase
        Report to subclass that namespace has been undefined.
        Specified by:
        undefineNamespace in class XMLWriterNamespaceBase
        Parameters:
        index - post-translation namespace URI index number
      • setIndentSpaces

        public void setIndentSpaces​(int count,
                                    java.lang.String newline,
                                    char indent)
        Description copied from interface: IXMLWriter
        Set nesting indentation. This is advisory only, and implementations of this interface are free to ignore it. The intent is to indicate that the generated output should use indenting to illustrate element nesting.
        Specified by:
        setIndentSpaces in interface IXMLWriter
        Parameters:
        count - number of character to indent per level, or disable indentation if negative (zero means new line only)
        newline - sequence of characters used for a line ending (null means use the single character '\n')
        indent - whitespace character used for indentation
      • writeXMLDecl

        public void writeXMLDecl​(java.lang.String version,
                                 java.lang.String encoding,
                                 java.lang.String standalone)
                          throws java.io.IOException
        Description copied from interface: IXMLWriter
        Write XML declaration to document. This can only be called before any other methods in the interface are called.
        Specified by:
        writeXMLDecl in interface IXMLWriter
        Parameters:
        version - XML version text
        encoding - text for encoding attribute (unspecified if null)
        standalone - text for standalone attribute (unspecified if null)
        Throws:
        java.io.IOException - on error writing to document
      • startTagOpen

        public void startTagOpen​(int index,
                                 java.lang.String name)
                          throws java.io.IOException
        Description copied from interface: IXMLWriter
        Generate open start tag. This allows attributes and/or namespace declarations to be added to the start tag, but must be followed by a IXMLWriter.closeStartTag() call.
        Specified by:
        startTagOpen in interface IXMLWriter
        Parameters:
        index - namespace URI index number
        name - unqualified element name
        Throws:
        java.io.IOException - on error writing to document
      • startTagNamespaces

        public void startTagNamespaces​(int index,
                                       java.lang.String name,
                                       int[] nums,
                                       java.lang.String[] prefs)
                                throws java.io.IOException
        Description copied from interface: IXMLWriter
        Generate start tag for element with namespaces. This creates the actual start tag, along with any necessary namespace declarations. Previously active namespace declarations are not duplicated. The tag is left incomplete, allowing other attributes to be added.
        Specified by:
        startTagNamespaces in interface IXMLWriter
        Parameters:
        index - namespace URI index number
        name - element name
        nums - array of namespace indexes defined by this element (must be constant, reference is kept until end of element)
        prefs - array of namespace prefixes mapped by this element (no null values, use "" for default namespace declaration)
        Throws:
        java.io.IOException - on error writing to document
      • addAttribute

        public void addAttribute​(int index,
                                 java.lang.String name,
                                 java.lang.String value)
                          throws java.io.IOException
        Description copied from interface: IXMLWriter
        Add attribute to current open start tag. This is only valid after a call to IXMLWriter.startTagOpen(int, java.lang.String) and before the corresponding call to IXMLWriter.closeStartTag().
        Specified by:
        addAttribute in interface IXMLWriter
        Parameters:
        index - namespace URI index number
        name - unqualified attribute name
        value - text value for attribute
        Throws:
        java.io.IOException - on error writing to document
      • startTagClosed

        public void startTagClosed​(int index,
                                   java.lang.String name)
                            throws java.io.IOException
        Description copied from interface: IXMLWriter
        Generate closed start tag. No attributes or namespaces can be added to a start tag written using this call.
        Specified by:
        startTagClosed in interface IXMLWriter
        Parameters:
        index - namespace URI index number
        name - unqualified element name
        Throws:
        java.io.IOException - on error writing to document
      • endTag

        public void endTag​(int index,
                           java.lang.String name)
                    throws java.io.IOException
        Description copied from interface: IXMLWriter
        Generate end tag.
        Specified by:
        endTag in interface IXMLWriter
        Parameters:
        index - namespace URI index number
        name - unqualified element name
        Throws:
        java.io.IOException - on error writing to document
      • writeTextContent

        public void writeTextContent​(java.lang.String text)
                              throws java.io.IOException
        Description copied from interface: IXMLWriter
        Write ordinary character data text content to document.
        Specified by:
        writeTextContent in interface IXMLWriter
        Parameters:
        text - content value text (must not be null)
        Throws:
        java.io.IOException - on error writing to document
      • writeCData

        public void writeCData​(java.lang.String text)
                        throws java.io.IOException
        Description copied from interface: IXMLWriter
        Write CDATA text to document.
        Specified by:
        writeCData in interface IXMLWriter
        Parameters:
        text - content value text (must not be null)
        Throws:
        java.io.IOException - on error writing to document
      • writeComment

        public void writeComment​(java.lang.String text)
                          throws java.io.IOException
        Description copied from interface: IXMLWriter
        Write comment to document.
        Specified by:
        writeComment in interface IXMLWriter
        Parameters:
        text - comment text (must not be null)
        Throws:
        java.io.IOException - on error writing to document
      • writeEntityRef

        public void writeEntityRef​(java.lang.String name)
                            throws java.io.IOException
        Description copied from interface: IXMLWriter
        Write entity reference to document.
        Specified by:
        writeEntityRef in interface IXMLWriter
        Parameters:
        name - entity name (must not be null)
        Throws:
        java.io.IOException - on error writing to document
      • writeDocType

        public void writeDocType​(java.lang.String name,
                                 java.lang.String sys,
                                 java.lang.String pub,
                                 java.lang.String subset)
                          throws java.io.IOException
        Description copied from interface: IXMLWriter
        Write DOCTYPE declaration to document.
        Specified by:
        writeDocType in interface IXMLWriter
        Parameters:
        name - root element name
        sys - system ID (null if none, must be non-null for public ID to be used)
        pub - public ID (null if none)
        subset - internal subset (null if none)
        Throws:
        java.io.IOException - on error writing to document
      • writePI

        public void writePI​(java.lang.String target,
                            java.lang.String data)
                     throws java.io.IOException
        Description copied from interface: IXMLWriter
        Write processing instruction to document.
        Specified by:
        writePI in interface IXMLWriter
        Parameters:
        target - processing instruction target name (must not be null)
        data - processing instruction data (must not be null)
        Throws:
        java.io.IOException - on error writing to document
      • indent

        public void indent()
                    throws java.io.IOException
        Description copied from interface: IXMLWriter
        Request output indent. The writer implementation should normally indent output as appropriate. This method can be used to request indenting of output that might otherwise not be indented. The normal effect when used with a text-oriented writer should be to output the appropriate line end sequence followed by the appropriate number of indent characters for the current nesting level.
        Specified by:
        indent in interface IXMLWriter
        Throws:
        java.io.IOException - on error writing to document
      • flush

        public void flush()
                   throws java.io.IOException
        Description copied from interface: IXMLWriter
        Flush document output. Writes any buffered data to the output medium. This does not flush the output medium itself, only any internal buffering within the writer.
        Specified by:
        flush in interface IXMLWriter
        Throws:
        java.io.IOException - on error writing to document
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: IXMLWriter
        Close document output. Completes writing of document output, including flushing and closing the output medium.
        Specified by:
        close in interface IXMLWriter
        Throws:
        java.io.IOException - on error writing to document
      • createChildWriter

        public IXMLWriter createChildWriter​(java.lang.String[] uris)
        Create a child writer instance to be used for a separate binding. The child writer inherits the output handling from this writer, while using the supplied namespace URIs.
        Specified by:
        createChildWriter in interface IExtensibleWriter
        Parameters:
        uris - ordered array of URIs for namespaces used in document (see StAXWriter(String[]))
        Returns:
        child writer