RDFaParser implements RdfParser { @Override public void parse(final Callback cb) { StreamProcessor sp = new StreamProcessor(RdfaParser.connect(new QuadSink() { @Override public void addNonLiteral(String arg0, String arg1, String arg2) { cb.processStatement(new Node[] { createBnodeOrResource(arg0, _baseURIstring), new Resource(arg1), createBnodeOrResource(arg2, _baseURIstring), }); } @Override public void addPlainLiteral(String arg0, String arg1, String arg2, String arg3) { cb.processStatement(new Node[] { createBnodeOrResource(arg0, _baseURIstring), new Resource(arg1), new Literal(arg2, arg3) }); } @Override public void addTypedLiteral(String arg0, String arg1, String arg2, String arg3) { cb.processStatement(new Node[] { createBnodeOrResource(arg0, _baseURIstring), new Resource(arg1), new Literal(arg2, new Resource(arg3)) }); } @Override public void endStream() throws ParseException { cb.endDocument(); } @Override public void setBaseUri(String arg0) { return; } @Override public boolean setProperty(String arg0, Object arg1) { return false; } @Override public void startStream() throws ParseException { cb.startDocument(); } @Override public void addNonLiteral(String arg0, String arg1, String arg2, String arg3) { cb.processStatement(new Node[] { createBnodeOrResource(arg0, arg3), new Resource(arg1), createBnodeOrResource(arg2, arg3), new Resource(arg3) }); } @Override public void addPlainLiteral(String arg0, String arg1, String arg2, String arg3, String arg4) { cb.processStatement(new Node[] { createBnodeOrResource(arg0, arg4), new Resource(arg1), new Literal(arg2, arg3), new Resource(arg4) }); } @Override public void addTypedLiteral(String arg0, String arg1, String arg2, String arg3, String arg4) { cb.processStatement(new Node[] { createBnodeOrResource(arg0, arg4), new Resource(arg1), new Literal(arg2, new Resource(arg3)), new Resource(arg4) }); } })); XMLReader reader = null; try { SAXParserImpl parser = SAXParserImpl.newInstance(null); reader = parser.getXMLReader(); } catch (SAXException e) { if (_eh != null) { _eh.fatalError(e); return; } } sp.setProperty(StreamProcessor.XML_READER_PROPERTY, reader); try { switch (_inputDataContents) { case reader: sp.process((Reader) _inputData[0], _baseURIstring); break; case inputstream: sp.process((InputStream) _inputData[0], _baseURIstring); break; case inputstreamAndCharset: sp.process(new InputStreamReader((InputStream) _inputData[0], (Charset) _inputData[1]), _baseURIstring); break; } } catch (ParseException e) { if (_eh != null) { _eh.warning(e); } } } RDFaParser(InputStream is, URI baseURI);  RDFaParser(InputStream is, Charset cs, URI baseURI);  RDFaParser(Reader r, URI baseURI); @Override void parse(final Callback cb); @Override void setErrorHandler(ErrorHandler eh);  }
@Test public void test() throws SAXException, ParseException, IOException, URISyntaxException { String uri = "https: URL u = new URL(uri); URLConnection connection = u.openConnection(); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); connection.connect(); RDFaParser rp = new RDFaParser(connection.getInputStream(), u.toURI()); OutputStream os = System.out; os = new DevNull(); final PrintWriter pw = new PrintWriter(os); final AtomicInteger count = new AtomicInteger(0); rp.parse(new Callback() { @Override protected void startDocumentInternal() { System.err.println("opening document..."); } @Override protected void endDocumentInternal() { System.err.println("closing document..."); } @Override protected void processStatementInternal(Node[] nx) { pw.println(Nodes.toString(nx)); count.incrementAndGet(); } }); pw.close(); System.err.println("Quads processed: " + count); if (count.get() == 0) fail(); }