I'm having issues sorting. The short description is, how do I set the
select attribute of xsl:sort to be the value of an xsl:variable? The
longer description follows:
What I want to do is to be able to make a data table sortable by
different headers. Right now, I've got javascript that lets you click
on a column header, and then it changes the DOM of the xsl file
(changes the select attribute of the xsl:sort element) and reapplies
the stylesheet to the xml file, and presents the newly resorted data.
However, the xpath for the select attribute gets ugly.
This is what it looks like now:
<xsl:sort select="item[key='main_conta ct']/value"/>
So my javascript is:
var sort_node=this. xslStylesheet.g etElementsByTag Name("sort").it em(0);
sort_xpath="ite m[key='" + my_sort_param + "']/value";//ugly, JS has to
know a lot about xpath
sort_node.setAt tribute("select ",sort_xpat h);
I'd rather my javascript be more like:
var
sort_param_node =this.xslStyles heet.getElement sByTagName("var iable").item(0) ;
sort_node.setAt tribute("select ",my_sort_param ); //prettier, JS just
knows a sort key, not the whole xpath
And so I think my xsl should be:
<xsl:variable name="sort_para m" select="'main_c ontact'"/>
<xsl:sort select="item[key='$sort_para m']/value"/>
But that doesn't work. I can't even get this to work:
<xsl:variable name="sort_para m"
select="item[key='main_conta ct']/value"/>
<xsl:sort select="$sort_p aram"/>
I'm pretty confused at this point. I'm not sure where I'm going wrong.
It could be syntax, it might be misunderstandin g how the variable works
with string literals vs element tree fragments, or...something else.
Any help is appreciated, thanks,
-John 2 2878
So apparently this does work afterall:
<xsl:variable name="sort_para m" select="'name'"/>
<xsl:sort select="item[key=$sort_param]/value" />
Though I tried something like this first, and it blew up. Oh well,
problem solved for now,
-John jo******@gmail. com wrote:
I'm having issues sorting. The short description is, how do I set the
select attribute of xsl:sort to be the value of an xsl:variable? The
longer description follows:
What I want to do is to be able to make a data table sortable by
different headers. Right now, I've got javascript that lets you click
on a column header, and then it changes the DOM of the xsl file
(changes the select attribute of the xsl:sort element) and reapplies
the stylesheet to the xml file, and presents the newly resorted data.
However, the xpath for the select attribute gets ugly.
This is what it looks like now:
<xsl:sort select="item[key='main_conta ct']/value"/>
So my javascript is:
var sort_node=this. xslStylesheet.g etElementsByTag Name("sort").it em(0);
sort_xpath="ite m[key='" + my_sort_param + "']/value";//ugly, JS has to
know a lot about xpath
sort_node.setAt tribute("select ",sort_xpat h);
I'd rather my javascript be more like:
var
sort_param_node =this.xslStyles heet.getElement sByTagName("var iable").item(0) ;
sort_node.setAt tribute("select ",my_sort_param ); //prettier, JS just
knows a sort key, not the whole xpath
And so I think my xsl should be:
<xsl:variable name="sort_para m" select="'main_c ontact'"/>
<xsl:sort select="item[key='$sort_para m']/value"/>
But that doesn't work. I can't even get this to work:
<xsl:variable name="sort_para m"
select="item[key='main_conta ct']/value"/>
<xsl:sort select="$sort_p aram"/>
I'm pretty confused at this point. I'm not sure where I'm going wrong.
It could be syntax, it might be misunderstandin g how the variable works
with string literals vs element tree fragments, or...something else.
Any help is appreciated, thanks,
-John
jo******@gmail. com wrote:
And so I think my xsl should be:
<xsl:variable name="sort_para m" select="'main_c ontact'"/>
<xsl:sort select="item[key='$sort_para m']/value"/>
You would need
<xsl:sort select="item[key=$sort_param]/value"/>
to have $sort_param interpreted as a variable. Your '$sort_param' is
simply a string literal which contains the text '$sort_param'.
And instead of using an xsl:variable and manipulating the stylesheet you
should use a top level
<xsl:param name="sort_para m" select="'main_c ontact'"/>
and then use the API your XSLT processor exposes to script to set that
parameter as needed.
Mozilla's API is described here:
<http://developer.mozil la.org/en/docs/Using_the_Mozil la_JavaScript_i nterface_to_XSL _Transformation s>
Opera 9 uses the same API.
--
Martin Honnen http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jarle Presttun |
last post by:
Hi,
Sometimes I display values by combining information from different
sections in the xml, like I do with gradeText in the student template
bellow. Is it possible to sort on gradeText when I loop over students,
as shown in the example? If not, I would have to modify some sql's.
Thanks, Jarle.
XML:
|
by: Derek Tinney |
last post by:
Hi,
I'm having difficulty building an XLST file that allows me to sort a list of
log records. I put together an XSL file that allows me to output a copy of
the input file and then I attempted to sort it. Eventually I want to filter
it based on the "when" element (and/or others) but I cannot proceed until I
get the sort to work. I have tried several approaches (specific XPATHs,
data-type on the sort) none of which have worked (or have...
|
by: Tjerk Wolterink |
last post by:
I posted my problem earlier, but i simplified the examples,
and i know what the cause of the problem is, but i dont know the solution,
my xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="datastyle.xsl"?>
<data xmlns="http://tjerk.com">
<item>a1</item>
<item>b2</item>
|
by: Mark Miller |
last post by:
I have a scheduled job that uses different XSL templates to transform XML
and save it to disk. I am having problems with the code below. The problem
shows up on both my development machine (Windows XP Pro SP 1, .Net Framework
1.1) and on our production server (Windows 2K SP 4, .Net Framework 1.1). I
have simplified the code and data to isolate the problem. When I use the
xsl:strip-space (Line 12) declaration in conjunction with the xsl:sort...
|
by: aerotops |
last post by:
Hi,
I am trying to sort something using XSLT. I am going to give examples.
Original.xml
<Root>
<Car>
<Name>Ford</Name>
<DealerRating>3</DealerRating>
| |
by: Nicolas |
last post by:
Hi,
I've been working on this problem for a couple of days and now i have no
more ideas.
first, this problem only happens with jdk 1.5, everything was fine with
jdk1.4.
I'm using a function to calculate the maximum value of some nodes passed
as argument, which i found here :
|
by: William Krick |
last post by:
I am writing an XSL transform that converts XML data about vehicles
into XML data that will fill printed forms.
The default form can handle up to 5 vehicles which I handle using
subscripts...
<xsl:for-each select="VEHICLE">
<!-- spit out some stuff about this vehicle -->
</xsl:for-each>
<xsl:for-each select="VEHICLE">
|
by: ajc308 |
last post by:
I have an XML document that looks like the following:
<root name="PlanRepository">
<directory name="connoraj">
<directory name="single_run1">
<file>insidebox.txt</file>
<file>outsidebox.txt</file>
<directory name="SAFE_Input">
<file>leapseconds.txt</file>
|
by: otis |
last post by:
Hi all,
This is a small issue to make things prettier, but we all know how important that can be!
I had an xsl:if to check if a node was the last one in a collection of nodes and if it was a horizontal divider would not be displayed underneath it. This worked a treat but now I'm trying to sort my data using xsl:sort. The if statement technically still works but now the node identified by last() could be anywhere in the output order. I only...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |