using multiple stylesheets with 1 xml file

Discussion in 'XML' started by steve, Nov 20, 2003.

  1. steve

    steve Guest

    I'm new to XML, so pardon the stupid question.

    I've looked thru several books with not luck. All I want to do is
    associate one xml file with multiple xsl stylesheets. For example, if
    the user clicks on Button A, I want to use xsl stylesheeet A to
    display the xml data in a browser. If he clicks button B, then I want
    to use stylesheet B. I would think that this would be a very common
    thing to do, but maybe i'm missing something big.

    Is there an easy way to do this? Do I have to use (learn) Javascript
    or something? does someone have an example?

    your input is appreciated!
     
    steve, Nov 20, 2003
    #1
    1. Advertising

  2. steve

    Andy Dingley Guest

    On 20 Nov 2003 06:50:54 -0800, (steve) wrote:

    >All I want to do is
    >associate one xml file with multiple xsl stylesheets.


    This is easy. Getting it to do something useful is harder !

    You can "associate" multiple stylesheets by using multiple PI's (the
    <?xml-stylesheet ... alternate="yes" ?> business)
    http://www.w3.org/TR/xml-stylesheet/

    Small problem with this is that you can indicate the default with
    alternate="no" (or omitting it) but there's no mechanism to indicate
    precedence or other bindings for alternates. The "media" attribute
    might be adequate for you.


    A larger problem is that this association does not _cause_ the
    stylesheet to be processed. That's the task of the stylesheet
    processor, which is an application-dependent task that's outside the
    scope of the W3C standards.

    If you're on your own web server, then it's pretty easy. parse the
    PI's at the top, invoke the processor accordingly. Write your own
    rules for selecting which one to choose, and just invoke the processor
    accordingly.

    On the client-side browser, then IE (and some others) now process XML
    according to a default stylesheet (but watch out for a "default"
    choice that's merely the first in the list, ignoring the alternate
    attribute).

    If you want alternates to be processed usefully on the client, then
    you're into writing some JavaScript. You may find a "data island"
    approach useful here, loading the page as static HTML with embedded
    XML, then processing it and writing it into a <div>, rather than
    processing the whole XML document into a single output page (which can
    then be hard to retrieve the other PI's)

    --
    Die Gotterspammerung - Junkmail of the Gods
     
    Andy Dingley, Nov 21, 2003
    #2
    1. Advertising

  3. steve

    steve Guest

    thanks - that was extremely helpful..i'm surprise that something this
    "basic" is so difficult!


    Andy Dingley <> wrote in message news:<>...
    > On 20 Nov 2003 06:50:54 -0800, (steve) wrote:
    >
    > >All I want to do is
    > >associate one xml file with multiple xsl stylesheets.

    >
    > This is easy. Getting it to do something useful is harder !
    >
    > You can "associate" multiple stylesheets by using multiple PI's (the
    > <?xml-stylesheet ... alternate="yes" ?> business)
    > http://www.w3.org/TR/xml-stylesheet/
    >
    > Small problem with this is that you can indicate the default with
    > alternate="no" (or omitting it) but there's no mechanism to indicate
    > precedence or other bindings for alternates. The "media" attribute
    > might be adequate for you.
    >
    >
    > A larger problem is that this association does not _cause_ the
    > stylesheet to be processed. That's the task of the stylesheet
    > processor, which is an application-dependent task that's outside the
    > scope of the W3C standards.
    >
    > If you're on your own web server, then it's pretty easy. parse the
    > PI's at the top, invoke the processor accordingly. Write your own
    > rules for selecting which one to choose, and just invoke the processor
    > accordingly.
    >
    > On the client-side browser, then IE (and some others) now process XML
    > according to a default stylesheet (but watch out for a "default"
    > choice that's merely the first in the list, ignoring the alternate
    > attribute).
    >
    > If you want alternates to be processed usefully on the client, then
    > you're into writing some JavaScript. You may find a "data island"
    > approach useful here, loading the page as static HTML with embedded
    > XML, then processing it and writing it into a <div>, rather than
    > processing the whole XML document into a single output page (which can
    > then be hard to retrieve the other PI's)
     
    steve, Nov 24, 2003
    #3
  4. steve

    fips152 Guest

    In article <>,
    (steve) wrote:

    > I'm new to XML, so pardon the stupid question.
    >
    > I've looked thru several books with not luck. All I want to do is
    > associate one xml file with multiple xsl stylesheets. For example, if
    > the user clicks on Button A, I want to use xsl stylesheeet A to
    > display the xml data in a browser. If he clicks button B, then I want
    > to use stylesheet B. I would think that this would be a very common
    > thing to do, but maybe i'm missing something big.
    >
    > Is there an easy way to do this? Do I have to use (learn) Javascript
    > or something? does someone have an example?
    >
    > your input is appreciated!



    Using some very simple CGI to change one line of
    text, "http://www.csszengarden.com/" is a nice
    demo of changing the CSS style sheeet.
     
    fips152, Nov 26, 2003
    #4
  5. steve

    Baldo Guest

    (steve) wrote in message news:<>...

    > Is there an easy way to do this? Do I have to use (learn) Javascript
    > or something? does someone have an example?


    u can use a TOMCAT + jsp + passing variable throught link

    quite easy to say, but very hard to do!
     
    Baldo, Dec 3, 2003
    #5
    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. Dave Higgins
    Replies:
    12
    Views:
    1,018
    Nick Howes
    Nov 22, 2003
  2. jim
    Replies:
    1
    Views:
    754
    Wizfrog
    Jul 24, 2007
  3. Kevin

    multiple xml stylesheets

    Kevin, Mar 5, 2008, in forum: XML
    Replies:
    0
    Views:
    401
    Kevin
    Mar 5, 2008
  4. Kevin

    Multiple stylesheets

    Kevin, Mar 5, 2008, in forum: XML
    Replies:
    0
    Views:
    398
    Kevin
    Mar 5, 2008
  5. Tim W
    Replies:
    4
    Views:
    407
    Tim W
    Dec 14, 2012
Loading...

Share This Page