Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT sorting

Reply
Thread Tools

XSLT sorting

 
 
bcochofel
Guest
Posts: n/a
 
      12-11-2006
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:
Code:
---------------------------------------------------------------------------------
    <sites>
    <!--
	  Site url: required (pattern: (https?|ftp)://.+)
	  Tag name: required
	  Tag weight: integer optional
    -->
      <site url="http://www.google.com">
        <tag name="pesquisa" weight="30" />
        <tag name="procura" weight="30" />
      </site>
      <site url="http://www.google.com/webhp?complete=1">
        <tag name="ajax" weight="25" />
        <tag name="pesquisa" weight="30" />
        <tag name="procura" weight="30" />
      </site>
      <site url="https://webmail.fe.up.pt">
        <tag name="email" weight="20" />
        <tag name="feup" weight="20" />
      </site>
    </sites>
--------------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      12-11-2006
bcochofel wrote:

> 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/
 
Reply With Quote
 
 
 
 
bcochofel
Guest
Posts: n/a
 
      12-11-2006
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 <(E-Mail Removed)> wrote:
> bcochofel wrote:
> > 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/


 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      12-11-2006
bcochofel wrote:
> 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?

> 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/
 
Reply With Quote
 
bcochofel
Guest
Posts: n/a
 
      12-11-2006
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 <(E-Mail Removed)> wrote:
> bcochofel wrote:
> > 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?
>
> > 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/


 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      12-11-2006
bcochofel wrote:
> 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/
 
Reply With Quote
 
bcochofel
Guest
Posts: n/a
 
      12-11-2006
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 <(E-Mail Removed)> wrote:
> bcochofel wrote:
> > 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/


 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting list vs sorting vector boltar2003@boltar.world C++ 2 07-06-2010 09:40 AM
fired event Sorting which wasn't handled - sorting and SelectedIndexChanged Jason ASP .Net Web Controls 0 10-04-2006 02:19 PM
XSLT: sorting and grouping Christian Ludwig XML 2 11-26-2003 10:37 AM
sorting by multiple criterias (sub-sorting) Tom Kirchner Perl Misc 3 10-11-2003 05:16 PM
xslt: sorting on the client side - cross browser! Ben Fitzgerald XML 6 10-03-2003 09:46 PM



Advertisments