Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add default xml in stylesheet??

Status
Not open for further replies.

mgriffith

MIS
Jul 3, 2001
177
US
i have a stylesheet that renders my different xml menus. my xml menus are set up like this
<navmenu>
<menu>menu1
<menuitem href=&quot;blah.htm&quot;>whatever</menuitem>
<menuitem href=&quot;blah.htm&quot;>whatever</menuitem>
<menuitem href=&quot;blah.htm&quot;>whatever</menuitem>
</menu>
<menu>menu2
<menuitem href=&quot;blah.htm&quot;>whatever</menuitem>
<menuitem href=&quot;blah.htm&quot;>whatever</menuitem>
<menuitem href=&quot;blah.htm&quot;>whatever</menuitem>
</menu>
</navmenu>

is there a way to include some default menus and menuitems in my stylesheet so that they get parsed ahead of the xml and then appear on top, or would i have to include the global stuff in each xml file?
 
Hi mgriffith,

There's no reason to add the general stuff in your xml. You could something like this:

Code:
<?xml version=&quot;1.0&quot;  encoding=&quot;utf-8&quot;?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform&quot;[/URL] xmlns:fo=&quot;[URL unfurl="true"]http://www.w3.org/1999/XSL/Format&quot;>[/URL]

  <xsl:template match=&quot;/&quot;>
    <xsl:apply-templates select=&quot;navmenu&quot;/>
  </xsl:template>

  <xsl:template match=&quot;navmenu&quot;>
    <!-- put the global stuff here, I've put some html
    here, you can put your global menu html or whatever
    here -->

    <html>
    <head>
    <title>Testpage</title>
    </head>
    <body>
       <xsl:apply-templates select=&quot;menu&quot;/>
    </body>     
    </html>
  </xsl:template>

  <xsl:template match=&quot;menu&quot;>
    <!-- Put the html and xsl codes for each menu node in 
    your xml data here -->
  </xsl:template>
</xsl:stylesheet>


Good luck!!

Jordi Reineman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top