Search in sources :

Example 1 with NamespaceImpl

use of org.eclipse.rdf4j.model.impl.NamespaceImpl in project rdf4j by eclipse.

the class CustomTurtleParserTest method testParsingNamespacesWithOption.

@Test
public void testParsingNamespacesWithOption() throws Exception {
    ParserConfig aConfig = new ParserConfig();
    aConfig.set(BasicParserSettings.NAMESPACES, Collections.<Namespace>singleton(new NamespaceImpl("foo", SKOS.NAMESPACE)));
    Model model = Rio.parse(new StringReader("<urn:a> foo:broader <urn:b>."), "", RDFFormat.TURTLE, aConfig, vf, new ParseErrorLogger());
    assertEquals(1, model.size());
    assertTrue(model.contains(vf.createURI("urn:a"), SKOS.BROADER, vf.createURI("urn:b")));
}
Also used : ParseErrorLogger(org.eclipse.rdf4j.rio.helpers.ParseErrorLogger) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) StringReader(java.io.StringReader) ParserConfig(org.eclipse.rdf4j.rio.ParserConfig) NamespaceImpl(org.eclipse.rdf4j.model.impl.NamespaceImpl) Test(org.junit.Test)

Example 2 with NamespaceImpl

use of org.eclipse.rdf4j.model.impl.NamespaceImpl in project rdf4j by eclipse.

the class CustomTurtleParserTest method testParsingNamespacesWithOverride.

@Test
public void testParsingNamespacesWithOverride() throws Exception {
    ParserConfig aConfig = new ParserConfig();
    aConfig.set(BasicParserSettings.NAMESPACES, Collections.<Namespace>singleton(new NamespaceImpl("foo", SKOS.NAMESPACE)));
    Model model = Rio.parse(new StringReader("@prefix skos : <urn:not_skos:> ." + "<urn:a> skos:broader <urn:b>."), "", RDFFormat.TURTLE, aConfig, vf, new ParseErrorLogger());
    assertEquals(1, model.size());
    assertTrue(model.contains(vf.createIRI("urn:a"), vf.createIRI("urn:not_skos:broader"), vf.createIRI("urn:b")));
}
Also used : ParseErrorLogger(org.eclipse.rdf4j.rio.helpers.ParseErrorLogger) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) StringReader(java.io.StringReader) ParserConfig(org.eclipse.rdf4j.rio.ParserConfig) NamespaceImpl(org.eclipse.rdf4j.model.impl.NamespaceImpl) Test(org.junit.Test)

Aggregations

StringReader (java.io.StringReader)2 Model (org.eclipse.rdf4j.model.Model)2 LinkedHashModel (org.eclipse.rdf4j.model.impl.LinkedHashModel)2 NamespaceImpl (org.eclipse.rdf4j.model.impl.NamespaceImpl)2 ParserConfig (org.eclipse.rdf4j.rio.ParserConfig)2 ParseErrorLogger (org.eclipse.rdf4j.rio.helpers.ParseErrorLogger)2 Test (org.junit.Test)2