Accessing XSL inside jQuery

I may be asking a very basic question. I searched many posts but didn't find correct information. Please point me in the right direction.

Below is my scenario. I am using jQuery/Javascript, HTML, XSL.

I have some sample data in XML. The structure of the data looks like this

    <!-- ... --->

I have table which d1isplays some of this information in a table which has a hyperlink/button "EDIT". So when user clicks on the edit button in the table, I need to populate the data in the textboxes/radio buttons, i have that in the XSL format.

I attached sample drawing of my screen:

I'm not sure how to access the XSL in jQuery or Javascript. In html i was ablt to access, for example i'm iterating it like this.

<xsl:for-each select="/<xsl:for-each select="/information/qContact">">

<xsl:value-of select="name"/>

Here I have list of XSL nodes, i need one of them , suppose when user clicks on the mike row, I need to get the mike properties from XSL and set them in the text boxes.

Is it doable?

  1. accessing the XSL in jQuery

  2. iterating through the particular node in this case <qContact> (and then getting name,email,phone etc)?

Please help me.

Some more Information:

1) I use Html to create different fields[text, radio buttons etc]

2)When i save the data in database and when reloading the form, i put that data in XSL and access it in the html page.


<td><input id="empName" type="text" name="name" value="{/information/qContact/name}" /></td>

3) I can access it inside jquery also.


 console.log("<xsl:value-of select="/information/qContact/name>");

Problem Scenario:

<xsl:for-each select="/information/qContact">

<a href="#" onclick="edit('Generated','{ID}','{current()}');event.returnValue=false; return false;">Edit</a>


function edit(name,id,selectData){
                    console.log(selectData); // This is printing all the data inside it.
                    console.log("<xsl:value-of select="/information/name"/>"); // Not able to access like this
                    $('#name').val('<xsl:value-of select="/information/qContact/name"/>');// Not able to access like this
                    $('#email').val('<xsl:value-of select="/information/qContact/email"/>');// Not able to access like this



The Question title is Accessing XSL inside jQuery The short answer is: You can't. You can execute xslt with transformNode (depending on browser).

But this is not really what you like to do. Keep in mind that there are three step involved.

  • loading xml and xsl and generating html (with JS)
  • loading (interpreting the generated html) - The xml and xslt is not accessible any more (at least not like you do).
  • execute the onclick handler

Your generated link will look something like:

   < a href="#" onclick="edit('Generated','','
  ');event.returnValue=false; return false;">Edit</a>

Therefor you need to generate a html or JavaScript representation of the required data.

For example generate a JS object with name {name: 'TOM'}:

<a href="#" 
       onclick="edit('Generated','{ID}',{{ name: '{name}' }});event.returnValue=false; return false;">Edit</a>

Need Your Help

Sort booleans, O(N) time, O(1) space

algorithm sorting boolean

For a homework assignment, I am asked to sort an array of bools using a method that uses O(1) space, and O(N) time complexity. Can any hints be offered? I was thinking of something along the pivot ...