1 5 6 package com.hp.hpl.jena.rdf.arp.test; 7 8 import java.io.IOException ; 9 import java.io.InputStream ; 10 11 import javax.xml.parsers.*; 12 import javax.xml.transform.Source ; 13 import javax.xml.transform.dom.DOMSource ; 14 15 16 import org.w3c.dom.Document ; 17 import org.xml.sax.SAXException ; 18 import org.xml.sax.SAXParseException ; 19 20 import com.hp.hpl.jena.rdf.arp.MalformedURIException; 21 import com.hp.hpl.jena.rdf.arp.DOM2Model; 22 import com.hp.hpl.jena.rdf.model.Model; 23 import com.hp.hpl.jena.shared.*; 24 25 29 class DOM2RDFTest extends SAX2RDFTest { 30 31 36 public DOM2RDFTest(String dir, String base0, String file) { 37 super(dir, base0, file); 38 } 39 40 static private DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 41 static { factory.setNamespaceAware(true);} 43 static private DocumentBuilder domParser; 44 45 static { 46 try { 47 domParser = factory.newDocumentBuilder(); 48 } 49 catch (ParserConfigurationException rte){ 50 throw new JenaException(rte); 51 } 52 } 53 54 55 void loadXMLModel(Model m2, InputStream in, RDFEHArray eh2) throws MalformedURIException, SAXException , IOException { 56 57 Document document = domParser 58 .parse(in,base); 59 60 Source input = new DOMSource (document); 62 DOM2Model d2m = new DOM2Model(base,m2); 63 64 d2m.setErrorHandler(eh2); 65 66 try { 67 try { 68 d2m.load(document); 69 } finally { 70 d2m.close(); 71 } 72 } catch (SAXParseException e) { 73 } 75 76 77 } 78 79 } 80 81 82 108 109 | Popular Tags |