Hey Bob

Yes that sounds like a correct explanation to me. I think numeric types will
be supported too, though maybe the expression needs to be wrapped in a
number() function call.

docElem.selectNodes( "a", "number(@price)" )

Though I've never tested the above ;-)

James
----- Original Message -----
From: "bob mcwhirter" <[EMAIL PROTECTED]>
To: "Terry Steichen" <[EMAIL PROTECTED]>
Cc: "dom4j-user" <[EMAIL PROTECTED]>
Sent: Sunday, June 02, 2002 5:09 AM
Subject: Re: [dom4j-user] Sorting selectNodes() results


> On Sat, 1 Jun 2002, Terry Steichen wrote:
>
> > Could anyone explain how you are supposed to use selectNodes(Xpath1,
> > Xpath2) such that Xpath2 results in a sorted node list?
>
> I'm just guessing, as I've never useed it, but here's what I divine
> from the javadocs...
>
> xpath1 is used to select the set of nodes to be sorted.  It's the
> normal 'xpath' paramter as in the simpler selectNodes(String xpath)
> method.
>
> The xpath2 parameter then, is used to select the key that's used
> to perform the sorting, which I assume in only natural order of
> strings.  (James? Does is handle numeric types, or anything?).
>
> So, given:
>
>
> <doc>
> <a name="foo"/>
> <a name="bar"/>
> <a name="cheese"/>
> </doc>
>
> And, given an Element representing the <doc> element, this
>
> docElem.selectNodes( "a", "@name" )
>
> would produce a list of <a> elements sorted by the value of the
> 'name' attribute, producing:
>
> {
> <a name="bar"/>,
> <a name="cheese"/>,
> <a name="foo"/>,
> }
>
> Hope that helps.  Heck, I hope it's an even marginally correct
> explanation.
>
> -bob
>
>
> _______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

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

Reply via email to