[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Combining static XML with a document

Subject: Combining static XML with a document
From: "Jon Smirl" <jonsmirl@xxxxxxxxxxxx>
Date: Sun, 8 Aug 1999 11:28:38 -0400
static xml
I am having a lot of trouble using XSL to combine an external XML document
with some static data embedded in my stylesheet.  An example of this would
be combining a data file with statically defined headers or in my case I am
generating a page and I want to attach a menu to it.  The headers/menu are
statically defined and then I want to use XSL to style them.

I initially tried to do this by unrolling the arrays of menu items. This
ends up with a kludgy XSL sheet (see attached file) and complicated calls to
the include file:

  <xsl:call-template name="banner">
   <xsl:with-param name="page" select="$page"/>
   <xsl:with-param name="onload" select="string('load()')"/>
   <xsl:with-param name="menu1">Search</xsl:with-param>
   <xsl:with-param name="url1">a</xsl:with-param>
   <xsl:with-param name="menu2">Results</xsl:with-param>
   <xsl:with-param name="url2">b</xsl:with-param>
   <xsl:with-param name="menu3">New</xsl:with-param>
   <xsl:with-param name="url3">c</xsl:with-param>
   <xsl:with-param name="tab" select="$tab"/>
  </xsl:call-template>

After thinking about this for a while I realized that I am actually trying
to merge two documents - the external XML and the static headers.

I can move the menu definition off into another XML file and use document()
to include it (whenever XT gets the document function).  But this brings up
the question, should document() allow an inline XML fragment,
document("<tag>xml goes here</tag>"), instead of only external files?

Jon Smirl
jonsmirl@xxxxxxxxxxxx

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
		default-space="strip"			
		xmlns="http://www.w3.org/TR/REC-html40" result-ns="">
	
  <xsl:template name="banner">
		<xsl:param name="menu1"/>
		<xsl:param name="menu2"/>
		<xsl:param name="menu3"/>
		<xsl:param name="menu4"/>
		<xsl:param name="menu5"/>
		<xsl:param name="menu6"/>
		<xsl:param name="menu7"/>
		<xsl:param name="menu8"/>
		<xsl:param name="url1"/>
		<xsl:param name="url2"/>
		<xsl:param name="url3"/>
		<xsl:param name="url4"/>
		<xsl:param name="url5"/>
		<xsl:param name="url6"/>
		<xsl:param name="url7"/>
		<xsl:param name="url8"/>
		<xsl:param name="tab"/>

		<table class="header" id="header" width="100%">
			<tr><td style="padding-left:2"><table class="menu"><tr>
				<xsl:call-template name="menu-item">
					<xsl:with-param name="menu" select="$menu1"/>
					<xsl:with-param name="url" select="$url1"/>
					<xsl:with-param name="tab" select="$tab"/>
				</xsl:call-template>	
				<xsl:call-template name="menu-item">
					<xsl:with-param name="menu" select="$menu2"/>
					<xsl:with-param name="url" select="$url2"/>
					<xsl:with-param name="tab" select="$tab"/>
				</xsl:call-template>	
				<xsl:call-template name="menu-item">
					<xsl:with-param name="menu" select="$menu3"/>
					<xsl:with-param name="url" select="$url3"/>
					<xsl:with-param name="tab" select="$tab"/>
				</xsl:call-template>	
				<xsl:call-template name="menu-item">
					<xsl:with-param name="menu" select="$menu4"/>
					<xsl:with-param name="url" select="$url4"/>
					<xsl:with-param name="tab" select="$tab"/>
				</xsl:call-template>	
				<xsl:call-template name="menu-item">
					<xsl:with-param name="menu" select="$menu5"/>
					<xsl:with-param name="url" select="$url5"/>
					<xsl:with-param name="tab" select="$tab"/>
				</xsl:call-template>	
				<xsl:call-template name="menu-item">
					<xsl:with-param name="menu" select="$menu6"/>
					<xsl:with-param name="url" select="$url6"/>
					<xsl:with-param name="tab" select="$tab"/>
				</xsl:call-template>	
				<xsl:call-template name="menu-item">
					<xsl:with-param name="menu" select="$menu7"/>
					<xsl:with-param name="url" select="$url7"/>
					<xsl:with-param name="tab" select="$tab"/>
				</xsl:call-template>	
				<xsl:call-template name="menu-item">
					<xsl:with-param name="menu" select="$menu8"/>
					<xsl:with-param name="url" select="$url8"/>
					<xsl:with-param name="tab" select="$tab"/>
				</xsl:call-template>	
				</tr></table>
				</td>
				<td align="right" nowrap="nowrap" width="100%">
					<a class="header" href="../page/home.xml">Acme Corporation</a>
				</td>
			</tr>
		</table>
  </xsl:template>
  
  <xsl:template name="menu-item">
		<xsl:param name="menu"/>
		<xsl:param name="url"/>
		<xsl:param name="tab"/>
		<xsl:if test="$menu != string('')">
			<td class="tab" valign="center">
			<xsl:if test="$menu=$tab">
				<xsl:attribute name="class">selTab</xsl:attribute>
			</xsl:if>
				<a href="{$url}"><xsl:value-of select="$menu"/></a>
			</td>
		</xsl:if>
  </xsl:template>
			
</xsl:stylesheet>
Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.