Linking an stylesheet outside the XML instance

Discussion in 'XML' started by leosarasua@gmail.com, Dec 14, 2007.

  1. Guest

    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?
     
    , Dec 14, 2007
    #1
    1. Advertising

  2. wrote:
    > 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>


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Dec 15, 2007
    #2
    1. Advertising

  3. wrote:

    > 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.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Dec 15, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

    Stylesheet referanse i stylesheet

    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=, Jul 3, 2004, in forum: XML
    Replies:
    3
    Views:
    602
    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=
    Jul 4, 2004
  2. UndoMiel
    Replies:
    1
    Views:
    427
    Keith M. Corbett
    Sep 21, 2004
  3. Steven An
    Replies:
    1
    Views:
    522
    Martin Honnen
    Nov 23, 2004
  4. David Blickstein
    Replies:
    3
    Views:
    1,066
    David Blickstein
    Aug 2, 2005
  5. David Blickstein
    Replies:
    14
    Views:
    6,405
    Harrie
    Oct 16, 2005
Loading...

Share This Page