Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 11th, 2006, 03:45 PM
bcochofel
Guest
 
Posts: n/a
Default XSLT sorting

I'm using xsl to list an xml file that contains something like: sites,
tag and weight.

I'm listing this in a table with the following titles: | URL | TAG |
WEIGHT (each title his a link)

What I want is when someone clicks a title chooses the sorting option,
if this is the actual sorting option then reverses the order. Can I do
this? How?

Here's an example:
Expand|Select|Wrap|Line Numbers
  1. ---------------------------------------------------------------------------------
  2. <sites>
  3. <!--
  4. Site url: required (pattern: (https?|ftp)://.+)
  5. Tag name: required
  6. Tag weight: integer optional
  7. -->
  8. <site url="http://www.google.com">
  9. <tag name="pesquisa" weight="30" />
  10. <tag name="procura" weight="30" />
  11. </site>
  12. <site url="http://www.google.com/webhp?complete=1">
  13. <tag name="ajax" weight="25" />
  14. <tag name="pesquisa" weight="30" />
  15. <tag name="procura" weight="30" />
  16. </site>
  17. <site url="https://webmail.fe.up.pt">
  18. <tag name="email" weight="20" />
  19. <tag name="feup" weight="20" />
  20. </site>
  21. </sites>
  22. --------------------------------------------------------------------------
  23.  
  #2  
Old December 11th, 2006, 04:35 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: XSLT sorting

bcochofel wrote:
Quote:
What I want is when someone clicks a title chooses the sorting option,
if this is the actual sorting option then reverses the order. Can I do
this? How?
Your XSLT probably creates a HTML table. To sort that table you can use
client-side script (JavaScript) if available. You can also use
client-side XSLT to sort if available although then you have to use
script too to run the transformation. A robust solution that works
independent of the browsers XSLT and script support will need to sort
the table server-side meaning a click on that table header will send a
request to the server to do the sorting and send a new document with a
sorted table back.

--

Martin Honnen
http://JavaScript.FAQTs.com/
  #3  
Old December 11th, 2006, 04:35 PM
bcochofel
Guest
 
Posts: n/a
Default Re: XSLT sorting

Well, I'm using Perl CGI to generate the XML on the server-side. On the
XML I have the query params from the script, so I was wondering if I
can use this params to sort within the XSL?
Also, I can I create an url with the value of some elements from my
XML?
Something like (on my xsl file), <a href="listsites.cgi?field=<xml
element value here>&sort=<xml element value here>">sites</a>...

On Dec 11, 4:55 pm, Martin Honnen <mahotr...@yahoo.dewrote:
Quote:
bcochofel wrote:
Quote:
What I want is when someone clicks a title chooses the sorting option,
if this is the actual sorting option then reverses the order. Can I do
this? How?Your XSLT probably creates a HTML table. To sort that table you can use
client-side script (JavaScript) if available. You can also use
client-side XSLT to sort if available although then you have to use
script too to run the transformation. A robust solution that works
independent of the browsers XSLT and script support will need to sort
the table server-side meaning a click on that table header will send a
request to the server to do the sorting and send a new document with a
sorted table back.
>
--
>
Martin Honnen
http://JavaScript.FAQTs.com/
  #4  
Old December 11th, 2006, 05:15 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: XSLT sorting

bcochofel wrote:
Quote:
Well, I'm using Perl CGI to generate the XML on the server-side. On the
XML I have the query params from the script, so I was wondering if I
can use this params to sort within the XSL?
Do you run the XSLT transformation on the server with Perl too? Or do
you rely on the browser doing the XSLT transformation?
Quote:
Also, I can I create an url with the value of some elements from my
XML?
Something like (on my xsl file), <a href="listsites.cgi?field=<xml
element value here>&sort=<xml element value here>">sites</a>...
Use attribute value templates e.g.
<a href="listsites.cgi?field={element-name}&amp;sort={element2-name}">
or xsl:attribute
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="concat('listsites.cgi?field=', element-name,
'&amp;sort=', element2-name)"/>
</xsl:attribute>
</xsl:element>


--

Martin Honnen
http://JavaScript.FAQTs.com/
  #5  
Old December 11th, 2006, 05:15 PM
bcochofel
Guest
 
Posts: n/a
Default Re: XSLT sorting

I'm using HTML::Template to generate my XML file (template.xml) Under
that template I have a reference for a local XSL. This is the only way
I know... I'm new to XML...

On Dec 11, 5:33 pm, Martin Honnen <mahotr...@yahoo.dewrote:
Quote:
bcochofel wrote:
Quote:
Well, I'm using Perl CGI to generate the XML on the server-side. On the
XML I have the query params from the script, so I was wondering if I
can use this params to sort within the XSL?Do you run the XSLT transformation on the server with Perl too? Or do
you rely on the browser doing the XSLT transformation?
>
Quote:
Also, I can I create an url with the value of some elements from my
XML?
Something like (on my xsl file), <a href="listsites.cgi?field=<xml
element value here>&sort=<xml element value here>">sites</a>...Use attribute value templates e.g.
<a href="listsites.cgi?field={element-name}&amp;sort={element2-name}">
or xsl:attribute
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="concat('listsites.cgi?field=', element-name,
'&amp;sort=', element2-name)"/>
</xsl:attribute>
</xsl:element>
>
--
>
Martin Honnen
http://JavaScript.FAQTs.com/
  #6  
Old December 11th, 2006, 05:15 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: XSLT sorting

bcochofel wrote:
Quote:
I'm using HTML::Template to generate my XML file (template.xml) Under
that template I have a reference for a local XSL. This is the only way
I know... I'm new to XML...
I don't use Perl, you will have to ask in a Perl group or wait whether
someone here comes along that can help with that Perl package.


--

Martin Honnen
http://JavaScript.FAQTs.com/
  #7  
Old December 11th, 2006, 05:29 PM
bcochofel
Guest
 
Posts: n/a
Default Re: XSLT sorting

It's the same as having a XML file and ref to a local XSL.
The Perl package creates the XML file and on the browser apears the
context...
If I don't put the line: <?xml-stylesheet type="text/xml"
href="RR.xsl"?>
I get pure XML on the browser.

On Dec 11, 5:41 pm, Martin Honnen <mahotr...@yahoo.dewrote:
Quote:
bcochofel wrote:
Quote:
I'm using HTML::Template to generate my XML file (template.xml) Under
that template I have a reference for a local XSL. This is the only way
I know... I'm new to XML...I don't use Perl, you will have to ask in a Perl group or wait whether
someone here comes along that can help with that Perl package.
>
--
>
Martin Honnen
http://JavaScript.FAQTs.com/
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles