Antwort: Re: [jdom-interest] org.jdom.xpath.XPath

Hans Prüller hans.prueller at
Wed Apr 10 06:32:19 PDT 2002

just as you explained Laurent... I think this would be the right thing to


|        |          Laurent Bihanic       |
|        |          <laurent.bihanic at atoso|
|        |>            |
|        |          Gesendet von:         |
|        |          jdom-interest-admin at jd|
|        |                |
|        |                                |
|        |                                |
|        |          10.04.2002 14:04      |
|        |                                |
  |                                                                                                           |
  |       An:     Jason Hunter <jhunter at>                                                              |
  |       Kopie:  JDOM Interest <jdom-interest at>                                                      |
  |       Thema:  Re: [jdom-interest] org.jdom.xpath.XPath                                                    |

As Jason requested some feedback, here it goes:

Although I wrote most of org.jdom.xpath.XPath, I do not agree with the
interface of the valueOf() method.
The current interface directly exposes the bahaviour of Jaxen which returns
empty string in many "error" cases. Although this may be a desirable
for XSLT processor, I don't think it applies to an API.

More specifically, valueOf() currently returns an empty string if the XPath

expression does not match any node. Thus, valueOf() for the XPath
"@name" will return "" if the attribute "name" is missing or if it's actual

value is "".
The method numberValueOf() already distinguishes the two cases returning
either null (no match) or Double.NaN (found value cannot be converted into

As a programmer I'd like to be able to distinguish between the above two
by simply testing the returned value. Otherwise, I'll have to use a
combination of XPath.selectSingleNode() and a JDOM method depending of the
type of object returned.

Thus I'd propose to change the interface of valueOf as follows:

     * @return the string value of the first node selected by applying
     *         the wrapped XPath expression to the given context or
     *         <code>null</code> if no node was selected.

Opinions ?


Jason Hunter wrote:
> I just checked in an org.jdom.xpath.XPath class written by Laurent
> Bihanic which provides a simple API for the common XPath calls you'll
> want to make.  It by default right now wraps the Jaxen library, but it's
> designed so we can plug alternative implementations in the future.  I
> welcome people using XPath to test it out and see how it works for you.
> Also, for the people helping design JDOM, the API isn't fixed and we
> should ensure it's exactly what we want.  Bob, your comments are most
> welcome.

To control your jdom-interest membership:

IGS Systemmanagement
GmbH & Co KG
Dorfplatz 5
A-4531 Piberbach
phone: +43 7228 6451 0       home:
fax: +43 7228 6451 30        eMail: igs at
fax: +43 7228 6451 20        eMail: hotline at


DKC Dokumentation ab sofort unter
im Downloadbereich verfügbar

Anlagenmanagement ab sofort verfügbar
Reservieren Sie sich Ihren persönlichen Demotermin
unter: igs at


More information about the jdom-interest mailing list