Dear James and Emmanuel (and others),
On Tue, Jun 05, 2001 at 11:40:57AM -0700, James Strachan wrote:
>I think you're both right ;-)
>
>How about a compromise:
>
>* we add a warning to the JavaDoc that if you change the document in any way
>then the XPath may no longer work.
>* I add a patch such that the index notation [2] is used if there are
>multiple siblings with the same QName.
>
>such that
>
>/root/nodeA/nodeB[2]/@attribute would occur if nodeA had 2 nodeB nodes but
>root had only one nodeA node.
>
>Sound like a good plan?
No.
*laugh*
Sorry. What I would prefer to do instead is ask:
what is the purpose of getPath?
Defining its purpose is likely to help define its semantics.
For instance: getPath() may be expected to return a valid XPath which
can be used to retrieve a nodeset, which this node is a member of. Or:
getPath() may be expected to return a valid XPath which can be used to
retrieve a nodeset, which is expected to have only a single member,
this node. Or: getPath() returns a list of ancestor nodes, in the form
of an XPath expression; the content of the nodeset returned by
evaluating the expression is not guaranteed, although it is likely to
contain this node.
My problem with the greater specificity is the means by which it is
obtained. Positional notation is a poor match for XML (in my opinion);
I don't see as much use of positional notation in XPaths as the XSLT
and XPath recommendations seem to suggest is likely. Let me provide an
example:
<document>
<properties>
<property name="whatever">value</property>
<property name="whenever">1:23</property>
<property name="however">fast</property>
<property name="never">now</property>
</properties>
</document>
This is not a terribly unusual document style, by the by. But the
choice of positional notation, rather than (in this case) value of an
attribute, makes the suggested default XPath generation less useful. I
don't *care* whether the document contains the "however" property in
position 3; I only care that the property I munge has the name
attribute "however".
Okay? I like getPath(), but I don't like the idea of even *trying* to
provide an XPath specific enough to generate a single-member node set,
because I don't think a generic algorithm can extract the interesting
information required for doing so (without expensive heuristics, that
is ... it *is* possible, in concept, and an interesting problem).
Using positional notation with XML doesn't strike me as a good thing.
Sorry.
Amy!
--
Amelia A. Lewis [EMAIL PROTECTED] [EMAIL PROTECTED]
I don't know that I ever wanted greatness, on its own. It seems rather like
wanting to be an engineer, rather than wanting to design something--or
wanting to be a writer, rather than wanting to write. It should be a
by-product, not a thing in itself. Otherwise, it's just an ego trip.
-- Merlin, son of Corwin, Prince of Chaos (Roger Zelazny)
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev