Hi,

First of all I want to say how I am happy to use this great library and
congratulate the author.

I would like to submit a little enhancement for the method getPath() of
AbstractElement class.
Indeed as it is written it didn't produce a good XPath if there is an
element repetition. For this I write this code : 

    public String getPath() {
       Element parent = getParent();
       int i = 1;
       if(parent != null){
         for(Iterator it = parent.elementIterator(); it.hasNext();){
           Element eltTmp = (Element)it.next();
           if(this == eltTmp){
             break;
           }
           if(getName().equalsIgnoreCase(eltTmp.getName())){
             i++;
           }
         }
       }
       return (parent != null)
         ? getPath() + "/" + getQualifiedName() +"[" + i + "]"
         : getQualifiedName();
     }

As example this code will produce this XPath query :
   resources/business[1]/bus[1]/line[2]/@name
 in place of : 
   resources/business/bus/line/@name
which don't point to the same node.

I hope this will help.

Every comments are welcome

Emmanuel



========================================================================= 
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