Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Sorting XSLT output items
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jure Sah  
View profile  
 More options Feb 27 2009, 10:24 pm
Newsgroups: comp.text.xml
From: Jure Sah <dustwo...@gmail.com>
Date: Sat, 28 Feb 2009 04:24:25 +0100
Local: Fri, Feb 27 2009 10:24 pm
Subject: Sorting XSLT output items
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I have an XSLT that checks several XML files (using document() ) and
outputs their combined contents. The items inside it have a date
argument according to which I would like to sort the result. How can
this be done?

That is... the usual sort will allow you to sort values from the input
file, but since my XSLT uses several other files in succession and
processes each of their items in a nested loop, I do not see where I
should put the sort tag to achieve the desired effect.

The only solution I see is to use an XSLT sort on the XSLT file output,
but that seems silly.

Thanks for any help in advance.

LP,
Jure
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJqK5pB6mNZXe93qgRArpKAJ95RHmaUjJ2xoBDW2+fAyl22y5urgCeJZPC
20XWXIcqPfzV0Ft0ynWW8Q8=
=dTj9
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options Feb 28 2009, 7:29 am
Newsgroups: comp.text.xml
From: Martin Honnen <mahotr...@yahoo.de>
Date: Sat, 28 Feb 2009 13:29:06 +0100
Local: Sat, Feb 28 2009 7:29 am
Subject: Re: Sorting XSLT output items

Jure Sah wrote:
> I have an XSLT that checks several XML files (using document() ) and
> outputs their combined contents. The items inside it have a date
> argument according to which I would like to sort the result. How can
> this be done?

   <xsl:apply-templates select="document('file1.xml')/foo/bar |
document('file2.xml')/foo/bar">
     <xsl:sort select="dateElement"/>
   </xsl:apply-templates/>

Note that only XSLT 2.0 has support for sorting dates in the W3C XML
schema date format. With XSLT 1.0 you will need to make sure you have
the date in a format like '2009-02-28' that allows string sorting.

--

        Martin Honnen
        http://JavaScript.FAQTs.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jure Sah  
View profile  
 More options Feb 28 2009, 10:53 pm
Newsgroups: comp.text.xml
From: Jure Sah <dustwo...@gmail.com>
Date: Sun, 01 Mar 2009 04:53:25 +0100
Local: Sat, Feb 28 2009 10:53 pm
Subject: Re: Sorting XSLT output items
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Honnen pravi:

>   <xsl:apply-templates select="document('file1.xml')/foo/bar |
> document('file2.xml')/foo/bar">
>     <xsl:sort select="dateElement"/>
>   </xsl:apply-templates/>

I can't use that, my files are defined in the XML file I am processing.

Any additional ideas?

LP,
Jure
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJqga1B6mNZXe93qgRAkB4AJ94ab4yjywTrzrMDvqagLpn+Kc3YwCgwJO0
oPruOVHNsVhJUlmGhkULDXw=
=5mF/
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options Mar 1 2009, 7:06 am
Newsgroups: comp.text.xml
From: Martin Honnen <mahotr...@yahoo.de>
Date: Sun, 01 Mar 2009 13:06:14 +0100
Local: Sun, Mar 1 2009 7:06 am
Subject: Re: Sorting XSLT output items

Jure Sah wrote:
> Martin Honnen pravi:
>>   <xsl:apply-templates select="document('file1.xml')/foo/bar |
>> document('file2.xml')/foo/bar">
>>     <xsl:sort select="dateElement"/>
>>   </xsl:apply-templates/>

> I can't use that, my files are defined in the XML file I am processing.

> Any additional ideas?

Nevertheless you should be able to process the union of nodes in those
documents and sort them. But you keep us guessing, show us your XML
input(s) and the result you want to produce, then we can suggest a way
how to solve that.

--

        Martin Honnen
        http://JavaScript.FAQTs.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jure Sah  
View profile  
 More options Mar 1 2009, 2:17 pm
Newsgroups: comp.text.xml
From: Jure Sah <dustwo...@gmail.com>
Date: Sun, 01 Mar 2009 20:17:55 +0100
Local: Sun, Mar 1 2009 2:17 pm
Subject: Re: Sorting XSLT output items
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Honnen pravi:

>>>   <xsl:apply-templates select="document('file1.xml')/foo/bar |
>>> document('file2.xml')/foo/bar">
>>>     <xsl:sort select="dateElement"/>
>>>   </xsl:apply-templates/>

>> I can't use that, my files are defined in the XML file I am processing.

>> Any additional ideas?

> Nevertheless you should be able to process the union of nodes in those
> documents and sort them. But you keep us guessing, show us your XML
> input(s) and the result you want to produce, then we can suggest a way
> how to solve that.

My code is available here:
http://dustwolf.ctrl-alt-del.si/downloads/XSLTaggregator_src.zip

As the name says, the code is a RSS Aggregator. Picks the URLs of the
RSS feeds to combine from an XML file and outputs the resulting feed.
Everything works fine, except the results are not sorted by date.

The code goes a little like this:
 <xsl:for-each select="feed:rss2">
  <xsl:variable name="myURL" select="." />
  <xsl:for-each select="document($myURL)/rss/channel/item">

..that is the two nested "for-each"es.

Any ideas?

Thanks.. really. :)

LP,
Jure
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJqt9jB6mNZXe93qgRApx7AJ9ZV5a82giJvMzw/857+KlOaFjO6QCgomZ7
4yAoOfSa7GSdnfIQH2YbtT8=
=HeXO
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Carlisle  
View profile  
 More options Mar 1 2009, 8:49 pm
Newsgroups: comp.text.xml
From: David Carlisle <david-n...@dcarlisle.demon.co.uk>
Date: Mon, 02 Mar 2009 01:49:55 +0000
Local: Sun, Mar 1 2009 8:49 pm
Subject: Re: Sorting XSLT output items

Jure Sah wrote:
> The code goes a little like this:
>  <xsl:for-each select="feed:rss2">
>   <xsl:variable name="myURL" select="." />
>   <xsl:for-each select="document($myURL)/rss/channel/item">

> ..that is the two nested "for-each"es.

> Any ideas?

just use one for-each then it's easier to sort over the whole collection.

<xsl:for-each select="document(feed:rss2)/rss/channel/item">
   <xsl:sort select= something ...

--
http://dpcarlisle.blogspot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jure Sah  
View profile  
 More options Mar 2 2009, 1:17 pm
Newsgroups: comp.text.xml
From: Jure Sah <dustwo...@gmail.com>
Date: Mon, 02 Mar 2009 19:17:23 +0100
Local: Mon, Mar 2 2009 1:17 pm
Subject: Re: Sorting XSLT output items
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Carlisle pravi:

> just use one for-each then it's easier to sort over the whole collection.

> <xsl:for-each select="document(feed:rss2)/rss/channel/item">
>   <xsl:sort select= something ...

That worked great! Thanks a bunch!

LP,
Jure
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJrCKyB6mNZXe93qgRAm7NAJ44ULtgBzuybjIZLWlw5s280T3y7gCaAsPz
SSxm9T0MZS6GTz8cAAoGnjg=
=MWke
-----END PGP SIGNATURE-----


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »