I watched the documentation https://developer.mozilla.org/en-US/docs/Web/API/XSLTProcessor . I use the latest version of Chrome. How to feed the .xsl file specified in the function header, if you know the path to it on the server disk?
1 answer
Because the transformation will be done on the client (which I personally strongly do not recommend doing), then the XML and XSL files should be available to the client. The server can send them via http / https / WebSocket .... The XSLTProcessor.importStylesheet() method takes the Node parameter.
Those. You need
- get xsl file
- Download it to
Document - Give the resulting object to the
importStylesheet
In the link provided by you there is also an example of use.
var myXMLHTTPRequest = new XMLHttpRequest(); myXMLHTTPRequest.open("GET", "example1.xsl", false); myXMLHTTPRequest.send(null); xslStylesheet = myXMLHTTPRequest.responseXML; xsltProcessor.importStylesheet(xslStylesheet); - open false - fuuuuuuu - Qwertiy ♦
- @Qwertiy the person had a specific question. Let's answer in the answer fix asynchrony, support of all browsers and error notifications of proxy servers - Anton Shchyrov
- Asynchrony, which should be there, is screwed in 30 seconds. Why instead learn to do bad? - Qwertiy ♦
- @Qwertiy teach well. And try not to complicate the understanding of the answer - Anton Shchyrov
|