Re: Storing xpath expressions in a vaiable

Subject: Re: Storing xpath expressions in a vaiable
From: Sridhar_Ramachandran@xxxxxx
Date: Thu, 28 Sep 2000 22:01:31 -0700
Paul and Evan,

Thanks for both your responses. I was able to get what I wanted by using
<xsl:include> and <xsl:call-template>. I created filter_notes.xsl which
contained a bunch of xsl:when under an xsl:choose. Each of these xsl:when
set the value of a parameter to a node-set derived from the appropriate
xpath expression and then called a handle_notes template. The
filter_notes.xsl contains all the xsl within a named template and this
template is explicitly called by the .xsl which includes the
filter_notes.xsl. This way I could get control of when the filtering etc.
actuly happens. Below is the listing for the including xsl, would like some
comments on this approach.
thanks

Sridhar

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0"
                xmlns:java="http://xml.apache.org/xslt/java";
                exclude-result-prefixes="java">
<xsl:import href="filter_table_notes.xsl"/>
<xsl:output method="html" indent = "yes"/>

<xsl:param name="filter_release" />
<xsl:param name="filter_template"/>
<xsl:param name="filter_product"/>
<xsl:param name="filter_solution" />

<xsl:variable name="relFilterFileName" select="string
('releasefilter.dat')"/>
<xsl:variable name="dummy" select="java:XmlUtil.loadReleaseFilterMap
($relFilterFileName)"/>

<xsl:template match="/">
    <HTML>
    <BODY>
    <HR SIZE="10" NOSHADE="TRUE"/>
        <xsl:apply-templates select="TABLE"/>
    </BODY>
    </HTML>
</xsl:template>

<xsl:template match="TABLE">
    <H1 STYLE="font-weight:bold; font-size:24; color:blue;
text-align:center"><xsl:value-of select="@NAME"/></H1>
    <B><I>DESCRIPTION:</I></B><P><xsl:value-of select="./DESCRIPTION"/>
</P>

    <TABLE BORDER="1" FRAME="BOX" BGCOLOR="#FFF9C">
    <CAPTION ALIGN="top">Table Level Notes</CAPTION>
    <th> Author </th>
    <th> Template </th>
    <th> Product</th>
    <th> Solution </th>
    <th> Date </th>
    <th> Comments   </th>

    <xsl:call-template name="filter_table_notes"/>

    </TABLE>
</xsl:template>

<xsl:template name="handle-table-notes">
      <xsl:param name="notes_list"/>
      <xsl:for-each select="$notes_list">
          <tr>
          <td> <xsl:value-of select="@AUTHOR"/></td>
          <td> <xsl:value-of select="@TEMPLATE"/></td>
          <td> <xsl:value-of select="@PRODUCT"/></td>
          <td> <xsl:value-of select="@SOLUTION"/></td>
          <td> <xsl:value-of select="@DATE"/></td>
          <td> <xsl:value-of select = "."/></td>
          </tr>
      </xsl:for-each>
</xsl:template>


</xsl:stylesheet>

Here is a excerpt from  filter_table_notes

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0"
                xmlns:java="http://xml.apache.org/xslt/java";
                exclude-result-prefixes="java">
<xsl:template name="filter_table_notes">
    <xsl:choose>
        <xsl:when test="$filter_template and $filter_product and
$filter_solution ">
            <xsl:call-template name="handle-table-notes">
                <xsl:with-param name = "notes_list"
                                select= "//TABLE/NOTES[@TEMPLATE
=$filter_template and @PRODUCT=$filter_product and @SOLUTION
= $filter_solution]"/>
            </xsl:call-template>
        </xsl:when>


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


Current Thread