camel with xquery

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>

你可能感兴趣的:(camel with xquery)