sem.bnode( [value as xs.anyAtomicType] ) as sem.blank
This function returns an identifier for a blank node, allowing the construction of a triple that refers to a blank node. This XQuery function backs up the SPARQL BNODE() function.
This function is a built-in.
Parameters | |
---|---|
value | If provided, the same blank node identifier is returned for the same argument value passed to the function. |
var sem = require("/MarkLogic/semantics.xqy"); var person1 = sem.bnode(); var person2 = sem.bnode(); var t1 = sem.triple(person1, sem.iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), sem.iri("http://xmlns.com/foaf/0.1/Person")); var t2 = sem.triple(person2, sem.iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), sem.iri("http://xmlns.com/foaf/0.1/Person")); var t3 = sem.triple(person1, sem.iri("http://xmlns.com/foaf/0.1/knows"), person2) var results = new Array(); results.push(t1, t2, t3); results; => // returns identifiers for blank nodes [{"triple": {"subject": {"value":"http://marklogic.com/semantics/blank/2404403597012311801"}, "predicate": {"value":"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "object": {"value":"http://xmlns.com/foaf/0.1/Person"} } }, {"triple": {"subject": {"value":"http://marklogic.com/semantics/blank/499971585800807003"}, "predicate": {"value":"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"}, "object": {"value":"http://xmlns.com/foaf/0.1/Person"}}}, {"triple":{ "subject": {"value":"http://marklogic.com/semantics/blank/2404403597012311801"}, "predicate": {"value":"http://xmlns.com/foaf/0.1/knows"}, "object": {"value":"http://marklogic.com/semantics/blank/499971585800807003"} } }]
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.