I grab some data from XML and translate it to Turtle/N3. I want to add @prefix and namespace URLs at the beginning. The original XML is something like:
<xxx>
<country
name="XX"
population="NN">
...
</country>
...
</xxx>
I write the XQuery:
declare function local:genPopulation()as xs:string* {
let $countries:=doc("mondial-3.0.xml")//country
for $elt in $countries
let $population := $elt/@population[1]
let $countryName := $elt/@name
return (concat(":",$countryName,":population :",$population,".
"))
};
"
","@prefix rdf: <http://www.w3.org/1999/02/22‐rdf‐syntax‐ns#> .","
",
"@prefix : <http://lyle.smu.edu/cse7347/> .","
",
local:genPopulation()
The output is:
<?xml version="1.0" encoding="UTF-8"?>
@prefix rdf: <http://www.w3.org/1999/02/22‐rdf‐syntax‐ns#> .
@prefix : <http://lyle.smu.edu/cse7347/> .
:Albania:population :3249136.
:Andorra:population :72766.
..
...
The output translate the original "<" and ">" to "<" and ">". How to keep these string unchanged? I want the output like:
@prefix rdf: <http://www.w3.org/1999/02/22‐rdf‐syntax‐ns#> .
@prefix : <http://lyle.smu.edu/cse7347/> .
:Albania:population :3249136.
...