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

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

    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
    uncommon)?

    Any advice would be appreciated,
    Steve
    Steven An, Nov 23, 2004
    #1
    1. Advertising

  2. Steven An wrote:


    > 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
    > uncommon)?


    Use a namespace alias e.g.
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xso="http://www.w3.org/1999/XSL/Transform/Output"
    version="1.0">

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

    <xsl:template match="/">
    <xso:stylesheet ...>
    ...
    <xso:stylesheet>
    </xsl:template>


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 23, 2004
    #2
    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. KBuser
    Replies:
    0
    Views:
    552
    KBuser
    Apr 10, 2006
  2. Andy
    Replies:
    0
    Views:
    525
  3. David Blickstein
    Replies:
    3
    Views:
    1,026
    David Blickstein
    Aug 2, 2005
  4. David Blickstein
    Replies:
    14
    Views:
    6,311
    Harrie
    Oct 16, 2005
  5. Matt
    Replies:
    3
    Views:
    330
    Bob Barrows [MVP]
    Apr 23, 2004
Loading...

Share This Page