[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Can you have a dummy XSL?


Subject: RE: [xsl] Can you have a dummy XSL?
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Thu, 02 Aug 2001 12:35:54 +0200

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



Current Thread
Keywords
xsl