我正在使用 Editix 运行一些 XML 查询,并且试图从标签中获取“角色”属性......
<actor id="5" role="Richie Cusack"/>
....并在我生成的标签之间插入值,就像这样....
<role>Richie Cusack</role>
...但是我正在运行的查询是将角色属性值插入回我围绕它的标签的属性中,例如...
<role role="Richie Cusack"/>
这是我的 XQuery 查询....
<results>
{
let $ms := doc("xmlPath.xml"),
for $m in $ms//movie
for $r in $m/actor/@role
return <result>
{$m/title}<role>{$r}</role>
</result>
}
</results>
...这是 XML 文件的结构...
<movies>
<movie>
<title>A History of Violence</title>
<year>2005</year>
<country>USA</country>
<genre>Crime</genre>
<summary>Tom Stall, a humble family man and owner of a
.</summary>
<director id="1"/>
<actor id="5" role="Richie Cusack"/>
</movie>
<movie>
<title>Heat</title>
<year>1995</year>
<country>USA</country>
<genre>Crime</genre>
<summary>Hunters and their prey--Neil and his professional
.... </summary>
<director id="6"/>
<actor id="7" role="Lt. Vincent Hanna"/>
</movies>
如何仅提取属性的值并将其嵌入标签之间,而不以属性的形式插入自身?