Dear Amy,

I think that we have to distinguish two fundamental uses of XML : document
centric and data centric.

An example of the first use can be illustrated here : 

<Book title="A Title">
        <Chapter name="Chapter 1"/>
        <Chapter name="Chapter 2"/>
        <Chapter name="Chapter 3"/>     
</Book>

As you can imagine here the element position is fundamental. Moreover when
you define an XML Schema the element declaration order is essential.

In your example Amy, you use XML in a data centric way. And you don't mind
the position of element.

So right now what getPath() method should return ?

If we want to follow the W3C recommendation I believe that the use of
element position is mandatory. 

Emmanuel

-----Message d'origine-----
De : Amy Lewis [mailto:[EMAIL PROTECTED]]
Envoyé : jeudi 7 juin 2001 00:14
À : [EMAIL PROTECTED]
Objet : Re: [dom4j-dev] getPath()


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


========================================================================= 
Ce message et toutes les pièces jointes sont propriété de VALTECH et 
susceptibles de contenir des informations confidentielles à l'intention 
exclusive de ses destinataires. Si vous avez reçu ce message par erreur 
ou si celui ci vous est parvenu incomplet ou altéré, merci d'en avertir 
l'expéditeur par retour.Toute utilisation, diffusion ou publication non 
expressément autorisée par nous par écrit est strictement interdite. 
 -------------------------------------------------------------------------- 
This message and any attachments are Valtech property and may contain 
iconfidential information intended solely for the addressees. If your are 
not the intended recipient of this message or if you have received it 
uncomplete or altered, please notify the author by replying to his e-mail 
immediately. Any unauthorised use, diffusion or dissemination not 
expressly authorised by us in writing is strictly prohibited. 
========================================================================= 
Copyright Valtech 2000 



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

Reply via email to