Linking an stylesheet outside the XML instance

L

leosarasua

One of the great things about XML, I find, is that you can do lots of
things with an XML instance without modifying it. You can have any
kind of processing and displaying by writing a stylesheet separate
from the XML document.

However, the reference to the stylesheet has to be in the XML
document, which already forces you to modify it every time you want to
use a different XSL.This is really inconvenient: in my case, I have a
huge database of XML documents, and I need to process them with
different XSL's depending on the application. Obviously, I don't want
to modify all the XML documents each time.

My question is: what was the reason to design the use of XSL like
this?

Couldn't the XSL be chosen, for example, in the XML processor (i.e.
the browser)? Another possibility: the XSL reference in the XML
document is optional, and if it is missing then it is chosen the first
XSL file in the same directory of the XML document.

Would this be workable? And if so, does anyone know a reason why it
wasn't designed like this?
 
M

Martin Honnen

One of the great things about XML, I find, is that you can do lots of
things with an XML instance without modifying it. You can have any
kind of processing and displaying by writing a stylesheet separate
from the XML document.

However, the reference to the stylesheet has to be in the XML
document, which already forces you to modify it every time you want to
use a different XSL.This is really inconvenient: in my case, I have a
huge database of XML documents, and I need to process them with
different XSL's depending on the application. Obviously, I don't want
to modify all the XML documents each time.

My question is: what was the reason to design the use of XSL like
this?

Couldn't the XSL be chosen, for example, in the XML processor (i.e.
the browser)?

You are right that client-side XSLT in the browser, where you want to
load the XML document in a browser window, depends on the xml-stylesheet
processing instruction. But XSLT in general does not, rather you have an
XSLT processor that has a command line feature to select both XML and
XSLT document and/or the processor has an API you can use to provide XML
and XSLT document. Even inside the browser XSLT processors have an API
exposed to script, for Mozilla, Opera 9 and Safari 3 see
<URL:http://developer.mozilla.org/en/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations>,
for IE 6 and later see
<URL:http://msdn2.microsoft.com/en-us/library/ms762799.aspx>
 
M

Martin Honnen

However, the reference to the stylesheet has to be in the XML
document, which already forces you to modify it every time you want to
use a different XSL.This is really inconvenient: in my case, I have a
huge database of XML documents, and I need to process them with
different XSL's depending on the application. Obviously, I don't want
to modify all the XML documents each time.

My question is: what was the reason to design the use of XSL like
this?

Also note that the specification of xml-stylesheet
<URL:http://www.w3.org/TR/xml-stylesheet/> allows for several of those
processing instruction to provide alternate stylesheet, only the major
browsers like Mozilla or IE do not implement that for XSLT stylesheets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top