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

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


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


regards,
Hans



|--------+-------------------------------->
|        |          Laurent Bihanic       |
|        |          <laurent.bihanic at atoso|
|        |          rigin.com>            |
|        |          Gesendet von:         |
|        |          jdom-interest-admin at jd|
|        |          om.org                |
|        |                                |
|        |                                |
|        |          10.04.2002 14:04      |
|        |                                |
|--------+-------------------------------->
  >-----------------------------------------------------------------------------------------------------------|
  |                                                                                                           |
  |       An:     Jason Hunter <jhunter at acm.org>                                                              |
  |       Kopie:  JDOM Interest <jdom-interest at jdom.org>                                                      |
  |       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
an
empty string in many "error" cases. Although this may be a desirable
behaviour
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
expression
"@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
a
number).

As a programmer I'd like to be able to distinguish between the above two
cases
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 ?

Laurent


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:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com





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

NEWSFLASH___________________________________________

DKC Dokumentation ab sofort unter www.igs.at
im Downloadbereich verfügbar

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

NEWSFLASH___________________________________________




More information about the jdom-interest mailing list