Mercurial > hg > duomoOWLProject
view src/de/mpiwg/dwinter/duomo/lexdump/LexDumpImporter.java @ 1:0fa29ab5e5e0
minor
| author | dwinter |
|---|---|
| date | Thu, 03 Feb 2011 14:05:52 +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 ""; } }
