XPath From VOTable
Created: 2014-03-12 06:43:31
A XPath From text version for VOTables. This is useful to extract certain information from the header of the VOTables but it could work for any XPath.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
Descriptions (1)
A XPath From text version for VOTables. This is useful to extract certain information from the header of the VOTables but it could work for any XPath. |
Dependencies (0)
Inputs (3)
Name |
Description |
VOTable |
VOTable input (not the file path but the table itself)
|
Version |
VOTable version (1.1, 1.2, ...). Default value is "1.2"
|
XPath |
Normal XPath as if it would be used with normal XMLs
|
Processors (5)
Name |
Type |
Description |
XPath_From_VOTables_core |
localworker |
Where all the magic happens Scriptimport org.dom4j.*;
import org.dom4j.io.SAXReader;
import org.dom4j.xpath.*;
SAXReader reader = new SAXReader(false);
reader.setIncludeInternalDTDDeclarations(false);
reader.setIncludeExternalDTDDeclarations(false);
XPath xpathObj = new DefaultXPath(xpath);
HashMap map = new HashMap();
map.put(abbrevation,namespace);
xpathObj.setNamespaceURIs(map);
Document document = reader.read(new StringReader(xmltext));
List nodelist = xpathObj.selectNodes(document);
// Process the elements in the nodelist
ArrayList outputList = new ArrayList();
ArrayList outputXmlList = new ArrayList();
String val = null;
String xmlVal = null;
for (Iterator iter = nodelist.iterator(); iter.hasNext();) {
Node element = (Node) iter.next();
xmlVal = element.asXML();
val = element.getStringValue();
if (val != null && !val.equals("")) {
outputList.add(val);
outputXmlList.add(xmlVal);
}
}
List nodelist=outputList;
List nodelistAsXML=outputXmlList; |
abbrevation_value |
stringconstant |
Valueh |
namespace |
stringconstant |
Valuehttp://www.ivoa.net/xml/VOTable/ |
namespace_version |
beanshell |
Script to join the namespace and the version input. Unless version 1.1 specified it will output the VOTable namespace for version 1.2 Scriptif (version != "1.1") {
version = "1.2";
}
namespace = namespace_url + "v" + version; |
XPath_modifier |
beanshell |
Simple regex to change the XPath in such way so it works for XPathFromVOTables core. Scriptxpath_out = "/"+xpath_in.replaceAll("/(?=\\w)","/h:");
//"(?i)(? |
Beanshells (2)
Name |
Description |
Inputs |
Outputs |
namespace_version |
Script to join the namespace and the version input. Unless version 1.1 specified it will output the VOTable namespace for version 1.2 |
namespace_url
version
|
namespace
|
XPath_modifier |
Simple regex to change the XPath in such way so it works for XPathFromVOTables core. |
xpath_in
|
xpath_out
|
Outputs (2)
Name |
Description |
nodelist |
List of all the elements searched
|
nodelistAsXML |
List with all the elements searched but with their nodes.
|
Datalinks (9)
Source |
Sink |
abbrevation_value:value |
XPath_From_VOTables_core:abbrevation |
namespace_version:namespace |
XPath_From_VOTables_core:namespace |
XPath_modifier:xpath_out |
XPath_From_VOTables_core:xpath |
VOTable |
XPath_From_VOTables_core:xmltext |
namespace:value |
namespace_version:namespace_url |
Version |
namespace_version:version |
XPath |
XPath_modifier:xpath_in |
XPath_From_VOTables_core:nodelist |
nodelist |
XPath_From_VOTables_core:nodelistAsXML |
nodelistAsXML |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (2)
(People/Groups)
Attributions (1)
(Workflows/Files)
Shared with Groups (2)
Featured In Packs (0)
None
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