简体   繁体   中英

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.

I'm using nginx RTMP module rtmp_stat directive . When I access "/stat" using a browser (ie. Firefox) I can get the transformed result.

However, when access the same URL "/stat" using urlConnection.getInputStream() I actually get the raw XML (before transformation). Why?

I need to programatically get the transformed result directly from the web server, ie. by simply accessing "/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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM