oracle.xml.parser.v2

## Class XMLPrintDriver

- java.lang.Object
- - oracle.xml.parser.v2.XMLPrintDriver

All Implemented Interfaces:
  PrintDriver

    public class XMLPrintDriver
    extends java.lang.Object
    implements PrintDriver

The `XMLPrintDriver` implements `PrintDriver` interface.

### Constructor Summary

Constructors
Constructor and Description
`XMLPrintDriver(java.io.OutputStream os)` Create a new PrintDriver to output XML to OutputStream
`XMLPrintDriver(java.io.PrintWriter pw)` Create a new PrintDriver to output XML to PrintWriter

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Closes the output stream or print writer.
`void` `close(int option)` Closes the output stream or print writer based on option Legal values are: XMLOutputStream.REUSE and XMLOutputStream.NO_REUSE.
`void` `flush()` Flushes the output stream or print writer
`void` `printAttribute(XMLAttr attr)` Prints a `XMLAttr` node
`void` `printAttributeNodes(XMLElement elem)` Calls print method for each attribute of the `XMLElement`
`void` `printCDATASection(XMLCDATA cdata)` Prints a `XMLCDATA` node
`void` `printChildNodes(XMLNode node)` Calls print method for each child of the `XMLNode`
`void` `printComment(XMLComment comment)` Prints a `XMLComment` node
`void` `printDoctype(DTD dtd)` Prints an `DTD`.
`void` `printDocument(XMLDocument doc)` Prints an `XMLDocument`.
`void` `printDocumentFragment(XMLDocumentFragment dfrag)` Prints an empty `XMLDocumentFragment` object.
`void` `printElement(XMLElement elem)` Prints an `XMLElement`.
`void` `printEntityReference(XMLEntityReference en)` Prints a `XMLEntityReference` node
`void` `printNode(XMLNode node)`
`void` `printProcessingInstruction(XMLPI pi)` Prints a `XMLPI` node
`void` `printTextNode(XMLText text)` Prints a `XMLText` node
`void` `setEncoding(java.lang.String enc)` Sets the encoding of the print driver.
`void` `setFormatPrettyPrint(boolean val)` Sets the pretty format print
`void` `setPrintInheritedNamespaces(boolean val)` Sets print inherited namespaces.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### XMLPrintDriver

    public XMLPrintDriver(java.io.PrintWriter pw)

Create a new PrintDriver to output XML to PrintWriter

Parameters:
  `pw` - - PrintWriter to use for output

#### XMLPrintDriver

    public XMLPrintDriver(java.io.OutputStream os)

Create a new PrintDriver to output XML to OutputStream

Parameters:
  `os` - - OutputStream to use for output

### Method Detail

#### setEncoding

    public void setEncoding(java.lang.String enc)
                     throws java.io.IOException

Sets the encoding of the print driver.

Specified by:
  `setEncoding` in interface `PrintDriver`
Parameters:
  `enc` - The encoding of the document being printed.
Throws:
  `java.io.IOException`

#### setFormatPrettyPrint

    public void setFormatPrettyPrint(boolean val)

Sets the pretty format print

Parameters:
  `val` - boolean value

#### setPrintInheritedNamespaces

    public void setPrintInheritedNamespaces(boolean val)

Sets print inherited namespaces. When printting an element this parameter constrols if all inherited namespaces will be printed or not.

Parameters:
  `val` - boolean - true to print all inherited namespaces, false to omit inherited namespace

#### printNode

    public void printNode(XMLNode node)
                   throws java.io.IOException

Throws:
  `java.io.IOException`

#### printDoctype

    public void printDoctype(DTD dtd)
                      throws java.io.IOException

Prints an `DTD`.

Specified by:
  `printDoctype` in interface `PrintDriver`
Parameters:
  `dtd` - The dtd to be printed.
Throws:
  `java.io.IOException`

#### printDocument

    public void printDocument(XMLDocument doc)
                       throws java.io.IOException

Prints an `XMLDocument`.

Specified by:
  `printDocument` in interface `PrintDriver`
Parameters:
  `doc` - The document to be printed.
Throws:
  `java.io.IOException`

#### printElement

    public void printElement(XMLElement elem)
                      throws java.io.IOException

Prints an `XMLElement`.

Specified by:
  `printElement` in interface `PrintDriver`
Parameters:
  `elem` - The element to be printed.
Throws:
  `java.io.IOException`

#### printDocumentFragment

    public void printDocumentFragment(XMLDocumentFragment dfrag)
                               throws java.io.IOException

Prints an empty `XMLDocumentFragment` object.

Specified by:
  `printDocumentFragment` in interface `PrintDriver`
Parameters:
  `dfrag` - The document fragment to be printed.
Throws:
  `java.io.IOException`

#### printTextNode

    public void printTextNode(XMLText text)
                       throws java.io.IOException

Prints a `XMLText` node

Specified by:
  `printTextNode` in interface `PrintDriver`
Parameters:
  `text` - The text node.
Throws:
  `java.io.IOException`

#### printComment

    public void printComment(XMLComment comment)
                      throws java.io.IOException

Prints a `XMLComment` node

Specified by:
  `printComment` in interface `PrintDriver`
Parameters:
  `comment` - The comment node.
Throws:
  `java.io.IOException`

#### printCDATASection

    public void printCDATASection(XMLCDATA cdata)
                           throws java.io.IOException

Prints a `XMLCDATA` node

Specified by:
  `printCDATASection` in interface `PrintDriver`
Parameters:
  `cdata` - The XMLCDATA node.
Throws:
  `java.io.IOException`

#### printProcessingInstruction

    public void printProcessingInstruction(XMLPI pi)
                                    throws java.io.IOException

Prints a `XMLPI` node

Specified by:
  `printProcessingInstruction` in interface `PrintDriver`
Parameters:
  `pi` - The XMLPI node.
Throws:
  `java.io.IOException`

#### printAttribute

    public void printAttribute(XMLAttr attr)
                        throws java.io.IOException

Prints a `XMLAttr` node

Specified by:
  `printAttribute` in interface `PrintDriver`
Parameters:
  `attr` - The XMLAttr node.
Throws:
  `java.io.IOException`

#### printEntityReference

    public void printEntityReference(XMLEntityReference en)
                              throws java.io.IOException

Prints a `XMLEntityReference` node

Specified by:
  `printEntityReference` in interface `PrintDriver`
Parameters:
  `en` - The XMLEntityReference node.
Throws:
  `java.io.IOException`

#### printChildNodes

    public final void printChildNodes(XMLNode node)
                               throws java.io.IOException

Calls print method for each child of the `XMLNode`

Specified by:
  `printChildNodes` in interface `PrintDriver`
Parameters:
  `node` - The node whose children are to be printed.
Throws:
  `java.io.IOException`

#### printAttributeNodes

    public final void printAttributeNodes(XMLElement elem)
                                   throws java.io.IOException

Calls print method for each attribute of the `XMLElement`

Specified by:
  `printAttributeNodes` in interface `PrintDriver`
Parameters:
  `elem` - The elem whose attributes are to be printed.
Throws:
  `java.io.IOException`

#### flush

    public void flush()
               throws java.io.IOException

Flushes the output stream or print writer

Specified by:
  `flush` in interface `PrintDriver`
Throws:
  `java.io.IOException`

#### close

    public void close()
               throws java.io.IOException

Closes the output stream or print writer. Migrate to close(int option).

Specified by:
  `close` in interface `PrintDriver`
Throws:
  `java.io.IOException`

#### close

    public void close(int option)
               throws java.io.IOException

Closes the output stream or print writer based on option Legal values are: XMLOutputStream.REUSE and XMLOutputStream.NO_REUSE.

Parameters:
  `option` - determines whether output stream or print writer has to be closed.
Throws:
  `java.io.IOException`

Copyright © 2003, 2018, Oracle and/or its affiliates. All rights reserved.