本文整理了Java中org.apache.jena.rdf.model.Model.getNsPrefixURI()
方法的一些代码示例,展示了Model.getNsPrefixURI()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.getNsPrefixURI()
方法的具体详情如下:
包路径:org.apache.jena.rdf.model.Model
类名称:Model
方法名:getNsPrefixURI
暂无
代码示例来源:origin: apache/jena
private static boolean usesPrefix(Model model, String prefix)
{
return model.getNsPrefixURI(prefix) != null ;
}
代码示例来源:origin: org.apache.jena/jena-core
private static boolean usesPrefix(Model model, String prefix)
{
return model.getNsPrefixURI(prefix) != null ;
}
代码示例来源:origin: TopQuadrant/shacl
private static void perhapsAppend(StringBuffer queryString, String prefix, String namespace, Model model) {
if(model.getNsPrefixURI(prefix) == null && namespace != null) {
queryString.append("PREFIX ");
queryString.append(prefix);
queryString.append(": <");
queryString.append(namespace);
queryString.append(">\n");
}
}
代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl
private static void perhapsAppend(StringBuffer queryString, String prefix, String namespace, Model model) {
if(model.getNsPrefixURI(prefix) == null && namespace != null) {
queryString.append("PREFIX ");
queryString.append(prefix);
queryString.append(": <");
queryString.append(namespace);
queryString.append(">\n");
}
}
代码示例来源:origin: apache/jena
private void addPrefixes(Model model)
{
if ( model.getNsPrefixURI("rs") == null )
model.setNsPrefix("rs", ResultSetGraphVocab.getURI() ) ;
if ( model.getNsPrefixURI("rdf") == null )
model.setNsPrefix("rdf", RDF.getURI() ) ;
if ( model.getNsPrefixURI("xsd") == null )
model.setNsPrefix("xsd", XSDDatatype.XSD+"#") ;
}
代码示例来源:origin: apache/jena
/** Document has set an empty prefix for the model */
protected String getDefaultPrefixNamespace() {
// alternatively, the default namespace may be set in the prefix mapping read from the input document
String defaultNS = m_source.getNsPrefixURI( "" );
if (defaultNS == null) {
defaultNS = m_source.getBaseModel().getNsPrefixURI( "" );
}
return defaultNS;
}
代码示例来源:origin: at.researchstudio.sat/won-core
/**
* Creates an RDF model containing a text message.
* @param message
* @return
*/
public static Model textMessage(String message) {
Model messageModel = createModelWithBaseResource();
Resource baseRes = messageModel.createResource(messageModel.getNsPrefixURI(""));
baseRes.addProperty(WON.HAS_TEXT_MESSAGE,message, XSDDatatype.XSDstring);
return messageModel;
}
代码示例来源:origin: apache/jena
@Override
public String getNsPrefixURI(final String prefix) throws ReadDeniedException, AuthenticationRequiredException {
checkRead();
return holder.getBaseItem().getNsPrefixURI(prefix);
}
代码示例来源:origin: org.apache.jena/jena-cmds
/** Document has set an empty prefix for the model */
protected String getDefaultPrefixNamespace() {
// alternatively, the default namespace may be set in the prefix mapping read from the input document
String defaultNS = m_source.getNsPrefixURI( "" );
if (defaultNS == null) {
defaultNS = m_source.getBaseModel().getNsPrefixURI( "" );
}
return defaultNS;
}
代码示例来源:origin: apache/jena
private static void checkNamespaces(Model m, Map<String, String> namespaces) {
if (namespaces == null) return;
for (String prefix : namespaces.keySet()) {
if ( ! prefix.isEmpty() )
Assert.assertEquals("Model does contain expected namespace " + prefix + ": <" + namespaces.get(prefix) + ">", namespaces.get(prefix), m.getNsPrefixURI(prefix));
}
}
}
代码示例来源:origin: at.researchstudio.sat/won-core
private static Model createModelWithBaseResource() {
Model model = ModelFactory.createDefaultModel();
model.setNsPrefix("", "no:uri");
model.createResource(model.getNsPrefixURI(""));
return model;
}
代码示例来源:origin: apache/jena
/** Encode the result set as RDF.
* @return Model Model contains the results
*/
public Model asModel(ResultSet resultSet)
{
Model m = GraphFactory.makeJenaDefaultModel() ;
asRDF(m, resultSet) ;
if ( m.getNsPrefixURI("rs") == null )
m.setNsPrefix("rs", ResultSetGraphVocab.getURI() ) ;
if ( m.getNsPrefixURI("rdf") == null )
m.setNsPrefix("rdf", RDF.getURI() ) ;
return m ;
}
代码示例来源:origin: tarql/tarql
public void exec(Model model) throws IOException {
for (Query q: tq.getQueries()) {
modifyQuery(q, table);
QueryExecution ex = createQueryExecution(q, model);
ex.execConstruct(model);
}
if (tarql.NS.equals(model.getNsPrefixURI("tarql"))) {
model.removeNsPrefix("tarql");
}
}
代码示例来源:origin: apache/jena
private void testWineNS(Model m) throws FileNotFoundException, IOException {
try (InputStream in = new FileInputStream("testing/arp/xmlns/wine.rdf")) {
m.read(in, "") ;
assertEquals("http://www.w3.org/TR/2003/CR-owl-guide-20030818/wine#", m.getNsPrefixURI("")) ;
}
}
代码示例来源:origin: org.apache.jena/jena-core
private void testWineNS(Model m) throws FileNotFoundException, IOException {
try (InputStream in = new FileInputStream("testing/arp/xmlns/wine.rdf")) {
m.read(in, "") ;
assertEquals("http://www.w3.org/TR/2003/CR-owl-guide-20030818/wine#", m.getNsPrefixURI("")) ;
}
}
代码示例来源:origin: apache/jena
@Test public void updatePrefixMapping1()
{
Model model = ModelFactory.createDefaultModel() ;
StringReader reader = new StringReader("@prefix x: <http://example/x>.") ;
RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE) ;
assertEquals(1, model.getNsPrefixMap().size()) ;
assertEquals("http://example/x", model.getNsPrefixURI("x")) ;
}
代码示例来源:origin: apache/jena
@Test public void optionalDotInPrefix()
{
Model model = ModelFactory.createDefaultModel() ;
StringReader reader = new StringReader("@prefix x: <http://example/x>") ;
RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE) ;
assertEquals(1, model.getNsPrefixMap().size()) ;
assertEquals("http://example/x", model.getNsPrefixURI("x")) ;
}
代码示例来源:origin: apache/jena
@Test public void updatePrefixMapping2()
{
// Test that prefixes are resolved
Model model = ModelFactory.createDefaultModel() ;
StringReader reader = new StringReader("BASE <http://example/> PREFIX x: <abc>") ;
RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE) ;
assertEquals(1, model.getNsPrefixMap().size()) ;
assertEquals("http://example/abc", model.getNsPrefixURI("x")) ;
}
代码示例来源:origin: apache/jena
public void testContentLoadsPrefixMappings()
{
Assembler a = new ContentAssembler();
String content =
"@prefix foo: <eh:/foo#>. <eh:/eggs> rdf:type rdf:Property."
.replaceAll( " ", "\\\\s" );
Resource root = resourceInModel( "x rdf:type ja:Content; x rdf:type ja:LiteralContent; x ja:literalContent '" + content + "'" );
Content c = (Content) a.open( root );
Model m = ModelFactory.createDefaultModel();
c.fill( m );
assertEquals( "eh:/foo#", m.getNsPrefixURI( "foo" ) );
}
代码示例来源:origin: org.apache.jena/jena-core
public void testContentLoadsPrefixMappings()
{
Assembler a = new ContentAssembler();
String content =
"@prefix foo: <eh:/foo#>. <eh:/eggs> rdf:type rdf:Property."
.replaceAll( " ", "\\\\s" );
Resource root = resourceInModel( "x rdf:type ja:Content; x rdf:type ja:LiteralContent; x ja:literalContent '" + content + "'" );
Content c = (Content) a.open( root );
Model m = ModelFactory.createDefaultModel();
c.fill( m );
assertEquals( "eh:/foo#", m.getNsPrefixURI( "foo" ) );
}
内容来源于网络,如有侵权,请联系作者删除!