xslt - can you filter results

Discussion in 'XML' started by inetquestion, Nov 14, 2005.

  1. inetquestion

    inetquestion Guest

    Can someone point me in the right direction regarding xml/xslt? I have
    the following xml file with corresponding xslt and would like to add
    some aditional functionality where a viewer can select from a dropdown
    menu or radio box which tier of servers to view thereby filtering out
    the others. From a few sources I've seen it looks like I would need to
    use xsl:with-param, but references I've seen of this do not explain it
    at my level (beginner).

    Regards,

    -Inet







    --------------------XML FILE---------------------
    <?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet
    type="text/xsl" href="ndd_settings.xsl"?>
    <servers>
    <info><title>NDD Tcp Settings</title><date>Nov 14 2005 17:15:11
    GMT</date></info>


    <server hostname="server01" tier="dev" sysadmin="Goofy"><NddParameters>
    <tcp_time_wait_interval default="240000" ewaa="60000"
    sync="yes">60000</tcp_time_wait_interval>
    <tcp_conn_req_max_q default="128" ewaa="1024"
    sync="yes">1024</tcp_conn_req_max_q>
    </NddParameters></server>


    <server hostname="server02" tier="stg" sysadmin="Donald
    Duck"><NddParameters>
    <tcp_time_wait_interval default="240000" ewaa="60000"
    sync="yes">60000</tcp_time_wait_interval>
    <tcp_conn_req_max_q default="128" ewaa="1024"
    sync="yes">1024</tcp_conn_req_max_q>
    </NddParameters></server>


    <server hostname="server03" tier="prd" sysadmin="Mickey
    Mouse"><NddParameters>
    <tcp_time_wait_interval default="240000" ewaa="60000"
    sync="yes">60000</tcp_time_wait_interval>
    <tcp_conn_req_max_q default="128" ewaa="1024"
    sync="yes">1024</tcp_conn_req_max_q>
    </NddParameters></server>

    </servers>


    ---------------------XSLT FILE-------------------------

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/servers">
    <html>
    <body>
    <center><xsl:apply-templates select="info" /></center>


    <center><table border="1"><caption><B>Legend</B></caption>
    <tr><td>Solaris 8 Defaults</td></tr>
    <tr><td bgcolor="#33FF66">EWAA Standard -
    <xsl:value-of select="count(//@sync)"/> / <xsl:value-of
    select="count(//NddParameters/*)"/> Completed</td></tr>
    <tr><td bgcolor="red">Unknown Origin OR Old Standard</td></tr>
    </table>
    </center><br /><br />

    <table border="1" width="100%">
    <tr bgcolor="#CCCCCC">
    <th>Server</th>
    <th>Tier</th>
    <th>SysAdmin</th>
    <th STYLE="layout-flow: vertical-ideographic"
    align="left">tcp_time_wait_interval</th>
    <th STYLE="layout-flow: vertical-ideographic"
    align="left">tcpconn_req_max_q</th>
    </tr>

    <xsl:apply-templates select="server" />

    </table>
    </body>
    </html>


    </xsl:template>



    <xsl:template match="info">
    <h2><xsl:value-of select="title"/></h2>
    Generated: <xsl:value-of select="date"/>
    </xsl:template>


    <xsl:template match="server">
    <tr>
    <td><xsl:value-of select="@hostname"/></td>
    <td><xsl:value-of select="@tier"/></td>
    <td><xsl:value-of select="@sysadmin"/></td>


    <xsl:choose>
    <xsl:when test="NddParameters/tcp_time_wait_interval =
    NddParameters/tcp_time_wait_interval/@ewaa">
    <td bgcolor="#33FF66"><xsl:value-of
    select="NddParameters/tcp_time_wait_interval"/></td>
    </xsl:when>
    <xsl:when test="NddParameters/tcp_time_wait_interval =
    NddParameters/tcp_time_wait_interval/@default">
    <td><xsl:value-of
    select="NddParameters/tcp_time_wait_interval"/></td>
    </xsl:when>
    <xsl:eek:therwise>
    <td bgcolor="red"><xsl:value-of
    select="NddParameters/tcp_time_wait_interval"/></td>
    </xsl:eek:therwise>
    </xsl:choose>




    <xsl:choose>
    <xsl:when test="NddParameters/tcp_conn_req_max_q =
    NddParameters/tcp_conn_req_max_q/@ewaa">
    <td bgcolor="#33FF66"><xsl:value-of
    select="NddParameters/tcp_conn_req_max_q"/></td>
    </xsl:when>
    <xsl:when test="NddParameters/tcp_conn_req_max_q =
    NddParameters/tcp_conn_req_max_q/@default">
    <td><xsl:value-of
    select="NddParameters/tcp_conn_req_max_q"/></td>
    </xsl:when>
    <xsl:eek:therwise>
    <td bgcolor="red"><xsl:value-of
    select="NddParameters/tcp_conn_req_max_q"/></td>
    </xsl:eek:therwise>
    </xsl:choose>



    </xsl:template>

    </xsl:stylesheet>
    inetquestion, Nov 14, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page