[jdom-interest] Addition method in org.jdom.xpath.XPath that would be useful

Brynjar Glesnes brynjar.glesnes at entragroup.com
Wed Mar 5 02:40:22 PST 2003


Hi,

I am very pleased with the added XPath support found in JDOM. There is
however an addition method that I would find very useful. This is the
possibility to detect if a "compiled" XPath is a location path.

In more detail I have an org.jdom.xpath.XPath instance compiled with
XPath.newInstance(). What method to invoke on this XPath depends on whether
it is a location path in which case I invoke some selectNodes() method. Else
I invoke valueOf() on the XPath.

In order to be able to do this I have added the following to
org.jdom.xpath.XPath:

   /**
    * Detects whether the wrapped XPath expression is a location path.
    * <p>
    * This is useful in order to deside whether this XPath should be
evaluated
    * using a method returning a node set or a method that computes a single
    * value.
    * <p>
    *
    * @return whether the wrapped XPath expression is a location path.
    */
   public abstract boolean isLocationPath();

and the following to org.jdom.xpath.JaxenXPath:

  /**
    * Detects whether the wrapped XPath expression is a location path.
    * <p>
    * This is useful in order to deside whether this XPath should be
evaluated
    * using a method returning a node set or a method that computes a single
    * value.
    * <p>
    *
    * @return whether the wrapped XPath expression is a location path.
    */
   public boolean isLocationPath() {
       return xPath.getRootExpr() instanceof LocationPath;
   }

Is this of any general interest? Is it possible to add this functionality to
the JDOM project?

Regards
Brynjar Glesnes
Entra Data AS, Hoffsveien 17, 0275 Oslo, Norway
+47 932 48 347 / +47 21 93 98 00
http://www.xmltransform.com




More information about the jdom-interest mailing list