henny Posted May 28, 2007 Share Posted May 28, 2007 hello,I've an XML with a lot of data and an XSL to transform this data into HTMLbut I would like to re-use that same XSL with different filter conditionsis it possible to loop over the XSL nodes, find " <xsl:for-each select " and change the filter condition in javascript ?? <xsl:for-each select="nieuws/bericht[>>change at runtime<<]">than I could re-use the same XSL with different filterswould be great !!thx in advance gr. Henny Link to comment Share on other sites More sharing options...
henny Posted May 29, 2007 Author Share Posted May 29, 2007 I've changed my XSL a little bitadded: <xsl:param name="x" select="'default'" />changed: <xsl:for-each select="nieuws/bericht[bookmark = $x]">now I use the following in Javascript to change the param ( bookmark ) after I've loaded the XSLbefore transforming the XML ( using the XSL ) into HTML var xsl = new ActiveXObject( "Microsoft.XMLDOM" ); xsl.async = false xsl.load( sourceXSL ); var xParam = xsl.selectSingleNode( "/*/xsl:param[@name = \'x\']/@select" );xParam.value = bookmark; in IE this works finethe equivalent Firefox code doesn't seem to like selectSingleNode() var xsl = document.implementation.createDocument( "", "", null );xsl.async = false xsl.load( sourceXSL ); var xParam = xsl.selectSingleNode( "/*/xsl:param[@name = \'x\']/@select" );xParam.value = bookmark; any workaround/suggestions ??thx in advance gr. Henny Link to comment Share on other sites More sharing options...
boen_robot Posted May 29, 2007 Share Posted May 29, 2007 If you're going to use xsl:param, you don't need to find the node like that. JS APIs for XSLT transformations have their own ways to change the value of parameters. this post shows a function that, when placed inside an XSLT file invoked from the client side, can change the parameter when called. Link to comment Share on other sites More sharing options...
henny Posted May 29, 2007 Author Share Posted May 29, 2007 thx for the feedback, but I don't know if I get your pointlet me explain my workflow I've an HTML-page with my news archive - just some short lines of text ( from XML created by XSL ) with a hyperlink for each article for more info this hyperlink starts a javascript function ( openWinXML ) with the ID ( called bookmark ) of the news article as parameter this javascript-function ( openWinXML ) opens a new browser window and should display the full article ( again from XML created by an other XSL ) what I was trying to do in that javascript-function is to modify a parameter in the XSL-structurethat give me the correct filter in: <xsl:for-each select="nieuws/bericht[bookmark = $x]"> and displays the selected article in the popup windowBTW: this works only in IE and locally - not on my webserver and not on FF your suggestion is to do this from within the XSLbut I don't understand how I get the ID ( called bookmark ) from therebecause that's a parameter for the javascript function ( openWinXML )can you pls give some more hints - thx in advance - Henny Link to comment Share on other sites More sharing options...
boen_robot Posted May 30, 2007 Share Posted May 30, 2007 Well, the real deal is not to use the JS within XSLT. The real deal is to use existing JS objects that were especially made to change parameter values, rather then looking for the xsl:param element with DOM and change it's value.It's more of a JS issue in other words. And I'm not very good with JavaScript, so I can't assist you any further, other then show you that other script. If you're good enough with JS yourself, you should be able to tweak the script to work from the HTML page. Link to comment Share on other sites More sharing options...
henny Posted June 1, 2007 Author Share Posted June 1, 2007 OK thxI've found some javascript for both IE and FF that does the job correctlyonly for IE I need MSXML v4.0 - but I test if that's installed, otherwise download & install the .cab-filehappy for nowspeak to you later !! Link to comment Share on other sites More sharing options...
boen_robot Posted June 1, 2007 Share Posted June 1, 2007 A Microsoft article I read recently (don't have the link though) reccomends that you test for MSXML 6.0 instead and fallback to MSXML 3.0 only. MSXML 4 is only made for office and it's not maintained. MSXML 6.0 includes all latest impovements, while MSXML 3.0 is the most deployed and only security updates are available for it. Link to comment Share on other sites More sharing options...
henny Posted June 1, 2007 Author Share Posted June 1, 2007 oh dearwill goto msdn to find out& maybe you're right v6.0 is betterI'll update you when I've made up my mind Link to comment Share on other sites More sharing options...
henny Posted June 1, 2007 Author Share Posted June 1, 2007 I found this artikel http://blogs.msdn.com/xmlteam/archive/2007...ill-bit-ed.aspxleft v4.0 & back to v3.0 for now ;-) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.