当前位置: 首页>>代码示例>>Java>>正文


Java RDFXMLWriter类代码示例

本文整理汇总了Java中org.openrdf.rio.rdfxml.RDFXMLWriter的典型用法代码示例。如果您正苦于以下问题:Java RDFXMLWriter类的具体用法?Java RDFXMLWriter怎么用?Java RDFXMLWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RDFXMLWriter类属于org.openrdf.rio.rdfxml包,在下文中一共展示了RDFXMLWriter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
@Override
public void parse(InputStream stream, ContentHandler handler,
		Metadata metadata, ParseContext context) throws IOException,
		SAXException, TikaException {

	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	turtleParser.setRDFHandler(new RDFXMLWriter(outputStream));
	
	try {
		turtleParser.parse(stream, metadata.get(Metadata.RESOURCE_NAME_KEY));
	} catch (Exception e) {
		throw new SAXException(e.getMessage());
	}

	ByteArrayInputStream os = new ByteArrayInputStream(outputStream.toByteArray());
	try {
		context.getSAXParser().parse(
               new CloseShieldInputStream(os),
               new OfflineContentHandler(handler));
	} finally {
		os.close();
	}
}
 
开发者ID:erfgoed-en-locatie,项目名称:artsholland-platform,代码行数:24,代码来源:TurtleParser.java

示例2: dump

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
public void dump(Writer writer) {
    try {
        if (contextResource.length == 0) {
            RepositoryResult<org.openrdf.model.Resource> results = conn.getContextIDs();
            while (results.hasNext()) {
                org.openrdf.model.Resource context = results.next();
                writer.append("Dumping context:" + context + "\n");
                conn.export(new RDFXMLWriter(writer), context);
            }
            dumpTriplesNotInContext(writer);
        } else {
            for (int i = 0; i < contextResource.length; i++) {
                writer.append("Dumping context:" + contextResource[i].stringValue() + "\n");
                conn.export(new RDFXMLWriter(writer), contextResource);
            }
        }
    } catch (Exception e) {
        throw new ShineRuntimeException(e);
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:21,代码来源:SesameGraph.java

示例3: getAvaiableWriters

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
public static Set<String> getAvaiableWriters(){
    N3Writer n = null;
    NTriplesWriter nt = null;
    RDFXMLPrettyWriter x2 = null;
    RDFXMLWriter x = null;
    TriGWriter tr = null;
    TriXWriter tw = null;
    TurtleWriter t = null;
    HashSet<String> results = new HashSet<String>();
    StringWriter writer = new StringWriter();
    for (RDFFormat rdfFormat:RDFFormat.values()){
        RDFWriter rdfWriter = getWriterIfPossible(rdfFormat, writer); 
        if (rdfWriter != null){
            results.add(rdfFormat.getName());
        }
    }
    return results;
}
 
开发者ID:bridgedb,项目名称:BridgeDb,代码行数:19,代码来源:BridgeDbRdfTools.java

示例4: testExporter

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
@Test
public void testExporter() throws IOException {
	Map<String, Class<?>> handlers = new HashMap<>();
	handlers.put( "filename.ttl", TurtleWriter.class );
	handlers.put( "filename.rdf", RDFXMLWriter.class );
	handlers.put( "filename.x", NTriplesWriter.class );

	for ( Map.Entry<String, Class<?>> en : handlers.entrySet() ) {
		RDFHandler handler;
		try ( StringWriter sw = new StringWriter() ) {
			handler = Utility.getExporterFor( en.getKey(), sw );
		}
		assertEquals( en.getValue(), handler.getClass() );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:16,代码来源:UtilityTest.java

示例5: testExportStatements

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
@Test
public void testExportStatements()
        throws Exception {
    Resource context1 = conn.getValueFactory().createURI("http://marklogic.com/test/context1");
    ValueFactory f= conn.getValueFactory();
    final URI alice = f.createURI("http://example.org/people/alice");
    URI name = f.createURI("http://example.org/ontology/name");
    Literal alicesName = f.createLiteral("Alice");

    Statement st1 = f.createStatement(alice, name, alicesName);
    conn.add(st1, context1);

    ByteArrayOutputStream out = new ByteArrayOutputStream();

    RDFXMLWriter rdfWriter = new RDFXMLWriter(out);

    String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<rdf:RDF\n" +
            "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
            "\n" +
            "<rdf:Description rdf:about=\"http://example.org/people/alice\">\n" +
            "\t<name xmlns=\"http://example.org/ontology/\" rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">Alice</name>\n" +
            "</rdf:Description>\n" +
            "\n" +
            "</rdf:RDF>";

    conn.exportStatements(alice, null, alicesName, true, rdfWriter, context1);
    Assert.assertEquals(expected, out.toString());
    conn.clear(context1);
}
 
开发者ID:marklogic,项目名称:marklogic-sesame,代码行数:31,代码来源:MarkLogicRepositoryConnectionTest.java

示例6: testExportStatementsAllNull

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
@Test
public void testExportStatementsAllNull()
        throws Exception {
    Resource context1 = conn.getValueFactory().createURI("http://marklogic.com/test/context1");
    ValueFactory f= conn.getValueFactory();
    final URI alice = f.createURI("http://example.org/people/alice");
    URI name = f.createURI("http://example.org/ontology/name");
    Literal alicesName = f.createLiteral("Alice");

    Statement st1 = f.createStatement(alice, name, alicesName);
    conn.add(st1, context1);

    ByteArrayOutputStream out = new ByteArrayOutputStream();

    RDFXMLWriter rdfWriter = new RDFXMLWriter(out);

    String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<rdf:RDF\n" +
            "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
            "\n" +
            "<rdf:Description rdf:about=\"http://example.org/people/alice\">\n" +
            "\t<name xmlns=\"http://example.org/ontology/\" rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">Alice</name>\n" +
            "</rdf:Description>\n" +
            "\n" +
            "</rdf:RDF>";

    conn.exportStatements(null, null, null, false, rdfWriter, context1);
    Assert.assertEquals(expected, out.toString());
    conn.clear(context1);
}
 
开发者ID:marklogic,项目名称:marklogic-sesame,代码行数:31,代码来源:MarkLogicRepositoryConnectionTest.java

示例7: toOutputStream

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
public void toOutputStream(OutputStream output)
		throws OpenRDFException, TransformerException, IOException {
	if (query.isGraphQuery()) {
		QueryResultUtil.report(asGraphQueryResult(), new RDFXMLWriter(
				output));
	} else if (query.isTupleQuery()) {
		QueryResultUtil.report(asTupleQueryResult(),
				new SPARQLResultsXMLWriter(output));
	} else if (query.isBooleanQuery()) {
		new SPARQLBooleanXMLWriter(output).write(asBoolean());
	} else {
		throw new AssertionError("Unknown query type");
	}
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:15,代码来源:SparqlEvaluator.java

示例8: toWriter

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
public void toWriter(Writer writer) throws OpenRDFException,
		TransformerException, IOException {
	if (query.isGraphQuery()) {
		QueryResultUtil.report(asGraphQueryResult(), new RDFXMLWriter(
				writer));
	} else if (query.isTupleQuery()) {
		QueryResultUtil.report(asTupleQueryResult(),
				new SPARQLResultsXMLWriter(new XMLWriter(writer)));
	} else if (query.isBooleanQuery()) {
		new SPARQLBooleanXMLWriter(new XMLWriter(writer))
				.write(asBoolean());
	} else {
		throw new AssertionError("Unknown query type");
	}
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:16,代码来源:SparqlEvaluator.java

示例9: executeConstructQuery

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
private void executeConstructQuery(GraphQuery prepareQuery, String format,
		OutputStream output) throws LodeException {
	try {
		if (GraphQueryFormats.RDFXML.toString().equals(format)) {
			prepareQuery.evaluate(new RDFXMLWriter(output));
		} else if (GraphQueryFormats.TURTLE.toString().equals(format)) {
			prepareQuery.evaluate(new TurtleWriter(output));
		}
	} catch (QueryEvaluationException | RDFHandlerException e) {
		// TODO Auto-generated catch block
		throw new LodeException(e);

	}

}
 
开发者ID:JervenBolleman,项目名称:sparql-identifiers,代码行数:16,代码来源:SesameSparqlService.java

示例10: getExporterFor

import org.openrdf.rio.rdfxml.RDFXMLWriter; //导入依赖的package包/类
/**
 * Gets the appropriate exporter for the given filename. "Appropriate" means
 * the file's suffix determines exporter. If no appropriate handler can be
 * found, an NTriples one is returned. Handled suffixes (case insensitive):
 * <ul>
 * <li>nt
 * <li>rdf
 * <li>ttl
 * </ul>
 *
 * @param filename the filename to determine the handler to use
 * @param out the output writer to use to create the handler
 * @return a handler (always)
 */
public static RDFHandler getExporterFor( String filename, Writer out ) {
	String suffix = FilenameUtils.getExtension( filename ).toLowerCase();
	switch ( suffix ) {
		case "rdf":
			return new RDFXMLWriter( out );
		case "ttl":
			return new TurtleWriter( out );
		default:
			return new NTriplesWriter( out );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:26,代码来源:Utility.java


注:本文中的org.openrdf.rio.rdfxml.RDFXMLWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。