have a stylesheet generate another stylesheet based on XML?

Discussion in 'XML' started by Steven An, Nov 23, 2004.

  1. Steven An

    Steven An Guest

    I'm gonna describe the situation I'm dealing with..but if you're not
    interested, just skip to the last line where I bluntly ask my question

    Here's my scenario: I've got a huge website that has many pages.
    Each page has its own content (which changes often). So I wanna use
    XSLT stylesheets to create these pages (so I can modify the appearance
    of the whole site easily). So that's pretty straightforward: one XML
    file per page, with a common stylesheet for them all.

    However, each page also has a navigation menu. This menu should look
    the same for all pages. You may think..just put the navigation menu
    in the page stylesheet! But..what if I want to use XSLT to create
    this menu as well? Because say I have a LOT of items in this menu and
    they all need to have a common style (that I want to be easily

    One solution is that I could put the menu data in with each page XML,
    and thus have the page stylesheet create the menus and the page..but
    this seems wasteful for many reasons. So here's the solution I'd like
    to use: I have a stylsheet which takes in the menu XML and then
    outputs ANOTHER stylesheet that transforms my page data. So the
    latter stylesheet would have all the generated menu HTML in it

    The question: How do I have a stylesheet output a stylesheet (based on
    XML input)? I've tried using CDATA, but that's really messy and
    doesn't quite work (I get a lot of & gt;'s and what not). Or is there
    a better way to deal with my situation (which I'm sure is not

    Any advice would be appreciated,
    Steven An, Nov 23, 2004
    1. Advertisements

  2. Steven An wrote:

    Use a namespace alias e.g.

    <xsl:namespace-alias stylesheet-prefix="xso"
    result-prefix="xsl" />

    <xsl:template match="/">
    <xso:stylesheet ...>
    Martin Honnen, Nov 23, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.