convert_points_xml_to_csv
Created: 2014-11-05 14:02:28
Last updated: 2015-05-11 22:12:33
Converts points in openModeller XML format into CSV format (header: occurrenceID,nameComplete,decimalLongitude,decimalLatitude). Most input/output ports related with presence or absence points expect/return data in openModeller XML format. This component can be used to simply convert such data back to a more human friendly format.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
Converts points from XML to CSV. |
Descriptions (1)
Converts points in openModeller XML format into CSV (header: Id, Longitude, Latitude). |
Dependencies (0)
Inputs (2)
Name |
Description |
points_xml |
Points in XML format. Each point must contain the attributes: Id, X and Y.
|
species_label |
Species name to be included on each csv line.
|
Processors (1)
Name |
Type |
Description |
transform_xml |
beanshell |
Scriptimport org.dom4j.Document;
import org.dom4j.Node;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
if ((sourceString == void) || (sourceString == null)) {
throw new RuntimeException("sourceString must be specified");
}
SAXReader reader = new SAXReader(false);
reader.setIncludeInternalDTDDeclarations(false);
reader.setIncludeExternalDTDDeclarations(false);
Document document = reader.read(new StringReader(""+sourceString+""));
List nodelist = document.selectNodes("//*[local-name(.)=\"Point\"]");
// Process the elements in the nodelist
int num_points = 0;
String outputString = "occurrenceID,nameComplete,decimalLongitude,decimalLatitude\n";
String id = null;
String latitude = null;
String longitude = null;
for (Iterator iter = nodelist.iterator(); iter.hasNext();) {
Node node = (Node) iter.next();
Element element = (Element) node;
id = element.attributeValue("Id");
longitude = element.attributeValue("X");
latitude = element.attributeValue("Y");
outputString += id+","+species_label+","+longitude+","+latitude+"\n";
num_points += 1;
} |
Beanshells (1)
Name |
Description |
Inputs |
Outputs |
transform_xml |
|
sourceString
species_label
|
outputString
num_points
|
Outputs (2)
Name |
Description |
points_csv |
Comma-separated list of points including header: occurrenceID,nameComplete,decimalLongitude,decimalLatitude
|
num_points |
Number of points returned.
|
Datalinks (4)
Source |
Sink |
points_xml |
transform_xml:sourceString |
species_label |
transform_xml:species_label |
transform_xml:outputString |
points_csv |
transform_xml:num_points |
num_points |
Uploader
Component Validity
Loading
License
All versions of this Workflow are
licensed under:
Version 4 (latest)
(of 4)
Credits (1)
(People/Groups)
Attributions (0)
(Workflows/Files)
None
Shared with Groups (0)
None
Featured In Packs (1)
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment