
function.event.xml.rq Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of corese-gui Show documentation
Show all versions of corese-gui Show documentation
Corese is a Semantic Web Factory (triple store and SPARQL endpoint)
implementing RDF, RDFS, SPARQL 1.1 Query and Update, Shacl. STTL. LDScript.
The newest version!
#
# Create RDF from XML on the fly
#
prefix ex:
@event
select * where {
?s ?p ?o
}
@init
function us:init(q) {
us:xml2rdf()
}
# parse XML document and create RDF triples
function us:xml2rdf() {
let (xml = xt:xml(us:xml())) {
for (book in xpath(xml, "/doc/book")) {
us:create(dom:getTextContent(xt:xpath(book, "title")),
dom:getTextContent(xt:xpath(book, "author")))
}
}
}
# create triples
function us:create(title, name) {
query (insert { ?uri foaf:name ?name . [ ex:author ?uri ; ex:title ?title] }
where {
bind (uri(concat(ex:, replace(name, " ", ""))) as ?uri)
values (?title ?name) {(undef undef)}
} )
}
# XML document
function us:xml() {
"""
1984 Georges Orwell
Le Capital au XXIe siècle Thomas Piketty
Capital et idéologie Thomas Piketty
"""
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy