[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: passing values from JavaScript to XSL using MSXML3

Subject: RE: passing values from JavaScript to XSL using MSXML3
From: "bryan" <bry@xxxxxxxxxx>
Date: Tue, 22 Jul 2003 09:59:45 +0200
xsl sort javascript


[Neil and Bryan, thanks for the help. But I am still confused about the
best
way of doing what I'm tring to accompish. Here is what it is: I have two
sort options, a menu and radio buttons, that are supposed make the XML
data
be sorted according to any specified tag and acend or decend. I am sure
this
comes up often, but I don't know if there is a good solution for it.
Another
thing to note is that I do my transformation on the server-side with
PHP. I
have some questions. How is it possible to use the <xml:param> element
inside <xsl:template match="/">? and Why can't you just do something
like
this: <xml:param name="sortBy"><input name="sortOrderButton"
type="radio"
value="ascending">Ascending</input></xml:param>, that is after you
manage it
to get it inside <xsl:template match="/">?
So if this all doen't work out I am just going to stick to
<msxsl:script>
]

you can't have xsl:sort as a child of xsl:template.

You can have it apply to xsl:for-each and xsl:apply-templates.

So (I can't remember the original thing you were trying to do so here's
an example)
<xsl:template match="/">
<result>
<xsl:for-each select="/Mabinogion/event">
<xsl:sort select="date" order="descending" />
<xsl:value-of select="."/>
</xsl:for-each></result>
</xsl:template>

here's a reasonable intro to sorting in xslt:
http://www.xml.com/pub/a/2002/07/03/transform.html


the reason why you can't do the above is that the xslt just outputs a
result tree, there's no way to pass in user input in the transformation
unless you build that way. So what you would do is to have the following
process:

application gets xml passes to xslt, xslt outputs form, form posts back
to application, application passes in relevant data to xslt as
parameters.

Obviously it could be done without a post, but you would have to use the
normal ways to get form data without a post, such as calling a
javascript function to read the form data. 

Lets say you want to build your sort dynamically, you could have the
following:

<xsl:param name="sortthis"/>
<!--sortthis is the parameter being sent in by the application, it will
be either 'date' or 'type'-->

<xsl:template match="/">
<result>
<xsl:for-each select="/Mabinogion/event">
<xsl:sort select="*[name() = $sortthis]" order="descending" />
<xsl:value-of select="."/>
</xsl:for-each>
</result>
</xsl:template>

commonly I prefer to pass values contained in the querystring rather
than in post data, I guess I just like get. 






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.