/** * Load built in prefixes. */ public static void init() { registerPrefix("rdf", RDF.getURI()); registerPrefix("rdfs", RDFS.getURI()); registerPrefix("drdfs", "urn:x-hp-direct-predicate:http_//www.w3.org/2000/01/rdf-schema#"); registerPrefix("owl", OWL.getURI()); registerPrefix("jr", ReasonerVocabulary.getJenaReasonerNS()); registerPrefix("rb", ReasonerVocabulary.getRBNamespace()); registerPrefix("eg", egNS); registerPrefix("xsd", XSDDatatype.XSD + "#"); }
public void testPrefixUse() { String NS = "http://jena.hpl.hp.com/example#"; String name = "r1"; String uri = NS + name; String shortform = "p:" + name; String longform = "<" + uri + ">"; Resource r = ResourceFactory.createResource(uri); assertEquals(longform, PrintUtil.print(r)); PrintUtil.registerPrefix("p", NS); assertEquals(shortform, PrintUtil.print(r)); PrintUtil.removePrefix("p"); assertEquals(longform, PrintUtil.print(r)); Map<String, String> map = new HashMap<>(); map.put("p", NS); PrintUtil.registerPrefixMap(map); assertEquals(shortform, PrintUtil.print(r)); PrintUtil.removePrefixMap( map ); assertEquals(longform, PrintUtil.print(r)); } }
/** * Load built in prefixes. */ public static void init() { registerPrefix("rdf", RDF.getURI()); registerPrefix("rdfs", RDFS.getURI()); registerPrefix("drdfs", "urn:x-hp-direct-predicate:http_//www.w3.org/2000/01/rdf-schema#"); registerPrefix("owl", OWL.getURI()); registerPrefix("jr", ReasonerVocabulary.getJenaReasonerNS()); registerPrefix("rb", ReasonerVocabulary.getRBNamespace()); registerPrefix("eg", egNS); registerPrefix("xsd", XSDDatatype.XSD + "#"); }
public void testPrefixUse() { String NS = "http://jena.hpl.hp.com/example#"; String name = "r1"; String uri = NS + name; String shortform = "p:" + name; String longform = "<" + uri + ">"; Resource r = ResourceFactory.createResource(uri); assertEquals(longform, PrintUtil.print(r)); PrintUtil.registerPrefix("p", NS); assertEquals(shortform, PrintUtil.print(r)); PrintUtil.removePrefix("p"); assertEquals(longform, PrintUtil.print(r)); Map<String, String> map = new HashMap<>(); map.put("p", NS); PrintUtil.registerPrefixMap(map); assertEquals(shortform, PrintUtil.print(r)); PrintUtil.removePrefixMap( map ); assertEquals(longform, PrintUtil.print(r)); } }
public static Dataset convert(Dataset metadata) { PrintUtil.registerPrefix("daq", DAQ.NS); PrintUtil.registerPrefix("dqv", "http://www.w3.org/ns/dqv#"); PrintUtil.registerPrefix("qb", "http://purl.org/linked-data/cube#");
/** * Internal helper: create an InfGraph with given rule set and base data. * The base data is encoded in kers-special RDF syntax. */ private InfGraph makeInfGraph(String rules, String data) { PrintUtil.registerPrefix("eh", "eh:/"); Graph base = graphWith( data ); List<Rule> ruleList = Rule.parseRules(rules); return new FBRuleReasoner(ruleList).bind( base ); }
/** * Internal helper: create an InfGraph with given rule set and base data. * The base data is encoded in kers-special RDF syntax. */ private InfGraph makeInfGraph(String rules, String data) { PrintUtil.registerPrefix("eh", "eh:/"); Graph base = graphWith( data ); List<Rule> ruleList = Rule.parseRules(rules); return new FBRuleReasoner(ruleList).bind( base ); }
}; PrintUtil.registerPrefix("foobar", "http://foobar#"); for (int i = 0; i < testRules.length; i++) { Rule r = Rule.parseRule(testRules[i]);
}; PrintUtil.registerPrefix("foobar", "http://foobar#"); for (int i = 0; i < testRules.length; i++) { Rule r = Rule.parseRule(testRules[i]);
/** * Test closure of grounded choice points */ public void testGroundClosure() { Flag myFlag = new Flag(); BuiltinRegistry.theRegistry.register(myFlag); String NS = "http://ont.com/"; PrintUtil.registerPrefix("ns", NS); String rules = "[r1: (ns:a ns:p ns:b) <- (ns:a ns:p ns:a)] " + "[r2: (ns:a ns:p ns:b) <- flag()] " + "[rt: (?a ns:q ?b) <- (?a ns:p ?b)] "; Model m = ModelFactory.createDefaultModel(); Resource a = m.createResource(NS + "a"); Resource b = m.createResource(NS + "b"); Property p = m.createProperty(NS + "p"); Property q = m.createProperty(NS + "q"); m.add(a, p, a); GenericRuleReasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules)); InfModel infModel = ModelFactory.createInfModel(reasoner, m); assertTrue( infModel.contains(a, q, b) ); assertTrue( ! myFlag.fired ); }
/** * Test closure of grounded choice points */ public void testGroundClosure() { Flag myFlag = new Flag(); BuiltinRegistry.theRegistry.register(myFlag); String NS = "http://ont.com/"; PrintUtil.registerPrefix("ns", NS); String rules = "[r1: (ns:a ns:p ns:b) <- (ns:a ns:p ns:a)] " + "[r2: (ns:a ns:p ns:b) <- flag()] " + "[rt: (?a ns:q ?b) <- (?a ns:p ?b)] "; Model m = ModelFactory.createDefaultModel(); Resource a = m.createResource(NS + "a"); Resource b = m.createResource(NS + "b"); Property p = m.createProperty(NS + "p"); Property q = m.createProperty(NS + "q"); m.add(a, p, a); GenericRuleReasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules)); InfModel infModel = ModelFactory.createInfModel(reasoner, m); assertTrue( infModel.contains(a, q, b) ); assertTrue( ! myFlag.fired ); }