Question

I've applied a stylesheet to an xml document using <?xsl-stylesheet ...>, this works great when the XML is being viewed in my application. But if the xml is exported, I want the XML to still render as plain XML, is it possible to have the stylesheet as optional rather than it producing this error when style is not found:

Error loading stylesheet: A network error occured loading an XSLT stylesheet:

Was it helpful?

Solution

The only solution is to remove the xml-stylesheet during the export sadly.

OTHER TIPS

(I know ti's an old question, but it begs for an update)

It's generally not a good idea to use the xsl-stylesheet processing instruction in XML, because of its limited applicability and because you're binding the view to the data. While you could make it dynamic by having your web server return a different stylesheet depending on where the request comes from, this is not ideal.

Instead, in your application, use any available XSLT processor and process the XML prior to showing it in the viewer. This is simple to build and maintain and has the added benefit that the view (the XSLT) is separate from the data (the XML). When viewing the XML normally, it will not have the PI anymore and will be shown as regular XML.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top