![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - a little hairy sorting problem. [Thread Next] Re: a little hairy sorting problem.To: NULL Date: 3/2/2004 7:02:00 AM Use:
<xsl:sort select="../contact[contactid = current()/*]/lastname"/>
Cheers,
Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,
http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"Jiho Han" <jiho.han@i...> wrote in message
news:O7nN8f9$DHA.2480@T......
> I have a source xml in the following format:
>
> <associations>
> <association>
> <associationid>ass1</associationid>
> <fromid>con1</fromid>
> <toid>acc1</toid>
> </association>
> <association>
> <associationid>ass2</associationid>
> <fromid>acc1</fromid>
> <toid>con2</toid>
> </association>
> <association>
> <associationid>ass3</associationid>
> <fromid>acc2</fromid>
> <toid>con1</toid>
> </association>
> <contact>
> <contactid>con1</contactid>
> <lastname>Smith</lastname>
> </contact>
> <contact>
> <contactid>con2</contactid>
> <lastname>Adams</lastname>
> </contact>
> <account>
> <accountid>acc2</accountid>
> <name>ABC Corp.</name>
> </account>
> <account>
> <accountid>acc1</accountid>
> <name>XYZ Industries, Ltd.</name>
> </account>
> </associations>
>
> What I need to do is, for each <association>, sort it by <lastname>. As
you
> can see, <association> to <contact> or <association> to <account> is not
> always the same. It can be by fromid or by toid.
> The resulting output will be HTML and it will look something like this:
>
> <table>
> <!-- header row not necessary -->
> <tr><th>AssociationId</th><th>Contact Lastname</th><th>Account
> Name</th></tr>
> <tr><td>ass2</td><td>Adams</td><td>XYZ Industries, Ltd.</td></tr>
> <tr><td>ass1</td><td>Smith</td><td>XYZ Industries, Ltd.</td></tr>
> <tr><td>ass3</td><td>Smith</td><td>ABC Corp.</td></tr>
> </table>
>
> I tried something like this:
>
> <xsl:for-each select="association">
> <xsl:sort select="/associations/contact[contactid = ./fromid or
> contactid = ./toid]/lastname"/>
> <tr>
> ...
> </tr>
>
> which obviously didn't work...
> What is the correct sort expression that's going to get me the result I
> want?
>
> Thanks very much.
> Jiho
>
>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
