"Murphy, James" <[EMAIL PROTECTED]> writes:

> Yuck?  WTF?  Its beautiful!  Maybe I should explain some more.
> 
> I followed the same links you described and realized that without some
> hacking in and around XMLScanner getting the BinInputStream from the
> ReaderMgr is a no go.  BTW, getting at XMLScanner from a parser would be
> real handy for lots of these kind of reasons.  
> 
> BUT, if you write your own file/mem InputSource that caches away its
> BinInputStream you can get at it from you sax event handler:
> 
> class cSuperFastMemInputSource : public MemBufInputSource
> {
>       BinInputStream* MemBufInputSource::makeStream() const
>       {
>          if (fMemStream = null)
>          {
>             fMemStream = new BinMemInputStream(fSrcBytes, fByteCount, 
> 
>              fCopyBufToStream ? BinMemInputStream::BufOpt_Copy :
> 
>                                 inMemInputStream::BufOpt_Reference);
>          }
>          return fMemStream;
>       }
> };

Probably want '==' for that comparison.

This doesn't come close to compiling: first because makeStream is
const, you can't do the assignment. You have to make a local variable
and cast of the const-ness like:

    BinMemInputStream *stream = new BinMemInputStream(...); 
    SuperFastMemBufInputSource *localThis = 
        const_cast<SuperFasMemBufInputSource *>(this);
    localThis->fMemStream = stream;

But then, all those variables are private, you have to modify
MemBufInputSource.hpp to change them to protected.

However ...

Even after this, it doesn't have the desired affect. Calling curPos()
in the startElement() method prints the same position for every
element:

    print Found element contributors at 377 offset
    print Found element person at 377 offset
    print Found element name at 377 offset
    print Found element email at 377 offset
            .
            .
            .

I modified it for LocalFileInputSource as well and got the same result:

    print Found element personnel at 1186 offset
    print Found element person at 1186 offset
    print Found element name at 1186 offset
    print Found element family at 1186 offset
            .
            .
            .

And 1186 is the length of the file, so it looks like the
BinInputStream is taken the whole way to the end in both cases before
the Parser starts the callbacks.

Any ideas what to do?
jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to