在XQuery中,如何防止字符串输出内容转化为实体?
In XQuery, How to keep the string output content from translate to entity?
我从 XML 中获取一些数据并将其转换为 Turtle/N3。
我想在开头添加 @prefix 和命名空间 URL。
原来的 XML 是这样的:
<xxx>
<country
name="XX"
population="NN">
...
</country>
...
</xxx>
我编写了 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()
输出为:
<?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.
..
...
输出将原来的“<”和“>”翻译成“<”和“>”。
如何保持这些字符串不变?
我想要这样的输出:
@prefix rdf: <http://www.w3.org/1999/02/22‐rdf‐syntax‐ns#> .
@prefix : <http://lyle.smu.edu/cse7347/> .
:Albania:population :3249136.
...
我该怎么办?
输出被序列化为 XML。要序列化为文本添加
declare namespace output = "w3.org/2010/xslt-xquery-serialization";
declare output:method "text";
我从 XML 中获取一些数据并将其转换为 Turtle/N3。 我想在开头添加 @prefix 和命名空间 URL。 原来的 XML 是这样的:
<xxx>
<country
name="XX"
population="NN">
...
</country>
...
</xxx>
我编写了 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()
输出为:
<?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.
..
...
输出将原来的“<”和“>”翻译成“<”和“>”。 如何保持这些字符串不变? 我想要这样的输出:
@prefix rdf: <http://www.w3.org/1999/02/22‐rdf‐syntax‐ns#> .
@prefix : <http://lyle.smu.edu/cse7347/> .
:Albania:population :3249136.
...
我该怎么办?
输出被序列化为 XML。要序列化为文本添加
declare namespace output = "w3.org/2010/xslt-xquery-serialization";
declare output:method "text";