[英]How to load a transformed XML (based on a XSL stylesheet) using Java?
I don't understand why the XSL stylesheet isn't applied when I use Java's urlConnection.getInputStream() method. 我不明白为什么使用Java的urlConnection.getInputStream()方法时未应用XSL样式表。
I'm using nginx RTMP module rtmp_stat directive . 我正在使用nginx RTMP模块rtmp_stat指令 。 When I access "/stat" using a browser (ie. Firefox) I can get the transformed result.
当我使用浏览器(例如Firefox)访问“ / stat”时,可以获得转换后的结果。
However, when access the same URL "/stat" using urlConnection.getInputStream() I actually get the raw XML (before transformation). 但是, 当使用urlConnection.getInputStream()访问相同的URL“ / stat”时,我实际上得到了原始XML(在转换之前)。 Why?
为什么?
I need to programatically get the transformed result directly from the web server, ie. 我需要以编程方式直接从Web服务器获取转换结果,即。 by simply accessing "/stat".
只需访问“ / stat”即可。 just like the result I get when I use a web browser to access.
就像我使用网络浏览器访问时得到的结果一样。 How can I do this?
我怎样才能做到这一点?
Thanks! 谢谢!
You're expecting getInputStream()
to look at the media type, work out that it's XML, parse the XML, discover that there is an <?xml-stylesheet?>
processing instruction, fetch the stylesheet, apply it, and return the result? 您期望
getInputStream()
查看媒体类型,确定它是XML,解析XML,发现有一个<?xml-stylesheet?>
处理指令,获取样式表,应用它,然后返回结果?
Wishful thinking, I'm afraid. 一厢情愿的想法,恐怕。
If you want to run transformations on the server you'll need to implement some server-side code to achieve it. 如果要在服务器上运行转换,则需要实现一些服务器端代码才能实现。 There may be server-side frameworks where you can just set a switch to achieve this, but it's not going to happen by default.
可能在服务器端框架中,您可以设置开关来实现此目的,但是默认情况下不会发生这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.