Как мне смешивать «новые» теги в предложении return
для xquery
?
это форма вывода, которая мне нужна:
<?xml version="1.0"?>
<csv>
<record>
<sex>M</sex>
</record>
<record>
<sex>F</sex>
</record>
<record>
<sex>M</sex>
</record>
<record>
<sex>F</sex>
</record>
</csv>
Специфические c значения, которые я ввел вручную для иллюстрации. Фактические значения и текущий выход:
<?xml version="1.0" encoding="UTF-8"?><csv>SexMFFMFFMF</csv>
исходные xml
данные:
<csv>
<record>
<entry>Reported_Date</entry>
<entry>HA</entry>
<entry>Sex</entry>
<entry>Age_Group</entry>
<entry>Classification_Reported</entry>
</record>
<record>
<entry>2020-01-26</entry>
<entry>Vancouver Coastal</entry>
<entry>M</entry>
<entry>40-49</entry>
<entry>Lab-diagnosed</entry>
</record>
<record>
<entry>2020-02-02</entry>
<entry>Vancouver Coastal</entry>
<entry>F</entry>
<entry>50-59</entry>
<entry>Lab-diagnosed</entry>
</record>
<record>
<entry>2020-02-05</entry>
<entry>Vancouver Coastal</entry>
<entry>F</entry>
<entry>20-29</entry>
<entry>Lab-diagnosed</entry>
</record>
<record>
<entry>2020-02-05</entry>
<entry>Vancouver Coastal</entry>
<entry>M</entry>
<entry>30-39</entry>
<entry>Lab-diagnosed</entry>
</record>
<record>
<entry>2020-02-11</entry>
<entry>Interior</entry>
<entry>F</entry>
<entry>30-39</entry>
<entry>Lab-diagnosed</entry>
</record>
<record>
<entry>2020-02-20</entry>
<entry>Fraser</entry>
<entry>F</entry>
<entry>30-39</entry>
<entry>Lab-diagnosed</entry>
</record>
<record>
<entry>2020-02-21</entry>
<entry>Fraser</entry>
<entry>M</entry>
<entry>40-49</entry>
<entry>Lab-diagnosed</entry>
</record>
<record>
<entry>2020-02-27</entry>
<entry>Vancouver Coastal</entry>
<entry>F</entry>
<entry>60-69</entry>
<entry>Lab-diagnosed</entry>
</record>
</csv>
Запрос FLWOR
:
declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
declare namespace array = "http://www.w3.org/2005/xpath-functions/array";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
for $x in /csv
return <csv>{$x/record[position() = (1 to 9)]/entry[3]/text()}</csv>
I ' Мы пробовали поместить теги узлов в фигурные скобки , но столкнулись с синтаксическими ошибками.