1 package net.sf.saxon.jdom; 2 3 import net.sf.saxon.Query; 4 import net.sf.saxon.trans.DynamicError; 5 import net.sf.saxon.trans.XPathException; 6 import org.jdom.JDOMException; 7 import org.jdom.input.SAXBuilder; 8 9 import javax.xml.transform.sax.SAXSource ; 10 import java.io.IOException ; 11 import java.util.ArrayList ; 12 import java.util.List ; 13 14 19 20 public class JDOMQuery extends Query { 21 22 public List preprocess(List sources) throws XPathException { 23 try { 24 ArrayList jdomSources = new ArrayList (sources.size()); 25 for (int i=0; i<sources.size(); i++) { 26 SAXSource ss = (SAXSource )sources.get(i); 27 SAXBuilder builder = new SAXBuilder(); 28 org.jdom.Document doc = builder.build(ss.getInputSource()); 29 DocumentWrapper jdom = new DocumentWrapper(doc, ss.getSystemId(), getConfiguration()); 30 jdomSources.add(jdom); 31 } 32 return jdomSources; 33 } catch (JDOMException e) { 34 throw new DynamicError(e); 35 } catch (IOException e) { 36 throw new DynamicError(e); 37 } 38 } 39 40 public static void main(String [] args) { 41 new JDOMQuery().doMain(args, "JDOMQuery"); 42 } 43 } 44 45 | Popular Tags |