2012-12-11 45 views
2

是我的xml:CONCAT()中的XPath

<compositeurs> 
    <compositeur></compositeur> 
    <compositeur id="5"> 
     <dates naissance="1687" deces="1770"></dates> 
     <nom> 
      <prenom>Johann</prenom> 
      <prenom>Sebastian</prenom> 
      <prenom>Sebastian</prenom> 
      <prenom>Sebastian</prenom> 
      <famille>Bach</famille> 
     </nom> 
    </compositeur> 
     <pays>Alemagne</pays> 
    <compositeur></compositeur> 
</compositeurs> 

我想Concat的所有元素prenom有粉彩= 「巴赫」。

我用concat(//nom[famille='Bach']/prenom)但它錯了。

回答

2

這是不可能做到這一點XPath 1.0中

這裏做了XPath 2.0的方式:

string-join(//nom[famille='Bach']/prenom, ' ') 

如果XPath 2.0中是不可用的,你總是可以拼接你的原始表達式的結果無論你使用什麼命令式語言。

+0

我使用氧氣它不可用:\ –

+0

@DalyChan AFAIK,氧氣支持XPath 2.0。這當然是[可用於XSL樣式表](http://www.oxygenxml.com/xml_editor/xslt_editor.html#xpathAwareCC) – toniedzwiedz

+0

感謝它現在可以工作,我將xpath 1.0更改爲2.0 :) –