Apply XSL to External XML

前端 未结 5 815
南旧
南旧 2020-12-28 08:54

Currently I use:


To link XSL to XML.

If my xml was here: www.externald

5条回答
  •  生来不讨喜
    2020-12-28 09:18

    You can't achieve this with "pure" xml+xslt(*). Some external code will need to identify the xml and the xslt which should transform it.

    Since you seem to be transforming XML, I'm going to guess you're doing this in the webbrowser.

    You can do this using javascript, as demonstrated on w3schools. However, cross-domain restrictions still apply if you're doing javascript-based requests (i.e. AJAX/XHR): if the originating server doesn't set the appropriate CORS headers to allow cross-domain javascript access, you'll need to proxy that xml request via your own server.

    (*): Mad's answer uses entity references to cleverly embed external xml in a containing document. It's definitely worth a try, but be aware that this kind of entity-based inclusion has been used in several information-disclosure leaks, which is why it's often not enabled in the xml parser (in particular, this shouldn't be able to subvert CORS in a browser). You'll just have to try it in your situation.

提交回复
热议问题