aspose file tools*
The moose likes XML and Related Technologies and the fly likes Nux XML processing library-error in streaming path filter code in API docs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Nux XML processing library-error in streaming path filter code in API docs" Watch "Nux XML processing library-error in streaming path filter code in API docs" New topic
Author

Nux XML processing library-error in streaming path filter code in API docs

Arvind Ik Chari
Greenhorn

Joined: Dec 02, 2012
Posts: 13
Hi

I am referring to http://acs.lbl.gov/software/nux/api/nux/xom/xquery/StreamingPathFilter.html

On that page, an example is given for parsing large XML documents in such a way that at a time only a small record/subset of the XML is loaded in memory.

Now, that page mentions that "Here is a similar snippet version that takes a filtering Builder from a thread-safe pool with optimized parser configuration:"

The code given on above page that I am referring to is now given below--



However when I enter the above data into my Eclipse java app, I get this error-- "The constructor BuilderPool(int, new BuilderFactory(){}) is undefined".

Now, I changed the above code into this--



The above code does not give any error-- however in the transform named "mytransform" I have added code to output the data that is processed by that transform-- but for some reason, the transform is not being applie d(because not even on line is being output by my commands within that transform function).

How do I initialise/run the streaming path filter of Nux correctly, so that the transform is applied?

Thanks,
Arvind.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 517
    
    3
final StreamingPathFilter filter = new StreamingPathFilter(path, prefixes);
BuilderPool pool = new BuilderPool(100, new BuilderFactory() {
protected Builder newBuilder(XMLReader parser, boolean validate) {
return new Builder(parser, validate, filter.createNodeFactory(null, myTransform));
}
}
);

The pool line should be set up properly with nux.xom.pool.PoolConfig. One can start with default setting and it will look like this.

So yes, the page does not put it exactly right.

As a supplementary note, the myTransform has to be declared final for this use case of BuilderPool, consequential to its being accessed from within the inner class.
Arvind Ik Chari
Greenhorn

Joined: Dec 02, 2012
Posts: 13
Hi,

OK with your advice I was able to make it work.

Now, I am outputting the intermediate data(ie each element that is processed by the transform). For some reason I am not getting the data output--

This is my code(for the transform function)--




Now this is the output I am getting for the above(for a specific piece of data and a specific transform)--




AS you can see from the above, an element has data "<version-no><version-date>20040404</version-date></version-no>"
and query on that element is " let $dd:=/version-no/version-date return $dd "


But the result of that query is empty?

Also, I tried the query as " let $dd:=version-no/version-date return $dd " also, but got no result even then.

What am I doing wrong here?

Thanks,
Arvind.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 517
    
    3
let $dd:=/version-no/version-date

The context is version-no already. The query should work like this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nux XML processing library-error in streaming path filter code in API docs