Passing parameters to XSLT style sheets
Passing parameters to XSLT style sheets
We can pass parameter for transformation using jQuery as :
<script type="text/javascript">
$(function() {
// For display purposes only
$.ajax({
url: 'xslt-test.xml',
dataType: 'html',
success: function(data) {
$('#xmldata').text(data);
}
});
$.ajax({
url: 'xslt-test.xsl',
dataType: 'html',
success: function(data) {
$('#xsldata').text(data);
}
});
// The transformation
$('#output').xslt({xmlUrl: 'xslt-test.xml', xslUrl: 'xslt-test.xsl'});
});
</script>
The above code is used to set the xml/ xsl in the display window using
jQuery.
After setting display, The xml and xsl is passed as parameters to the function '.xslt( )' for transformation under the variable 'xmlUrl' and 'xslUrl' respectively. This will transform the output into text string and display output in the div element 'output'.
Learn from experts! Attend jQuery Training classes.