Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: a little hairy sorting problem.

From: "Dimitre Novatchev [MVP XML]" <dnovatchev@-----.--->
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
>
>




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent