Re: [xsl] Not able to work further with templates...match..

Subject: Re: [xsl] Not able to work further with templates...match..
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 23 Dec 2000 20:10:02 +0000
Sachi,

> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transforml";
>                 version="1.0"
>                 xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>                 xmlns:user="http://mycompany.com/mynamespace";>

The XSLT namespace needs to be 'http://www.w3.org/1999/XSL/Transform'
- there's no 'l' at the end.

You also have problems in the stylesheet because you have result
elements outside the xsl:templates that you're defining.  Putting this
right makes your stylesheet look something like:

<xsl:template match="/">
  <HTML>
    <HEAD>
      <TITLE>menu</TITLE>
      <LINK rel="stylesheet" type="text/css" href="DIMStyle.css"/>
    </HEAD>
    <body class="MenuBody">
      <div CLASS="inner" STYLE="width:100%; height:100%;">
        <div CLASS="theMenu" ID="theMenu">
          <h1><xsl:value-of select="//topFolderOut/test"/></h1>
          <xsl:apply-templates />
        </div>
      </div>
      <div ID="theMenuUp" CLASS="scrollButtonOut"
           TITLE="Click to move the menu down">
        <img SRC="/images/menuUp.gif"/>
      </div>
      <div ID="theMenuDown" CLASS="scrollButtonOut"
           TITLE="Click to move the menu up">
        <img SRC="/images/menuDown.gif"/>
      </div>
    </body>
  </HTML>
</xsl:template>

<xsl:template match="topFolderOut">
  <div CLASS="topFolderOut" TARGET="right">
    <xsl:attribute name="ID"><xsl:value-of select="@ID"/></xsl:attribute>
    <xsl:attribute name="HREF"><xsl:value-of select="@URL"/></xsl:attribute>
    <xsl:attribute name="TITLE"><xsl:value-of select="@Title"/></xsl:attribute>
  </div>
</xsl:template>

[This second template could also look like:

<xsl:template match="topFolderOut">
  <div CLASS="topFolderOut" TARGET="right"
       ID="{@ID}" HREF="{@URL}" TITLE="{@Title}" />
</xsl:template>

with the same effect.]

I doubt this will give you the results that you're after, however.
In the root-matching template (the first one above), you have an h1
heading with a content being the value of the first 'test' element
under a 'topFolderOut' element.  It doesn't look like you have a
'test' element under a 'topFolderOut' element in your source XML, so
no content will be given.  Another problem is that none of the content
of the 'topFolderOut' elements will be processed because the
topFolderOut-matching template (the second one above) doesn't put any
content within the 'div'.  You probably want to have
xsl:apply-templates in there somewhere.

Nevertheless, the main problems were the XSLT namespace and the
general structure of the stylesheet, so hopefully the small problems
mentioned above will be relatively easy to fix.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread