Hi All, I need to manipulate a XML string which is thrown by server with XSL reference embedded. I need to insert a piece of Code written in JavaScript to my XSL file to traverse the string to match an existing string of data with one at a node and collect the chaild nodes of the same. Please note that I have a XML string in the memory. ------------------
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
posted
0
Sounds complicated... My friend�s karate instructor used to say: "if you do something and it is difficult, know: you do it wrong. It shouldn�t be difficult". Perhaps you should formulate what you want not in terms if "JavaScript" and "XSLT", but in terms of your goals: what do you want to get? If you want to select all nodes with specific name you can pass it in XSLT as a parameter and then select all matching nodes with expression select="*[name(.)=$parameter]" You do not need JavaScript to do it. "XML string which is thrown by server with XSL reference embedded" � you mean that you have both XML and XSLT written, and you want somehow modify XSLT to get the result other, than it produces? Then it is easier to simply apply another XSLT. I believe you can call XSLT stylesheet dynamically in IE, even if XML document specifies one.
Originally posted by Mapraputa Is: Sounds complicated... My friend�s karate instructor used to say: "if you do something and it is difficult, know: you do it wrong. It shouldn�t be difficult". Perhaps you should formulate what you want not in terms if "JavaScript" and "XSLT", but in terms of your goals: what do you want to get? If you want to select all nodes with specific name you can pass it in XSLT as a parameter and then select all matching nodes with expression select="*[name(.)=$parameter]" You do not need JavaScript to do it. "XML string which is thrown by server with XSL reference embedded" � you mean that you have both XML and XSLT written, and you want somehow modify XSLT to get the result other, than it produces? Then it is easier to simply apply another XSLT. I believe you can call XSLT stylesheet dynamically in IE, even if XML document specifies one.
My friend, Thanks for ur suggestion. I have no idea how I can dynamically call another XSLT in IE. I can't modify the XML formatted string as it is coming from server. So I have only one XSL which has its reference in XML and I need to modify the same. So please suggest some way if not JavaScript to get the work done.
------------------
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
posted
0
Here is a working example how XSLT can be applied dynamically. (all code is in control.htm It should be something like: source = new ActiveXObject("Microsoft.XMLDOM"); source.async = false; style = new ActiveXObject("Microsoft.XMLDOM"); style.async = false; source.load(�myXML.xml�); style.load (�myXSLT.xsl�); source.transformNode(style); you can use their JavaScript as a prototype
subject: Manipulating XML string using JavaScript in XSL