Hi David

From: "David White" <[EMAIL PROTECTED]>
> Yep, that's why I think this stuff is so cool!

Me too! :-)

> Now, if we could only implement more powerful XPath expression to register
> handlers with (i.e. parser.addHandler("//a[@href]", new myLinkHandler());
> :^)

Now your talking!!!

:-)

Some kind of XPathDispatcher would be really cool.

A brute force approach is easy, an efficient non-brute force will require
some help from the XPath engine and is much more work :-(.

e.g. the brute force mechansim would be something like...

public XPathDispatcher implements ElementHandler {

    private XPath xpath;
    private ElementHandler child;

    public XPathDispatcher( XPath xpath, ElementHandler child ) {
        this.xpath = xpath;
        this.child = child;
    }

    public XPathDispatcher( String xpath, ElementHandler child ) {
        this.xpath = DocumentHelper.createXPath( xpath );
        this.child = child;
    }

    public void onStart( ElementPath path ) {
        // XXX don't know what to do here?
    }

    public void onEnd( ElementPath path )

        Element element = path.getCurrent();

        if ( xpath.matches( element ) ) {
            child.onEnd( path );
        }
    }
}

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to