Mercurial > hg > duomoOWLProject
view src/de/mpiwg/dwinter/duomo/lexdump/LexDumpImporter.java @ 5:923e73fa07f1
Minor changes, Suche nach Objekten nach readableId jetzt einschraenkbar, nicht auf subclassen ausweiten.
author | dwinter |
---|---|
date | Mon, 07 Feb 2011 16:51:38 +0100 |
parents | fb3f3df002df |
children | 919e9f3b5efd |
line wrap: on
line source
package de.mpiwg.dwinter.duomo.lexdump; import java.io.File; import java.io.IOException; import java.util.List; import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.jdom.xpath.XPath; public class LexDumpImporter { private Document doc; public LexDumpImporter(String path) throws JDOMException, IOException{ SAXBuilder builder = new SAXBuilder(); doc = builder.build(new File(path)); } @SuppressWarnings("unchecked") public List<Element> getCartas() throws JDOMException{ return (List<Element>)XPath.selectNodes(doc, "//carta"); } public List<Element> getSignatures() throws JDOMException { return (List<Element>)XPath.selectNodes(doc, "//segna"); } public String getValue(Object context, String path) throws JDOMException { Object node = XPath.selectSingleNode(context, path); if (node==null){ return ""; } else if (Element.class.isInstance(node)){ return ((Element)node).getTextTrim(); } else if (Attribute.class.isInstance(node)){ return ((Attribute)node).getValue(); } return ""; } }