Subject: RE: [xsl] passing values from JavaScript to XSL using MSXML3 From: "bryan" <bry@xxxxxxxxxx> Date: Tue, 22 Jul 2003 09:59:45 +0200 |
[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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] passing values from JavaS, Sergey Demidenko | Thread | [xsl] A more complicated Muenchian , Greg Johnson |
[xsl] printing the input xml witha , Peter_Ivan | Date | RE: [xsl] Ho do you format arbitrar, David . Pawson |
Month |