public class XMLInstances extends XMLDocument implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static String |
ATT_CLASS
the class attribute
|
static String |
ATT_FORMAT
the format attribute (for date attributes)
|
static String |
ATT_INDEX
the index attribute
|
static String |
ATT_MISSING
the missing attribute
|
static String |
ATT_TYPE
the type attribute
|
static String |
ATT_VERSION
the version attribute
|
static String |
ATT_WEIGHT
the weight attribute
|
static String |
DOCTYPE
the DTD
|
static String |
FILE_EXTENSION
The filename extension that should be used for xrff files
|
protected Instances |
m_Instances
the underlying Instances
|
protected int |
m_Precision
the precision for numbers
|
static String |
TAG_ATTRIBUTE
the attribute element
|
static String |
TAG_ATTRIBUTES
the attributes element
|
static String |
TAG_BODY
the body element
|
static String |
TAG_DATASET
the root element
|
static String |
TAG_HEADER
the header element
|
static String |
TAG_INSTANCE
the instance element
|
static String |
TAG_INSTANCES
the data element
|
static String |
TAG_LABEL
the label element
|
static String |
TAG_LABELS
the labels element
|
static String |
TAG_METADATA
the meta-data element
|
static String |
TAG_NOTES
the notes element
|
static String |
TAG_PROPERTY
the property element
|
static String |
TAG_VALUE
the value element
|
static String |
VAL_DATE
the value for date
|
static String |
VAL_NOMINAL
the value for nominal
|
static String |
VAL_NORMAL
the value for normal
|
static String |
VAL_NUMERIC
the value for numeric
|
static String |
VAL_RELATIONAL
the value for relational
|
static String |
VAL_SPARSE
the value for sparse
|
static String |
VAL_STRING
the value for string
|
ATT_NAME, DTD_ANY, DTD_AT_LEAST_ONE, DTD_ATTLIST, DTD_CDATA, DTD_DOCTYPE, DTD_ELEMENT, DTD_IMPLIED, DTD_OPTIONAL, DTD_PCDATA, DTD_REQUIRED, DTD_SEPARATOR, DTD_ZERO_OR_MORE, m_Builder, m_DocType, m_Document, m_Factory, m_RootNode, m_Validating, m_XPath, PI, VAL_NO, VAL_YES| Constructor and Description |
|---|
XMLInstances()
the default constructor
|
XMLInstances(Instances data)
generates the XML structure based on the given data
|
XMLInstances(Reader reader)
generates the Instances directly from the reader containing the
XML data.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAttribute(Element parent,
Attribute att)
adds the attribute to the XML structure
|
protected void |
addInstance(Element parent,
Instance inst)
adds the instance to the XML structure
|
protected Attribute |
createAttribute(Element node)
creates an Attribute from the given XML node
|
protected FastVector |
createAttributes(Element parent,
int[] classIndex)
returns a list of generated attributes
|
protected Instance |
createInstance(Instances header,
Element parent)
creates an Instance from the given XML node
|
protected Instances |
createInstances(Instances header,
Element parent)
creates Instances from the given XML node
|
protected FastVector |
createLabels(Element parent)
returns the labels listed underneath this (nominal) attribute in a
FastVector
|
protected ProtectedProperties |
createMetadata(Element parent)
returns the metadata, if any available underneath this node, otherwise
just null
|
protected Instances |
dataFromXML(Instances header)
generates the complete dataset from the XML document
|
protected void |
dataToXML()
generates the XML structure from the rows
|
Instances |
getInstances()
returns the current instances, either the ones that were set or the ones
that were generated from the XML structure.
|
String |
getRevision()
Returns the revision string.
|
protected Instances |
headerFromXML()
generates the header from the XML document
|
protected void |
headerToXML()
generates the XML structure for the header
|
static void |
main(String[] args)
takes an XML document as first argument and then outputs the Instances
statistics
|
void |
setInstances(Instances data)
builds up the XML structure based on the given data
|
void |
setXML(Reader reader)
reads the XML structure from the given reader
|
protected String |
validContent(String content)
turns all <, > and &into character entities and returns that
string.
|
clear, eval, evalBoolean, evalDouble, evalString, findNodes, getBuilder, getChildTags, getChildTags, getContent, getDocType, getDocument, getFactory, getNode, getRootNode, getValidating, newDocument, print, read, read, read, read, setDocType, setDocument, setRootNode, setValidating, toString, toString, write, write, write, writepublic static String FILE_EXTENSION
public static final String TAG_DATASET
public static final String TAG_HEADER
public static final String TAG_BODY
public static final String TAG_NOTES
public static final String TAG_ATTRIBUTES
public static final String TAG_ATTRIBUTE
public static final String TAG_LABELS
public static final String TAG_LABEL
public static final String TAG_METADATA
public static final String TAG_PROPERTY
public static final String TAG_INSTANCES
public static final String TAG_INSTANCE
public static final String TAG_VALUE
public static final String ATT_VERSION
public static final String ATT_TYPE
public static final String ATT_FORMAT
public static final String ATT_CLASS
public static final String ATT_INDEX
public static final String ATT_WEIGHT
public static final String ATT_MISSING
public static final String VAL_NUMERIC
public static final String VAL_DATE
public static final String VAL_NOMINAL
public static final String VAL_STRING
public static final String VAL_RELATIONAL
public static final String VAL_NORMAL
public static final String VAL_SPARSE
public static final String DOCTYPE
protected int m_Precision
protected Instances m_Instances
public XMLInstances()
throws Exception
Exception - if XML initialization failspublic XMLInstances(Instances data) throws Exception
data - the data to build the XML structure fromException - if initialization/generation failsprotected void addAttribute(Element parent, Attribute att)
parent - the parent node to add the attribute node as childatt - the attribute to addprotected String validContent(String content)
content - string to convertprotected void addInstance(Element parent, Instance inst)
parent - the parent node to add the instance node as childinst - the instance to addprotected void headerToXML()
protected void dataToXML()
public void setInstances(Instances data)
data - data to generate the XML frompublic Instances getInstances()
protected ProtectedProperties createMetadata(Element parent) throws Exception
parent - the attribute nodeException - if generation failsprotected FastVector createLabels(Element parent) throws Exception
parent - the (nominal) attribute nodeException - if generation failsprotected Attribute createAttribute(Element node) throws Exception
node - the node with the setupException - if generation fails, e.g., due to unknown attribute typeprotected FastVector createAttributes(Element parent, int[] classIndex) throws Exception
parent - the attributes nodeclassIndex - array of length 1 to return the class index, if anyException - if generation fails, e.g., due to unknown attribute typeprotected Instance createInstance(Instances header, Element parent) throws Exception
header - the data this instance will belong toparent - the instance nodeException - if generation fails, e.g., due to unknown attribute typeprotected Instances createInstances(Instances header, Element parent) throws Exception
header - the header of this dataparent - the instances nodeException - if generation fails, e.g., due to unknown attribute typeprotected Instances headerFromXML() throws Exception
Exception - if generation failsprotected Instances dataFromXML(Instances header) throws Exception
header - the header structureException - if generation failspublic void setXML(Reader reader) throws Exception
reader - the reader to get the XML fromException - ifpublic String getRevision()
getRevision in interface RevisionHandlergetRevision in class XMLDocumentpublic static void main(String[] args)
args - the commandline optionsCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.