"ted sandler" <[EMAIL PROTECTED]> writes:

> Hi.  The XML tools that you guys at Apache have been building are
> fantastic and I want to let you know how helpful it's been to my
> work.

Hey Ted,

You're welcome. Thanks for letting us know. I do a lot of work for
this project, and it's completely voluntary. I haven't had a lot of
time to devote to the project lately, and I've felt a bit guilty. 

But at the same time, I haven't heard a lot of feedback recently, and
so I begin to wonder whether I'm developing an XML parser just for
myself. 

Feedback like yours, gives me a reason to prioritize the XML::Xerces
work. 

> I am emailing because I am having difficulty creating a tree walker for a
> parsed documents and I think it's due to a deficiency in the perl API to
> Xerces-C.  The problem centers around the fact that there is no way to
> create a new XML::Xerces::DOM_NodeFilter object (I've included the relevent
> portion of the Xerces.pm module at the bottom of this email).  The new()
> method is entirely absent.
> 
> Consequently, there seems no way to create a treewalker object because
> DOM_Document_createTreeWalker( ) requires a DOM_NodeFiler object as its 3
> argument.  Is there any way to get around this?

This is because I've never built one, and so I never checked that this
API actually works. 

>From the example code that I found in the xerces-c archive at:

  http://marc.theaimsgroup.com/?l=xerces-c-dev&w=2&r=1&s=DOM_NodeFilter&q=b

It seems that DOM_NodeFilter is really just an interface, and you are
supposed to create your own class that implements that interface.

There is a problem there. The issue is that whatever class you create,
call it MyNodeFilter, is going to have to provide some object that can
be passed to Xerces-C and be stored for callbacks, because that is how
the acceptFilter() method works, I think. Whenever the treewalker hits
a node, it calls acceptFilter() on the MyNodeFilter instance you gave
it. 

So what is the problem? The problem is that Xerces-C can only store
pointers to C++ objects. That means that currently you can't have a
Perl only class that does what you want. 

That sucks.

I've hit this problem many times before - there are many interfaces
that exist in Xerces-C like all the *Handler classes: ErrorHandler,
ContentHandler, etc. Each time I implemented a Separate solution for
them: a C++ callback class that simply stored the pointer to a Perl
object (the MyNodeFilter instance in your case) and forwarded all
method calls to it. That way, whenever you create a treewalker and
pass in an instance of your MyNodeFilter class, I would have to first
create an instance of the C++ callback class, passing it the
MyNodeFilter instance you provided, and then sending the C++ callback
class instance to the Xerces-C treewalker creation code.

As you can see it's a bit complicated, and since it's code that has to
go in Xerces.pm it's not something that a user is expected to be able
to do. I tell you not because I expect you to roll up your sleeves and
begin hacking Xerces.pm, but just to let you know it's possible.

I'll take a look at it, and make another experimental release of 1.6.0
with that functionality. That means that you'll have to get
Xerces-C-1.6.0 in order to get it to work.

Cheers,
jas.

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

Reply via email to