Not quoting your original message, because it contains bad wacky voodoo
which freaks out my xterm'd pine session.

Anyhow...

Selecting JDOM nodes from an XPath.  That's pretty standard, and what Jaxen
excels at.  Tricky part is writing good XPaths.  zvon.org has a good tutorial
about XPath in general.

As far as reverse-engineering an XPath from a node, that's a tad more ambiguous.
Like the perlites say, TMTOWTDI. Simplest form is use proximity predicates:

        /*[1]/*[3]/*[2]

Of course, those break easily, as soon as you alter the document.  Doing
named-proximity is better, kinda.

        /foo[1]/bar[1]/baz[3]

But, still fragile.

XPaths are best when they deal with semantic information instead of
structures/syntactic.

        /foo/bar[/baz[@id="cheese"]]

fwiw, if you can change object-models, I believe dom4j (dom4j.org) has
a method expressly for the purpose of giving you a (possibly fragile)
xpath denoted the node.  Regardless, it's just a matter of recursing
the getParent() chain, and building some text.

        -bob


_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to