ITeye博客

camel with xquery

dwtq · 2010-02-01 11:10 · [网站分类]1.网站首页原创Java技术区(对首页文章的要求: 原创、高质量、经过认真思考并精心写作。BlogJava管理团队会对首页的文章进行管理。) · Markdown

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>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。