• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Arvind Ik Chari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let $dd:=/version-no/version-date

The context is version-no already. The query should work like this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic