com.esri.arcgis.system
Class XMLWriter

java.lang.Object
  extended by com.esri.arcgis.system.XMLWriter
All Implemented Interfaces:
com.esri.arcgis.interop.RemoteObjRef, ISupportErrorInfo, IXMLWriter, Serializable

public class XMLWriter
extends Object
implements com.esri.arcgis.interop.RemoteObjRef, IXMLWriter, ISupportErrorInfo

An XML sequential document writer.

Remarks

Use the XMLWriter coclass when you wish to provide access to members that control the sequential writing of XML. XMLStream needs to be hooked-up in order to write to the stream.


'*** Create XmlStream and XmlWriter ***
Dim pStream As IXMLStream
Set pStream = New XMLStream

Dim pWriter As IXMLWriter
Set pWriter = New XMLWriter

pWriter.WriteTo pStream

'*** Create XmlSerializer ***
Dim pSerializer As IXMLSerializer
Set pSerializer = New XMLSerializer

pSerializer.WriteObject pWriter, Nothing, Nothing, "", "", pPoint

See the IXMLReader interface for more on getting information about writing of objects.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

See Also:
IXMLStream, IXMLWriter, IXMLReader, IXMLSerialize, Serialized Form

Constructor Summary
XMLWriter()
          Constructs a XMLWriter using ArcGIS Engine.
XMLWriter(Object obj)
          Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
XMLWriter theXMLWriter = (XMLWriter) obj;
 
Method Summary
 boolean equals(Object o)
          Compare this object with another
static String getClsid()
          getClsid.
 int hashCode()
          the hashcode for this object
 void interfaceSupportsErrorInfo(GUID riid)
          interfaceSupportsErrorInfo
 String lookupNamespace(String uri)
          Returns the declared namespace prefix for a namespace.
 void writeBinary(byte[] value)
          Writes an element value as a binary array.
 void writeBoolean(boolean value)
          Writes an element value as a boolean.
 void writeByte(byte value)
          Writes an element value as a byte.
 void writeCData(String cdata)
          Writes a CDATA section.
 void writeDate(Date value)
          Writes an element value as a date.
 void writeDouble(double value)
          Writes an element value as a double.
 void writeEndTag()
          Writes the ending tag of an element.
 void writeFloat(float value)
          Writes an element value as a float.
 void writeInteger(int value)
          Writes an element value as a long.
 void writeNewLine()
          Writes a newline.
 void writeShort(short value)
          Writes an element value as a short.
 void writeStartTag(String localName, String uri, IXMLAttributes attributes, IXMLNamespaces namespaces, boolean isEmpty)
          Writes the starting tag of an element.
 void writeTab()
          Writes a tab.
 void writeText(String text)
          Writes the text value of an element.
 void writeTo(IStream outputStream)
          Specifies output XML stream.
 void writeVariant(Object value)
          Writes an element value as a variant.
 void writeXML(String xML)
          Writes raw XML.
 void writeXMLDeclaration()
          Writes the XML document declaration.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef
getJintegraDispatch, release
 

Constructor Detail

XMLWriter

public XMLWriter()
          throws IOException,
                 UnknownHostException
Constructs a XMLWriter using ArcGIS Engine.

Throws:
IOException - if there are interop problems
UnknownHostException - if there are interop problems

XMLWriter

public XMLWriter(Object obj)
          throws IOException
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
XMLWriter theXMLWriter = (XMLWriter) obj;

Construct a XMLWriter using a reference to such an object returned from ArcGIS Engine or Server. This is semantically equivalent to casting obj to XMLWriter.

Parameters:
obj - an object returned from ArcGIS Engine or Server
Throws:
IOException - if there are interop problems
Method Detail

getClsid

public static String getClsid()
getClsid.


equals

public boolean equals(Object o)
Compare this object with another

Overrides:
equals in class Object

hashCode

public int hashCode()
the hashcode for this object

Overrides:
hashCode in class Object

writeTo

public void writeTo(IStream outputStream)
             throws IOException,
                    AutomationException
Specifies output XML stream.

Remarks


The WriteTo method specifies the output XML stream. XMLStream lets you write/read (in our case write) xml data to stream object.

For Example:

Dim pWriter As IXMLWriter
Set pWriter = New XMLWriter

Dim pXMLStream as IXMLStream
Set pXMLStream = new XMLStream

'*** This sets output to XML Stream ***
pWriter.WriteTo pStream

'*** Write some xml to the stream ***
pWriter.WriteXMLDeclaration

'*** Save stream to the file ***
pXMLStream.SaveToFile App.Path & "\new.xml"

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeTo in interface IXMLWriter
Parameters:
outputStream - A reference to a com.esri.arcgis.system.IStream (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeStartTag

public void writeStartTag(String localName,
                          String uri,
                          IXMLAttributes attributes,
                          IXMLNamespaces namespaces,
                          boolean isEmpty)
                   throws IOException,
                          AutomationException
Writes the starting tag of an element.

Remarks


The WriteStartTag method specifies the starting tag of an element.
For example:

<Length>

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeStartTag in interface IXMLWriter
Parameters:
localName - The localName (in)
uri - The uri (in)
attributes - A reference to a com.esri.arcgis.system.IXMLAttributes (in)
namespaces - A reference to a com.esri.arcgis.system.IXMLNamespaces (in)
isEmpty - The isEmpty (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeText

public void writeText(String text)
               throws IOException,
                      AutomationException
Writes the text value of an element.

Remarks

The WriteText method writes the text value of an element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeText in interface IXMLWriter
Parameters:
text - The text (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeCData

public void writeCData(String cdata)
                throws IOException,
                       AutomationException
Writes a CDATA section.

Remarks


All text inside XML document is parsed by the XML parser. Only the text inside the CDATA section is ignored by the parser. If your text has lots of "<", ">", "&", "'", and "" (like program code), it could be hidden in CDATA section.

For example,

<test>
<![CDATA[
if a > b & b > c, then a > c
]]>
</test>

In the example above, everything inside CDATA section was ignored by the parser. It would show <test>if a > b & b > c, then a > c</test> in any web browser.

Example of creating such CDATA section using IXMLWriter:

Dim pXMLStream as IXMLStream
Set pXMLStream = new XMLStream

Dim pXMLWriter as IXMLWriter
Set pXMLWriter = new XMLWriter

pXMLWriter.WriteTo pXMLStream

pXMLWriter.WriteCData "if a > b & b > c, then a > c"

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeCData in interface IXMLWriter
Parameters:
cdata - The cdata (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeEndTag

public void writeEndTag()
                 throws IOException,
                        AutomationException
Writes the ending tag of an element.

Description


The WriteEndTag method specifies the end tag of an element.
For example:

</Length>

If the WriteStartTag method was called with the parameter "IsEmpty" set to True, the WriteEndTag method will not be executed, and the Error will be raised. The WriteStartTag method needs to specify that the Start Tag is not going to be Empty in order to call the WriteEndTag method.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeEndTag in interface IXMLWriter
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeBoolean

public void writeBoolean(boolean value)
                  throws IOException,
                         AutomationException
Writes an element value as a boolean.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeBoolean in interface IXMLWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeByte

public void writeByte(byte value)
               throws IOException,
                      AutomationException
Writes an element value as a byte.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeByte in interface IXMLWriter
Parameters:
value - An unsigned byte (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeShort

public void writeShort(short value)
                throws IOException,
                       AutomationException
Writes an element value as a short.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeShort in interface IXMLWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeInteger

public void writeInteger(int value)
                  throws IOException,
                         AutomationException
Writes an element value as a long.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeInteger in interface IXMLWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeFloat

public void writeFloat(float value)
                throws IOException,
                       AutomationException
Writes an element value as a float.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeFloat in interface IXMLWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeDouble

public void writeDouble(double value)
                 throws IOException,
                        AutomationException
Writes an element value as a double.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeDouble in interface IXMLWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeDate

public void writeDate(Date value)
               throws IOException,
                      AutomationException
Writes an element value as a date.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeDate in interface IXMLWriter
Parameters:
value - The value (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeBinary

public void writeBinary(byte[] value)
                 throws IOException,
                        AutomationException
Writes an element value as a binary array.

Remarks

The WriteBinary method writes an element value as a binary array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeBinary in interface IXMLWriter
Parameters:
value - An unsigned byte (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeVariant

public void writeVariant(Object value)
                  throws IOException,
                         AutomationException
Writes an element value as a variant.

Remarks

The WriteVariant method writes an element value as a variant.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeVariant in interface IXMLWriter
Parameters:
value - A Variant (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeXML

public void writeXML(String xML)
              throws IOException,
                     AutomationException
Writes raw XML.

Remarks

The RawXML method writes XML code to Stream object. The XML code should be well-formed and valid, otherwise the XMLReader will raise error if the Stream is going to be read afterwards.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeXML in interface IXMLWriter
Parameters:
xML - The xML (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeXMLDeclaration

public void writeXMLDeclaration()
                         throws IOException,
                                AutomationException
Writes the XML document declaration.

Remarks


The WriteXMLDeclaration writes

<?xml version="1.0" encoding="utf-8" ?>

to Stream object. XML Declaration should always be included, as it defines the XML version and the encoding of the document.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeXMLDeclaration in interface IXMLWriter
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeNewLine

public void writeNewLine()
                  throws IOException,
                         AutomationException
Writes a newline.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeNewLine in interface IXMLWriter
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

writeTab

public void writeTab()
              throws IOException,
                     AutomationException
Writes a tab.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
writeTab in interface IXMLWriter
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

lookupNamespace

public String lookupNamespace(String uri)
                       throws IOException,
                              AutomationException
Returns the declared namespace prefix for a namespace.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
lookupNamespace in interface IXMLWriter
Parameters:
uri - The uri (in)
Returns:
The prefix
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

interfaceSupportsErrorInfo

public void interfaceSupportsErrorInfo(GUID riid)
                                throws IOException,
                                       AutomationException
interfaceSupportsErrorInfo

Description

Indicates whether the interface supports IErrorInfo.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
interfaceSupportsErrorInfo in interface ISupportErrorInfo
Parameters:
riid - A Structure: com.esri.arcgis.support.ms.stdole.GUID (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.