2014-02-07 38 views
0

有人guru xquery嗎?使用xquery flwor表達式在XML標記中寫入變量

我有一個XQuery的FLWOR表達式:

<dg:segment xsi:type="dg:SegmentEauType"> 
{ 
for $attr_name in fme:get-list-attribute("_att{}._attr_name") 
return <attribut name="{$attr_name}">value</attribut> 
} 
</dg:segment> 
產生

<dg:segment xsi:type="dg:SegmentEauType"> 
    <attribut name="DIAMETREM_R">value</attribut> 
    <attribut name="PROVENANCEDONNEE_R">value</attribut> 
    <!-- etc... --> 
</dg:segment> 

我怎樣才能獲取XML節點?

<dg:segment xsi:type="dg:SegmentEauType"> 
    <DIAMETREM_R>value<DIAMETREM_R> 
    <PROVENANCEDONNEE_R>value<PROVENANCEDONNEE_R> 
    <!-- etc... --> 
</dg:segment> 

我試過了,但是出現了錯誤。

for $attr_name in fme:get-list-attribute("_att{}._attr_name") 
return <{$attr_name}>value</{$attr_name}> 

不要沒關係約FME:獲取列表屬性功能...

很多的Tx!

+1

什麼「錯誤」弄來? –

回答

3

嘗試:

<dg:segment xsi:type="dg:SegmentEauType"> 
{ 
for $attr_name in fme:get-list-attribute("_att{}._attr_name") 
return element { $attr_name } { 'value' } 
} 
</dg:segment> 
+0

你可以試試這個解決方案直播http://try.zorba.io/queries/xquery/%2BZDmCM7MapDlHFhzLgN56B9%2FV7Q%3D – wcandillon

+0

它的作品...謝謝! – user1555873