|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Can you have a dummy XSL?
Hewko, Doug wrote:
> Can you have a XSL that does not do any text formatting or
> processing? I am working on a web page and want to enforce
> a standard look and feel. Part of this standard is a generic
> header title, left bar navigation and footer information. Tables
> would be used to maintain this look and feel. The title,
> left bar and footer will contain text, links and icons. These would
> all be standard.
I really wonder that nobody proposed to use document():
<xsl:tepmlate match="/">
<html>
<head><title>Stuff</title></head>
<body>
<table>
<tr>
<td>
<xsl:copy-of select="document('std.xml')/*/left-bar-navigation">
</td>
<td>
<xsl:apply-templates/>
</td>
</tr>
<tr>
</td>
<xsl:copy-of select="document('std.xml')/*/footer">
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
You may have put the table for the general layout into the template
above. The "std.xml" should be something like
<root>
<left-bar-navigation>
<table>
<tr><th>Navigation</th></tr>
<tr><td><a href="link">link</a></td></tr>
</table>
</left-bar-navigation>
<footer>
.....
</footer
</root>
An interesting alternative may be to use a sort of HTML-template:
File template.xml
<html xmlns:t="your.uri/template">
<head>
<title>
<t:title/>
</title>
</head>
<body>
<table>
<tr>
<td>
<table>
<tr><th>Navigation</th></tr>
<tr><td><a href="link">link</a></td></tr>
</table>
</td>
<td>
<t:content/>
</td>
</tr>
<tr>
</td>
<!-- footer -->
</td>
</tr>
</table>
</body>
</html>
File your.xsl
<xsl:stylesheet
xmlns:xsl="..."
xmlns:t="your.uri/template">
<!-- save input doc -->
<xsl:variable name="doc" select="/"/>
<xsl:template match="/">
<xsl:apply-templates
select="document('template.xml')"
mode="template"/>
</xsl:template>
<!-- important: copy-through template elements -->
<xsl:template match="*|@*|text()" mode="template">
<xsl:copy>
<xsl:apply-templates select="node()|@*"
mode="template"/>
</xsl:copy>
</xsl:template>
<!-- handle HTML title -->
<xsl:template match="t:title" mode="template">
<xsl:apply-templates select="$doc" mode="title"/>
</xsl:template>
<!-- handle HTML content -->
<xsl:template match="t:title" mode="template">
<xsl:apply-templates select="$doc" mode="content"/>
</xsl:template>
<!-- example: retrive title -->
<xsl:template match="/" mode="title">
<xsl:value-of select="/document/docinfo/title"/>
</xsl:template>
<!-- example: usual content handling -->
<xsl:template match="/" mode="content">
<xsl:apply-templates select="$doc"/>
</xsl:template>
<xsl:stylesheet>
(not tested)
HTH
J.Pietschmann
--
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








