diva.util.xml
Class XmlWriter

java.lang.Object
  extended by diva.util.LoggableOp
      extended by diva.util.xml.XmlWriter

public class XmlWriter
extends LoggableOp

Given a tree of XmlElements, an object of this class generates the equivalent XML into an output stream.

Version:
$Id: XmlWriter.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Copyright (c) 1997, 1998 by Microstar Software Ltd.;, written by David Megginson <dmeggins@microstar.com>, Steve Neuendorffer, John Reekie

Field Summary
private  XmlParser _parser
           
private  java.lang.String _xmlVersion
           
 
Fields inherited from class diva.util.LoggableOp
_verbose
 
Constructor Summary
XmlWriter()
           
 
Method Summary
(package private)  java.lang.String makeAttributeType(java.lang.String elname, java.lang.String aname)
          Generate the attribute type as a normalised string.
(package private)  java.lang.String makeAttributeValue(java.lang.String elname, java.lang.String aname)
          Generate a full attribute default value.
(package private)  java.lang.String makeExternalIdentifiers(java.lang.String pubid, java.lang.String sysid)
          Construct a string equivalent of external identifiers.
(package private)  java.lang.String makeLiteral(java.lang.String data)
          Quote a literal, and escape any '"' or non-ASCII characters within it.
 void setXMLVersion(java.lang.String v)
          Set the XML version string.
 void write(XmlDocument document)
          Write the given XmlDocument to its URL.
 void write(XmlDocument document, java.io.Writer out)
          Write the given XmlDocument to a given Writer.
 void write(XmlElement e, java.io.Writer out, java.lang.String prefix)
          Deprecated. Use XmlElement.writeXML instead.
 void writeDTD(XmlDocument document, java.io.Writer out)
          Write the DTD of the given XmlDocument to a given Writer.
(package private)  void writeDTDAttributes(java.lang.String elname, java.io.Writer out)
          Dump attributes for an element.
 void writeDTDElements(java.io.Writer out)
          Produce normalised declarations for all elements.
 void writeDTDEntities(java.io.Writer out)
          Produce normalised declarations for all general entities.
 void writeDTDNotations(java.io.Writer out)
          Produce normalised declarations for all notations.
 
Methods inherited from class diva.util.LoggableOp
getErrorCount, getErrorStream, getLineNumber, getWarningCount, indent, isVerbose, logError, logError, logError, logInfo, logInfo, logWarning, logWarning, logWarning, reset, setErrorStream, setVerbose, unindent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_xmlVersion

private java.lang.String _xmlVersion

_parser

private XmlParser _parser
Constructor Detail

XmlWriter

public XmlWriter()
Method Detail

setXMLVersion

public void setXMLVersion(java.lang.String v)
Set the XML version string. The default is 1.0.


write

public void write(XmlDocument document)
           throws java.io.IOException
Write the given XmlDocument to its URL. If the file or URL of the document cannot be opened for writing, then an IOException will be thrown.

Throws:
java.io.IOException

write

public void write(XmlDocument document,
                  java.io.Writer out)
           throws java.io.IOException
Write the given XmlDocument to a given Writer. If an error occurs while writing, then an IOException will be thrown.

Throws:
java.io.IOException

write

public void write(XmlElement e,
                  java.io.Writer out,
                  java.lang.String prefix)
           throws java.io.IOException
Deprecated. Use XmlElement.writeXML instead.

Write a single XML element out to the given writer. Prefix each line with the given string. The writer is not flushed -- the caller must do this if necessary.

Throws:
java.io.IOException

writeDTD

public void writeDTD(XmlDocument document,
                     java.io.Writer out)
              throws java.io.IOException
Write the DTD of the given XmlDocument to a given Writer. If an error occurs while writing, then an IOException will be thrown.

Throws:
java.io.IOException

writeDTDNotations

public void writeDTDNotations(java.io.Writer out)
                       throws java.io.IOException
Produce normalised declarations for all notations.

Throws:
java.io.IOException

writeDTDEntities

public void writeDTDEntities(java.io.Writer out)
                      throws java.io.IOException
Produce normalised declarations for all general entities.

Throws:
java.io.IOException

writeDTDElements

public void writeDTDElements(java.io.Writer out)
                      throws java.io.IOException
Produce normalised declarations for all elements.

Throws:
java.io.IOException

writeDTDAttributes

void writeDTDAttributes(java.lang.String elname,
                        java.io.Writer out)
                  throws java.io.IOException
Dump attributes for an element.

Throws:
java.io.IOException
See Also:
makeAttributeType(String, String), makeAttributeValue(String, String)

makeAttributeType

java.lang.String makeAttributeType(java.lang.String elname,
                                   java.lang.String aname)
Generate the attribute type as a normalised string.


makeAttributeValue

java.lang.String makeAttributeValue(java.lang.String elname,
                                    java.lang.String aname)
Generate a full attribute default value.

See Also:
makeLiteral(java.lang.String)

makeExternalIdentifiers

java.lang.String makeExternalIdentifiers(java.lang.String pubid,
                                         java.lang.String sysid)
Construct a string equivalent of external identifiers.

See Also:
makeLiteral(java.lang.String)

makeLiteral

java.lang.String makeLiteral(java.lang.String data)
Quote a literal, and escape any '"' or non-ASCII characters within it.