XQUERY return 结果格式 <!ELEMENT dynosaur ($dynosaurName) +>
XQUERY return result in format <!ELEMENT dynosaur ($dynosaurName) +>
我在 .xml
文件中使用 XQUERY FLWOR
表达式:
for $dynosaur in doc("document.xml")//species
let $dynosaurName := $dynosaur/text() // keeping the dynosaurName as a variable
return $dynosaur
以上 return 结果如下:
<species age="84">Velociraptor</species>
我需要格式化结果如下:
<!ELEMENT dynosaur (Velociraptor) +>
所以我正在尝试使用以下但不起作用...
return <!ELEMENT dynosaur ({$dynosaurName}) +> //here i want that format but it return error
和xml文件:
<?xml version="1.0"?>
<dinosauria>
<group>
<name>saurishia</name>
<subgroups>
<group>
<name>theropoda</name>
<subgroups>
<group>
<name>carnosaurs</name>
<speciesList>
<species age="74">Dyptosaurus</species>
<species age="170">Megalosaurus</species>
<species age="67">Tyrannosaurus</species>
</speciesList>
</group>
<group>
<name>coelurosauria</name>
<speciesList>
<species age="84">Velociraptor</species>
<species age="110">Deinonychus</species>
<species age="228">Eoraptor</species>
</speciesList>
</group>
</subgroups>
</group>
<group>
<name>sauropodomorpha</name>
<subgroups>
<group>
<name>sauropods</name>
<speciesList>
<species age="155">Brachiosaurus</species>
<species age="155">Camarasaurus</species>
</speciesList>
</group>
</subgroups>
</group>
</subgroups>
</group>
<group>
<name>ornithishia</name>
<subgroups></subgroups>
</group>
</dinosauria>
最后:
我找不到任何方法来return那种类型的结果。考虑到这本书,我检查了很多链接:http://www.datypic.com/books/xquery/chapter09.html
你可以尝试输出文本吗?
return concat("<!ELEMENT dynosaur (",$dynosaurName, ") +>")
我在 .xml
文件中使用 XQUERY FLWOR
表达式:
for $dynosaur in doc("document.xml")//species
let $dynosaurName := $dynosaur/text() // keeping the dynosaurName as a variable
return $dynosaur
以上 return 结果如下:
<species age="84">Velociraptor</species>
我需要格式化结果如下:
<!ELEMENT dynosaur (Velociraptor) +>
所以我正在尝试使用以下但不起作用...
return <!ELEMENT dynosaur ({$dynosaurName}) +> //here i want that format but it return error
和xml文件:
<?xml version="1.0"?>
<dinosauria>
<group>
<name>saurishia</name>
<subgroups>
<group>
<name>theropoda</name>
<subgroups>
<group>
<name>carnosaurs</name>
<speciesList>
<species age="74">Dyptosaurus</species>
<species age="170">Megalosaurus</species>
<species age="67">Tyrannosaurus</species>
</speciesList>
</group>
<group>
<name>coelurosauria</name>
<speciesList>
<species age="84">Velociraptor</species>
<species age="110">Deinonychus</species>
<species age="228">Eoraptor</species>
</speciesList>
</group>
</subgroups>
</group>
<group>
<name>sauropodomorpha</name>
<subgroups>
<group>
<name>sauropods</name>
<speciesList>
<species age="155">Brachiosaurus</species>
<species age="155">Camarasaurus</species>
</speciesList>
</group>
</subgroups>
</group>
</subgroups>
</group>
<group>
<name>ornithishia</name>
<subgroups></subgroups>
</group>
</dinosauria>
最后:
我找不到任何方法来return那种类型的结果。考虑到这本书,我检查了很多链接:http://www.datypic.com/books/xquery/chapter09.html
你可以尝试输出文本吗?
return concat("<!ELEMENT dynosaur (",$dynosaurName, ") +>")