Xquery检索信息(将单独的重复字段分成单个值)

时间:2012-05-05 01:17:13

标签: xml xslt xquery

XML文件来自 food:food-item($ food:fps-photo-atlas)

<portion>
<food-description unit="g">Spaghetti     </food-description>
<food-number file-type="jpg">3    </food-number>
<portion-size>
<size tag="1">55    </size>
<size tag="2">108    </size>
<size tag="3">161    </size>
<size tag="4">214    </size>
<size tag="5">266    </size>
<size tag="6">319    </size>
<size tag="7">372    </size>
<size tag="8">425    </size>
</portion-size>
<size-increment eight-plus="478">52.86    </size-increment>
</portion>

我的XQUERY(XML到HTML部分)

for $x in food:food-item($food:fps-photo-atlas)/portion/portion-size
return
<i>{data($x/size)}</i>
}

我当前XQuery的当前结果

<i>55 108 161 214 266 319 372 425</i>

首选结果..

<i>55</i>
<i>108</i>
<i>161</i>
<i>214</i>
<i>266</i>
<i>319</i>
<i>372</i>
<i>425</i>

谢谢!

1 个答案:

答案 0 :(得分:3)

for $x in food:food-item($food:fps-photo-atlas)/portion/portion-size/size
return
<i>{data($x)}</i>
}