proper.xml
Class XMLInstances

java.lang.Object
  extended by proper.xml.XMLInstances

public class XMLInstances
extends java.lang.Object

This class reads XML files representing Instances and writes Instances to XML.

Version:
$Revision: 1.2 $
Author:
FracPete

Field Summary
static java.lang.String DATE_FORMAT
          the initial format for dates
static java.lang.String DOCTYPE
          the DTD for the output
static java.lang.String PI
          the PI for the output
static java.lang.String TAG_ATTRIBUTE
           
static java.lang.String TAG_ATTRIBUTES
           
static java.lang.String TAG_INSTANCE
           
static java.lang.String TAG_INSTANCES
           
static java.lang.String TAG_RELATION
           
static java.lang.String TAG_VALUE
           
static java.lang.String TYPE_DATE
           
static java.lang.String TYPE_NOMINAL
           
static java.lang.String TYPE_NUMERIC
           
static java.lang.String TYPE_STRING
           
 
Constructor Summary
XMLInstances()
          initializes the object
XMLInstances(weka.core.Instances instances)
          initializes the object with the given instances
 
Method Summary
 java.lang.String getDateFormat()
          returns the date format used in the DATE attributes
 java.lang.String getDoctype()
          returns the DTD used in the XML file
 weka.core.Instances getInstances()
          returns the current instances object (either read or set)
 java.lang.String getPI()
          returns the processing instructions to use in the file
static void main(java.lang.String[] args)
          for testing only (first arg type [xml/arff], second arg filename)
 weka.core.Instances process(Document doc)
          transforms an XML document into an instances object
 Document process(weka.core.Instances instances)
          transforms instances into a XML document
 boolean read(java.lang.String filename)
          reads the instances from the given XML file, returns TRUE if successful
 void setDateFormat(java.lang.String dateFormat)
          sets the date format to use in the attributes
 void setDoctype(java.lang.String doctype)
          sets the DTD to use in XML file
 void setInstances(weka.core.Instances instances)
          sets the instances object to use
 void setPI(java.lang.String pi)
          sets the processing instructions to use in the file
static int stringToType(java.lang.String typeStr)
          returns the WEKA Attribute type of the given string, default is STRING
static java.lang.String typeToString(int type)
          returns a string representation of the given WEKA Attribute type, default is TYPE_STRING
 boolean write(java.lang.String filename)
          writes the current instances to the given filename, returns TRUE if successful
static boolean write(java.lang.String filename, weka.core.Instances instances)
          writes the given instances to the given file, in XML format, returns TRUE if successful
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_DATE

public static final java.lang.String TYPE_DATE
See Also:
Constant Field Values

TYPE_NOMINAL

public static final java.lang.String TYPE_NOMINAL
See Also:
Constant Field Values

TYPE_NUMERIC

public static final java.lang.String TYPE_NUMERIC
See Also:
Constant Field Values

TYPE_STRING

public static final java.lang.String TYPE_STRING
See Also:
Constant Field Values

DOCTYPE

public static final java.lang.String DOCTYPE
the DTD for the output

See Also:
Constant Field Values

PI

public static final java.lang.String PI
the PI for the output

See Also:
Constant Field Values

DATE_FORMAT

public static final java.lang.String DATE_FORMAT
the initial format for dates

See Also:
Constant Field Values

TAG_RELATION

public static final java.lang.String TAG_RELATION
See Also:
Constant Field Values

TAG_ATTRIBUTES

public static final java.lang.String TAG_ATTRIBUTES
See Also:
Constant Field Values

TAG_ATTRIBUTE

public static final java.lang.String TAG_ATTRIBUTE
See Also:
Constant Field Values

TAG_INSTANCES

public static final java.lang.String TAG_INSTANCES
See Also:
Constant Field Values

TAG_INSTANCE

public static final java.lang.String TAG_INSTANCE
See Also:
Constant Field Values

TAG_VALUE

public static final java.lang.String TAG_VALUE
See Also:
Constant Field Values
Constructor Detail

XMLInstances

public XMLInstances()
initializes the object


XMLInstances

public XMLInstances(weka.core.Instances instances)
initializes the object with the given instances

Method Detail

setInstances

public void setInstances(weka.core.Instances instances)
sets the instances object to use


getInstances

public weka.core.Instances getInstances()
returns the current instances object (either read or set)


setDoctype

public void setDoctype(java.lang.String doctype)
sets the DTD to use in XML file

See Also:
DOCTYPE

getDoctype

public java.lang.String getDoctype()
returns the DTD used in the XML file

See Also:
DOCTYPE

setPI

public void setPI(java.lang.String pi)
sets the processing instructions to use in the file

See Also:
PI

getPI

public java.lang.String getPI()
returns the processing instructions to use in the file

See Also:
PI

setDateFormat

public void setDateFormat(java.lang.String dateFormat)
sets the date format to use in the attributes

See Also:
DATE_FORMAT

getDateFormat

public java.lang.String getDateFormat()
returns the date format used in the DATE attributes

See Also:
DATE_FORMAT

stringToType

public static int stringToType(java.lang.String typeStr)
returns the WEKA Attribute type of the given string, default is STRING

See Also:
Attribute.STRING

typeToString

public static java.lang.String typeToString(int type)
returns a string representation of the given WEKA Attribute type, default is TYPE_STRING

See Also:
TYPE_STRING

process

public Document process(weka.core.Instances instances)
transforms instances into a XML document


process

public weka.core.Instances process(Document doc)
transforms an XML document into an instances object


write

public boolean write(java.lang.String filename)
writes the current instances to the given filename, returns TRUE if successful


write

public static boolean write(java.lang.String filename,
                            weka.core.Instances instances)
writes the given instances to the given file, in XML format, returns TRUE if successful


read

public boolean read(java.lang.String filename)
reads the instances from the given XML file, returns TRUE if successful


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
for testing only (first arg type [xml/arff], second arg filename)

Throws:
java.lang.Exception