tags:

views:

114

answers:

5

I'd like to filter a couple of nested xml elements, evaluation of their attributes. For this purposes I'm searching a efficient and lightweight java api or framework.

The main requirements are:

  • filtering of element bodies, based on some pattern or condition
  • event based XML transformation

My first idea was apache jelly, but jelly has an ungly side effect. It removes CDATA tags and thats an unwanted behaviour.

Thanks in advance.

A: 

I am pretty sure JXPath has filtering capabilities. Worth having a look at probably :)

willcodejavaforfood
JXPath uses XPath syntax to navigate POJO hierarchies, and isn't directly XML related
Brian Agnew
+1  A: 

Go simple and try SAX.

Charlie Martin
A: 

Finally I implemented the filterchain using dom4j and xpath. I decided for this api because it is quite handy if you got to move a number of branches inside one document and it's build in xpath facilitates finding the wanted elements.

Thanks for your answers.

Thomas
A: 

Would XSLT work for you? There are java libraries built in for this, and the layout is such that you can setup sections only when certain tags and/or conditions are met. Then again, you have to learn XSLT.

Clinton
A: 

I use and recommend xquery over xslt. Both are functional languages and take some getting used to. Saxon supports both. See http://saxon.sourceforge.net/

Brad Cox