Mercurial > hg > de.mpg.mpiwg.itgroup.digilib.plugin
view src/de/mpg/mpiwg/itgroup/indexMeta/Utils/ParseIndexMeta.java @ 1:83c58ea33792
first release (continued)
author | dwinter |
---|---|
date | Mon, 03 Jan 2011 09:11:25 +0100 |
parents | |
children | e63a64652f4d |
line wrap: on
line source
package de.mpg.mpiwg.itgroup.indexMeta.Utils; import java.io.File; import java.io.IOException; import java.io.InputStream; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.jdom.xpath.XPath; public class ParseIndexMeta { private Document dom; public ParseIndexMeta(IFile indexMetaFile) throws JDOMException, IOException, CoreException { SAXBuilder builder = new SAXBuilder(); InputStream is = indexMetaFile.getContents(); dom = builder.build(is); } public String getPath() throws JDOMException { // TODO Auto-generated method stub XPath xpath = XPath.newInstance("//archive-path"); Element el = (Element)xpath.selectSingleNode(dom); if (el==null) return null; return el.getTextTrim(); } public String getImagePath() throws JDOMException{ String path = getPath(); XPath xpath = XPath.newInstance("//texttool/image"); Element el = (Element)xpath.selectSingleNode(dom); if (el==null) return null; String imagePath =el.getTextTrim(); return(path+"/"+imagePath); } }