camel with xquery
myTransform.xquery文件:
<persons>
{
for $b in (persons/person)
return
if($b/age>20)
then
<man>
{$b/firstName}
</man>
else
""
}
</persons>
message.xml
<persons>
<person user="james">
<firstName>James</firstName>
<lastName>Strachan</lastName>
<city>London</city>
<age>20</age>
</person>
<person user="xiaofei">
<firstName>xiaofei</firstName>
<lastName>liu</lastName>
<city>ShangHai</city>
<age>23</age>
</person>
<person user="tony">
<firstName>tony</firstName>
<lastName>liu</lastName>
<city>ShangHai</city>
<age>23</age>
</person>
</persons>
camelcontext.xml:
<route>
<from uri="file:src/data?noop=true"/>
<to uri="xquery:myTransform.xquery"/>
<to uri="file:target/outputFiles"/>
</route>
out:
<persons>
<man>
<firstName>xiaofei</firstName>
</man>
<man>
<firstName>tony</firstName>
</man>
</persons>
<persons>
{
for $b in (persons/person)
return
if($b/age>20)
then
<man>
{$b/firstName}
</man>
else
""
}
</persons>
message.xml
<persons>
<person user="james">
<firstName>James</firstName>
<lastName>Strachan</lastName>
<city>London</city>
<age>20</age>
</person>
<person user="xiaofei">
<firstName>xiaofei</firstName>
<lastName>liu</lastName>
<city>ShangHai</city>
<age>23</age>
</person>
<person user="tony">
<firstName>tony</firstName>
<lastName>liu</lastName>
<city>ShangHai</city>
<age>23</age>
</person>
</persons>
camelcontext.xml:
<route>
<from uri="file:src/data?noop=true"/>
<to uri="xquery:myTransform.xquery"/>
<to uri="file:target/outputFiles"/>
</route>
out:
<persons>
<man>
<firstName>xiaofei</firstName>
</man>
<man>
<firstName>tony</firstName>
</man>
</persons>
posted on 2010-02-01 11:10 小飛哥 閱讀(1637) 評論(0) 編輯 收藏 所屬分類: camel