This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: question regarding Saxon customized extension and NodeInfo


> I am trying to write a customized Saxon java extension which
> reads a file,
> convert each line into a Node and put into a NodeSet, then
> have stylesheet process the NodeSet.
> >
> What I wanted is to process it just once... so I created a
> customized class
> that implements NodeEnumeration interface... so each call to
> nextElement()
> actually calls the BuffereReader.readLine() until readLine()
> returns null...
> I have everything in place, except I couldn't figure out how
> to create an
> NodeInfo (which is required by
> NodeEnumeration.nextElement()).  Basically I
> want to get the one line of text from the file, and somehow
> convert it into
> a NodeInfo....
>
This question is very Saxon-specific, so it probably should have been asked
on the Saxon list at http://saxon.sf.net/.

NodeInfo is an interface, so to create instances of it you will have to
either define an implementation class or choose an existing implementation
class. The existing implementations (tree.NodeImpl, tinytree.NodeImpl, etc)
all have constructors that assume you are building a tree. In fact, you
almost inevitably need to build a tree in order to support all the axes. So
I think it's hard to improve on the way you are currently doing it.

Of course with XPath 2.0 / Saxon 7.0 you don't need to represent this
structure as a tree, you can represent it as a sequence of strings. This
makes it a great deal easier to implement your own iterator class which
returns the lines of the file on demand, because there is now no need to
support all the complexities of the XPath tree model.

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]