camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Müller (JIRA) <j...@apache.org>
Subject [jira] [Commented] (CAMEL-3998) improve stax/jax components
Date Sun, 19 Jun 2011 15:27:47 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-3998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13051697#comment-13051697
] 

Christian Müller commented on CAMEL-3998:
-----------------------------------------

In one of our projects, we need the ability to split a large XML file (3 - 10 GB) into its
individual records. Because XPath reads the entire document into memory, it's not an option
for us. For the time being, we will develop our own custom Splitter which use internally StAX
to stream the file and return an Iterator. For each call of hasNext()/next() on the Iterator
interface, we will read and return the next record.

I think we will share this solution so that in Camel 2.9.0, the user should be able to do
something like (in the same way as the xpath support):
{code:java}
from("direct:start")
  .split(stax("//foo/bar"))
  .convertBodyTo(String.class) // may be not necessary, depending on the stax response
  .to("mock:result")
{code}

The following should also be possible:
{code:java}
StaxBuilder staxBuilder = new StaxBuilder("//foo/bar"); 
from("direct:start")
  .split(staxBuilder)
  .convertBodyTo(String.class) // may be not necessary, depending on the stax response
  .to("mock:result")
{code}

To support namespaces, the following should be implemented:
{code:java}
Namespaces ns = new Namespaces("c", "http://acme.com/cheese");
from("direct:start")
  .split(stax("//foo/bar", ns))
  .convertBodyTo(String.class) // may be not necessary, depending on the stax response
  .to("mock:result")
{code}

and also:
{code:java}
Namespaces ns = new Namespaces("c", "http://acme.com/cheese");
StaxBuilder staxBuilder = new StaxBuilder("//foo/bar");
staxBuilder.setNamespaces(ns.getNamespaces());

from("direct:start")
  .split(staxBuilder)
  .convertBodyTo(String.class) // may be not necessary, depending on the stax response
  .to("mock:result")
{code}

What do you think?

> improve stax/jax components
> ---------------------------
>
>                 Key: CAMEL-3998
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3998
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Romain Manni-Bucau
>            Priority: Minor
>
> it could be pretty cool to have an iterator to be able to iterate over a filtered tree
of a xml document avoiding to load all the document in memory.
> it can be nice to do it loading sub objects using jaxb.
> i did a version here: http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/src/main/java/org/apache/camel/stax/expression/StAXJAXBIteratorExpression.java
(i added some converters to help too).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message