Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2006, 02:44 PM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jayme27
Default Filter multi-tier XML data island

I am attempting to apply a filter to a multi-tier XML data island. I'm about 80 percent there, but still have not got it to function correctly. It was fully functional prior to my adding an additional level (Categories XML tag) to my XML island. This is my HTML file below. Any ideas on what I might be missing?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><HEAD>
    <title>Links</title>


<!--
AUTHOR: David Silverlight
Editor: This version edited by Jayme
Email: HeadGeek@xmlpitstop.com
Shameless Plug: Yes I am a consultant who is always looking for cool projects.
Phone: (877) XML-GURU

Description: This code snippet demonstrates how to add Filtering to a DataBound HTML table.
Yes, it will not work in anything except an IE Browser and No, it does not do any updates to a database. That functionality
is outside of the scope of this snippet.

-- Enjoy.
-->


<STYLE>

INPUT
{
    FONT-SIZE: 9pt;
    HEIGHT:20px;
    COLOR: #330066;
    FONT-FAMILY: Arial, Helvetica, sans-serif;
    BACKGROUND-COLOR: #F0F0F0;
    border : thin outset #F5F5DC;
    border-bottom-color : #F5FFFA;
}

FORM
{
    FONT-SIZE: 10pt;
    COLOR: #330066;
    FONT-FAMILY: Arial, Helvetica, sans-serif
}

TD
{
    FONT-SIZE: 9pt;
     FONT-FAMILY: Arial, Helvetica, sans-serif;
}


BODY
{
    SCROLLBAR-FACE-COLOR: #F0F0F0;
    SCROLLBAR-HIGHLIGHT-COLOR: #CCCCCC;
    SCROLLBAR-SHADOW-COLOR: #CCCCCC;
    SCROLLBAR-3DLIGHT-COLOR: #F0F0F0;
    SCROLLBAR-ARROW-COLOR: #330066;
    SCROLLBAR-DARKSHADOW-COLOR: #CCCCCC;
    SCROLLBAR-BASE-COLOR: #CCCCCC;
}

TR
{
    CURSOR: hand;
    TEXT-ALIGN: left;
    PADDING-LEFT : 4px;
}


.DataTable
{
    BORDER-RIGHT: 0px solid;
    BORDER-TOP: thin solid;
    FONT-WEIGHT: normal;
    FONT-SIZE: 8pt;
    BORDER-LEFT: 0px solid;
    BORDER-BOTTOM: 1px solid;
    FONT-FAMILY: Arial, Helvetica, sans-serif;
    HEIGHT: 1px
}

.MainHeader
{
    FONT-SIZE: 14pt;
    COLOR: Darklue;
    FONT-FAMILY: Arial, Helvetica, sans-serif
}
.DataCol
{
    FONT-SIZE: 8pt;
     FONT-FAMILY: Arial, Helvetica, sans-serif;
}


    </STYLE>

    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"></HEAD>

    <body bgcolor="#00FFFF">
        <form method="post" action="" name="frmData">
        <div id="divHeader" style="Z-INDEX: 34; LEFT: 33px; WIDTH: 703px; POSITION: absolute; TOP: 150px; HEIGHT: 149px">

            <div name="CustomerList" style="LEFT: 1px; OVERFLOW: scroll; WIDTH: 100%; TOP: 14px; HEIGHT: 350px">


            <table id="tblHeader" Datasrc="#xmlDSO" Class="DataTable" width="100%" cellpadding="0" cellspacing="0" border="1" style="LEFT: -1px; TOP: 0px">
                <thead>
                    <tr>
                        <th id="thdr" width="10">#</th>
                        <th id="thdr" width="80">Site</th>
                        <th id="thdr" width="250">Description</th>
                        <th id="thdr" width="67" >Categories</th>
                        <th id="thdr" width="90">Rating</th>
                    </tr>
                </thead>
                <tbody>
<tr onclick="CurrentRecord()">
                        <td width="10" align="left" height="15"><span datafld="ID" class="xDataCol"></span></td>
                        <td width="80" align="left" height="15"><a href datafld="SiteURL" target="_blank"><span datafld="SiteName" class="xDataCol"></span></a></td>
                        <td width="250" align="left" height="15"><span datafld="SiteDescription" class="xDataCol"></span></td>
                        <td width="67" align="left" height="15">
                            <table Datasrc="#xmlDSO" datafld="Categories" cellpadding="0" cellspacing="0" border="0">
                                <tr><td><span datafld="#text"></span></td></tr>
                            </table>

</td>
                        <td width="90" align="left" height="15"><span datafld="SiteRating" class="xDataCol"></span></td>
                    </tr>

            </tbody>
        </table>
    </div>
</div>


<div id="main" style="LEFT: 0px; WIDTH: 759px; POSITION: absolute; TOP: 100px; HEIGHT: 29px" tabIndex="11">
    <div id="divSearch" style="LEFT: 32px; WIDTH: 710px; POSITION: absolute; TOP: -100px; HEIGHT: 27px">
        <table ID="tblSearchFields" border=1 bgcolor="menu" width="100%">
            <tr>
                <td colspan="2" >Select your site using the criteria below:</td>
                <td colspan="2" ><Input type=button value="Show all"id=btnShowAll name=btnShowAll onclick="doShowAll()"></td>
                </tr>
            <tr>
                <td>
                    Category:
                        <SELECT ID="selCategory" NAME="selCategory" onchange="doFilter()">
                            <OPTION selected value="Political">Political</OPTION>
                            <OPTION value="Military">Military</OPTION>
                            <OPTION value="Social">Social</OPTION>
                            <OPTION value="Economic">Economic</OPTION>
                            <OPTION value="Information">Information</OPTION>
                            <OPTION value="Infrastructure">Infrastructure</OPTION>
                        </SELECT>

                </td>
                <td>
                    Rating:
                        <SELECT ID="selSiteRating" NAME="selSiteRating" onchange="doFilter()">
                            <OPTION selected value="5">5</OPTION>
                            <OPTION value="4">4</OPTION>
                            <OPTION value="3">3</OPTION>
                            <OPTION value="2">2</OPTION>
                            <OPTION value="1">1</OPTION>
                        </SELECT>
                </td>
            </tr>
        </table>

    </div>


        </div>

</form>


<xml id="xslFilter">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="xml"/>

<xsl:param name="Category" select="'Political'"/>
<xsl:param name="SiteRating" select="'5'"/>

<xsl:template match="/">

    <CATALOG>
    <xsl:for-each select="CATALOG/SITE[/Categories/Category=$Category and @SiteRating=$SiteRating]" >

    <xsl:sort select="@ID" order="ascending" />

        <data>
            <xsl:for-each select="@*" >
                <xsl:attribute name='{name()}'> <xsl:value-of select="."/></xsl:attribute>
            </xsl:for-each>
        </data>
    </xsl:for-each>
    </CATALOG>

</xsl:template>



<xsl:template match="data">
    <data>
        <xsl:apply-templates/>
    </data>
</xsl:template>
</xsl:stylesheet>
</xml>
<xml id="xmlDSO">
<CATALOG>
    <SITE ID="01" SiteName="Jowairiyya" SiteDescription="I am winking at you" SiteRating="5" SiteURL="http://library.nps.navy.mil/home/tgp/tgpndx.htm#2001">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="02" SiteName="Gulmakai" SiteDescription="Where are you good looking?" SiteRating="1" SiteURL="images/TalibanGirl2.jpg">
        <Categories>
         <Category>Military</Category>
        <Category>Infrastructure</Category>
        <Category></Category>
        </Categories>
    </SITE>
    <SITE ID="03" SiteName="Frozen" SiteDescription="Looking for a little sunshine." SiteRating="5" SiteURL="images/TalibanGirl3.jpg">
        <Categories>
         <Category>Economic</Category>
        <Category></Category>
        <Category></Category>
        </Categories>
    </SITE>
    <SITE ID="04" SiteName="Masooda" SiteDescription="I can't see anyone here" SiteRating="5" SiteURL="images/TalibanGirl4.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="05" SiteName="Parween" SiteDescription="Bring some light to my life" SiteRating="5" SiteURL="images/TalibanGirl5.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Economic</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="06" SiteName="Shreengul" SiteDescription="I Declare a Jihad On U, Baby" SiteRating="5" SiteURL="images/TalibanGirl6.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="07" SiteName="Frogh" SiteDescription="NO MORE BEATINGS PLEASE" SiteRating="3" SiteURL="images/TalibanGirl7.jpg">
<Categories Category1="Political" Category2="Military" Category3="Social" Category4="Economic"/>
    </SITE>
    <SITE ID="08" SiteName="Mahboba" SiteDescription="Make me 1 of your wives" SiteRating="5" SiteURL="images/TalibanGirl8.jpg">
        <Categories>
         <Category>Information</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="09" SiteName="Shawjan" SiteDescription="R U A Terrorist with a heart?" SiteRating="1" SiteURL="images/TalibanGirl9.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="10" SiteName="Paktoon" SiteDescription="Not like all the other women" SiteRating="5" SiteURL="images/TalibanGirl10.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="11" SiteName="Hillary Clinton" SiteDescription="Looking for someone faithful" SiteRating="4" SiteURL="images/Hillary1.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="12" SiteName="Janet Reno" SiteDescription="Looking for that tall Man/Women of my dreams" SiteRating="1" SiteURL="images/JanetReno3.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="13" SiteName="Joe" SiteDescription="I'm smokin!" SiteRating="3" SiteURL="images/JoeCamel1.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="14" SiteName="Camel" SiteDescription="Will work for food" SiteRating="2" SiteURL="images/Camel2.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="15" SiteName="Camel" SiteDescription="Ever done it with a talking camel?" SiteRating="2" SiteURL="images/Camel3.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="16" SiteName="Peppi" SiteDescription="Join me for a pepsi" SiteRating="2" SiteURL="images/Camel1.jpg">
        <Categories>
         <Category>Military</Category>
        <Category></Category>
        <Category></Category>
        </Categories>
    </SITE>
    <SITE ID="17" SiteName="Buck" SiteDescription="A face only a camel could love" SiteRating="2" SiteURL="images/Camel4.jpg">
        <Categories>
         <Category>Economic</Category>
        <Category>Military</Category>
        <Category></Category>
        </Categories>
    </SITE>
</CATALOG>
</xml>
<!-- Note: the reason for the xmlDSOorig data island is that the xmlDSO data island becomes repopulated after
a filtering is performed. If you try to filter a second time, you will need to start from the original contents. -->
<xml id="xmlDSOorig">
<CATALOG>
    <SITE ID="01" SiteName="Jowairiyya" SiteDescription="I am winking at you" SiteRating="5" SiteURL="http://library.nps.navy.mil/home/tgp/tgpndx.htm#2001">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="02" SiteName="Gulmakai" SiteDescription="Where are you good looking?" SiteRating="1" SiteURL="images/TalibanGirl2.jpg">
        <Categories>
         <Category>Military</Category>
        <Category>Infrastructure</Category>
        <Category></Category>
        </Categories>
    </SITE>
    <SITE ID="03" SiteName="Frozen" SiteDescription="Looking for a little sunshine." SiteRating="5" SiteURL="images/TalibanGirl3.jpg">
        <Categories>
         <Category>Economic</Category>
        <Category></Category>
        <Category></Category>
        </Categories>
    </SITE>
    <SITE ID="04" SiteName="Masooda" SiteDescription="I can't see anyone here" SiteRating="5" SiteURL="images/TalibanGirl4.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="05" SiteName="Parween" SiteDescription="Bring some light to my life" SiteRating="5" SiteURL="images/TalibanGirl5.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Economic</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="06" SiteName="Shreengul" SiteDescription="I Declare a Jihad On U, Baby" SiteRating="5" SiteURL="images/TalibanGirl6.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="07" SiteName="Frogh" SiteDescription="NO MORE BEATINGS PLEASE" SiteRating="3" SiteURL="images/TalibanGirl7.jpg">
<Categories Category1="Political" Category2="Military" Category3="Social" Category4="Economic"/>
    </SITE>
    <SITE ID="08" SiteName="Mahboba" SiteDescription="Make me 1 of your wives" SiteRating="5" SiteURL="images/TalibanGirl8.jpg">
        <Categories>
         <Category>Information</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="09" SiteName="Shawjan" SiteDescription="R U A Terrorist with a heart?" SiteRating="1" SiteURL="images/TalibanGirl9.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="10" SiteName="Paktoon" SiteDescription="Not like all the other women" SiteRating="5" SiteURL="images/TalibanGirl10.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="11" SiteName="Hillary Clinton" SiteDescription="Looking for someone faithful" SiteRating="4" SiteURL="images/Hillary1.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="12" SiteName="Janet Reno" SiteDescription="Looking for that tall Man/Women of my dreams" SiteRating="1" SiteURL="images/JanetReno3.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="13" SiteName="Joe" SiteDescription="I'm smokin!" SiteRating="3" SiteURL="images/JoeCamel1.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="14" SiteName="Camel" SiteDescription="Will work for food" SiteRating="2" SiteURL="images/Camel2.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="15" SiteName="Camel" SiteDescription="Ever done it with a talking camel?" SiteRating="2" SiteURL="images/Camel3.jpg">
        <Categories>
         <Category>Social</Category>
        <Category>Military</Category>
        <Category>Political</Category>
        </Categories>
    </SITE>
    <SITE ID="16" SiteName="Peppi" SiteDescription="Join me for a pepsi" SiteRating="2" SiteURL="images/Camel1.jpg">
        <Categories>
         <Category>Military</Category>
        <Category></Category>
        <Category></Category>
        </Categories>
    </SITE>
    <SITE ID="17" SiteName="Buck" SiteDescription="A face only a camel could love" SiteRating="2" SiteURL="images/Camel4.jpg">
        <Categories>
         <Category>Economic</Category>
        <Category>Military</Category>
        <Category></Category>
        </Categories>
    </SITE>
</CATALOG>
</xml>




<script language="JavaScript">

function doShowAll() {
    try {
        xmlDSO.loadXML(xmlDSOorig.xml);
    }
    catch (error) {
        alert("doShowAll() in Default.htm caused the following error: " + error.SiteDescription)
    }

}


function doFilter() {
    try {
        var strRating = document.all.selSiteRating.value;
        var strCategory = document.all.selCategory.value;
        vbFilterTable(strCategory, strRating);
    }
    catch (error) {
        alert("doFilter() in Default.htm caused the following error: " + error.SiteDescription)
    }

}

   function CurrentRecord(){
        try {
            var iNum = window.event.srcElement.recordNumber;
            xmlDSO.recordset.AbsolutePosition = iNum;
        }
        catch (error) {
            alert("CurrentRecord() in Default.htm caused the following error: " + error.SiteDescription)
    }

}


        </script>


<script language="vbscript">

function vbFilterTable(strCategory, strRating)

        dim objXSL, objXML, objTemplate, objProcessor, strHTML

        Set objXML = CreateObject("Msxml2.FreeThreadedDOMDocument")
        Set objXSL = CreateObject("Msxml2.FreeThreadedDOMDocument")

        'Load the XML document
        objXML.async = False
        objXML.Loadxml xmlDSOorig.xml

        'Load the XSL document
        objXSL.async = False
        objXSL.Loadxml xslFilter.xml

        'Create an instance of our XSL Template object
        'Set objTemplate = CreateObject("MSXML2.XSLTemplate.3.0")
        Set objTemplate = CreateObject("MSXML2.XSLTemplate")

        'Create an instance of our stylesheet object using our recently loaded XSLT document
        Set objTemplate.stylesheet = objXSL

        'Create an instance of our Processor object
        Set objProcessor = objTemplate.createProcessor

        'Define the input object for our object equal to our recently loaded XML document
        objProcessor.input = objXML

        'Now, finally we can add any parameters that we require to our Template processor
        objProcessor.AddParameter "Category", strCategory
        objProcessor.AddParameter "SiteRating", strRating

        'Last but not least we do our transformation
        objProcessor.Transform

        'Store the results of the output into a string.
        strXML = objProcessor.output


        'Load up an XML DOM object from the recent XML output
        objXML.loadxml strXML

        'Select only the "SITE" elements from our document object
        objXML.selectNodes("//CATALOG")

        'Load our Data Island using our new XML object
        xmlDSO.loadxml objXML.xml



    end function

        </script>

    </body>
</html>

 
Old April 22nd, 2006, 04:53 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I think the basic approach is flawed in the sense that you need two copies of the original XML.
If you're going to do that then you might as well always transform the document to a simpler form more suited to IE internal representation of a data bound document (basically a simple table).
This is my version which is slightly different but shouldn't be too difficult to change if you don't like it:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  <title>Links</title>
  <xml id="xslLinks">
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="xml" />
      <xsl:param name="Category" select="''" />
      <xsl:param name="SiteRating" select="''" />
      <xsl:template match="/">
        <links>
          <xsl:apply-templates select="CATALOG/SITE[(Categories/Category = $Category or $Category = '')  and (@SiteRating = $SiteRating or $SiteRating = '')]">
            <xsl:sort select="@ID" order="ascending" />
          </xsl:apply-templates>
        </links>
      </xsl:template>
      <xsl:template match="SITE">
        <link>
          <id>
            <xsl:value-of select="@ID" />
          </id>
          <name>
            <xsl:value-of select="@SiteName" />
          </name>
          <url>
            <xsl:value-of select="@SiteURL" />
          </url>
          <description>
            <xsl:value-of select="@SiteDescription" />
          </description>
          <rating>
            <xsl:value-of select="@SiteRating" />
          </rating>
          <categoryList>
            <xsl:apply-templates select="Categories/Category">
              <xsl:sort data-type="text" order="ascending" select="." />
            </xsl:apply-templates>
          </categoryList>
        </link>
      </xsl:template>
      <xsl:template match="Category">
        <xsl:value-of select="." />
        <xsl:if test="position() != last()">
          <xsl:text>, </xsl:text>
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>
  </xml>
  <xml id="xmlLinks">
    <CATALOG>
      <SITE ID="01" SiteName="Jowairiyya" SiteDescription="I am winking at you" SiteRating="5"
        SiteURL="http://library.nps.navy.mil/home/tgp/tgpndx.htm#2001">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="02" SiteName="Gulmakai" SiteDescription="Where are you good looking?" SiteRating="1"
        SiteURL="images/TalibanGirl2.jpg">
        <Categories>
          <Category>Military</Category>
          <Category>Infrastructure</Category>
        </Categories>
      </SITE>
      <SITE ID="03" SiteName="Frozen" SiteDescription="Looking for a little sunshine."
        SiteRating="5" SiteURL="images/TalibanGirl3.jpg">
        <Categories>
          <Category>Economic</Category>
        </Categories>
      </SITE>
      <SITE ID="04" SiteName="Masooda" SiteDescription="I can't see anyone here" SiteRating="5"
        SiteURL="images/TalibanGirl4.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="05" SiteName="Parween" SiteDescription="Bring some light to my life" SiteRating="5"
        SiteURL="images/TalibanGirl5.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Economic</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="06" SiteName="Shreengul" SiteDescription="I Declare a Jihad On U, Baby"
        SiteRating="5" SiteURL="images/TalibanGirl6.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="07" SiteName="Frogh" SiteDescription="NO MORE BEATINGS PLEASE" SiteRating="3"
        SiteURL="images/TalibanGirl7.jpg">
        <Categories Category1="" Category2="Military" Category3="" Category4="">
          <Category>Political</Category>
          <Category>Military</Category>
          <Category>Social</Category>
          <Category>Economic</Category>
        </Categories>
      </SITE>
      <SITE ID="08" SiteName="Mahboba" SiteDescription="Make me 1 of your wives" SiteRating="5"
        SiteURL="images/TalibanGirl8.jpg">
        <Categories>
          <Category>Information</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="09" SiteName="Shawjan" SiteDescription="R U A Terrorist with a heart?"
        SiteRating="1" SiteURL="images/TalibanGirl9.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="10" SiteName="Paktoon" SiteDescription="Not like all the other women" SiteRating="5"
        SiteURL="images/TalibanGirl10.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="11" SiteName="Hillary Clinton" SiteDescription="Looking for someone faithful"
        SiteRating="4" SiteURL="images/Hillary1.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="12" SiteName="Janet Reno" SiteDescription="Looking for that tall Man/Women of my dreams"
        SiteRating="1" SiteURL="images/JanetReno3.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="13" SiteName="Joe" SiteDescription="I'm smokin!" SiteRating="3" SiteURL="images/JoeCamel1.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="14" SiteName="Camel" SiteDescription="Will work for food" SiteRating="2"
        SiteURL="images/Camel2.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="15" SiteName="Camel" SiteDescription="Ever done it with a talking camel?"
        SiteRating="2" SiteURL="images/Camel3.jpg">
        <Categories>
          <Category>Social</Category>
          <Category>Military</Category>
          <Category>Political</Category>
        </Categories>
      </SITE>
      <SITE ID="16" SiteName="Peppi" SiteDescription="Join me for a pepsi" SiteRating="2"
        SiteURL="images/Camel1.jpg">
        <Categories>
          <Category>Military</Category>
        </Categories>
      </SITE>
      <SITE ID="17" SiteName="Buck" SiteDescription="A face only a camel could love" SiteRating="2"
        SiteURL="images/Camel4.jpg">
        <Categories>
          <Category>Economic</Category>
          <Category>Military</Category>
        </Categories>
      </SITE>
    </CATALOG>
  </xml>

  <script language="JavaScript">

      function getSelectOption(select)
      {
        var listbox = document.getElementById(select);
        var iIndex = listbox.selectedIndex;
        if (iIndex == -1) return null;
        return listbox.options[iIndex];
      }

      function doShowAll()
      {
        filterTable("", "");
      }

      function doFilter()
      {
        var sCategory = getSelectOption("selCategory").value;
        var sRating = getSelectOption("selSiteRating").value;
        filterTable(sCategory, sRating);
     }
 
      var _oDom = null;
      function getFreeThreadedDom()
      {
       if (!_oDom)
       {
         _oDom = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
         _oDom.async = false;
       }
       return _oDom.cloneNode(false);
      }

      function getXslTemplate()
      {
       return new ActiveXObject("MSXML2.XSLTemplate.3.0");
      }

      function filterTable(category, rating)
      {
        var oProc = getXsltProcessor();
        oProc.addParameter("Category", category);
        oProc.addParameter("SiteRating", rating);
        oProc.input = getOriginalXml();
        oProc.transform();
        document.getElementById("xmlLinks").XMLDocument.loadXML(oProc.output);
      }

      var _oOriginalDom = null;
      function setOriginalXml()
      {
        _oOriginalDom = getFreeThreadedDom();
        _oOriginalDom.load(document.getElementById("xmlLinks").XMLDocument);
      }

      function getOriginalXml()
      {
        return _oOriginalDom;
      }

      var _oXsltProcessor = null;
      function setXsltProcessor()
      {
        var oTemplate = getXslTemplate();
        var oStyle = getFreeThreadedDom();
        oStyle.load(document.getElementById("xslLinks").XMLDocument)
        oTemplate.stylesheet = oStyle;
        _oXsltProcessor = oTemplate.createProcessor();
      }

      function getXsltProcessor()
      {
        return _oXsltProcessor;
      }

      function init()
      {
        setOriginalXml();
        setXsltProcessor();
        doFilter();
      }
  </script>

</head>
<body onload="init();">
  <form method="post" action="" name="frmData">
    <div id="divHeader" style="z-index: 34; left: 33px; width: 703px; position: absolute;
      top: 150px; height: 149px">
      <div style="left: 1px; overflow: scroll; width: 100%; top: 14px; height: 350px">
        <table id="tblHeader" datasrc="#xmlLinks" class="DataTable" width="100%" cellpadding="0"
          cellspacing="0" border="1" style="left: -1px; top: 0px">
          <thead>
            <tr>
              <th id="thdr1" width="5%">
                #</th>
              <th id="thdr2" width="15%">
                Site</th>
              <th id="thdr3" width="35%">
                Description</th>
              <th id="thdr4" width="35%">
                Categories</th>
              <th id="thdr5" width="10">
                Rating</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left" height="15">
                <span datafld="id" class="xDataCol"></span>
              </td>
              <td align="left" height="15">
                <a href datafld="url" target="_blank"><span datafld="name" class="xDataCol"></span>
                </a>
              </td>
              <td align="left" height="15">
                <span datafld="description" class="xDataCol"></span>
              </td>
              <td align="left" height="15">
                <span datafld="categoryList"></span>
              </td>
              <td align="left" height="15">
                <span datafld="rating" class="xDataCol"></span>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <div id="main" style="left: 0px; width: 759px; position: absolute; top: 100px; height: 29px"
      tabindex="11">
      <div id="divSearch" style="left: 32px; width: 710px; position: absolute; top: -100px;
        height: 27px">
        <table id="tblSearchFields" border="1" bgcolor="menu" width="100%">
          <tr>
            <td colspan="2">
              Select your site using the criteria below:</td>
            <td colspan="2">
              <input type="button" value="Show all" id="btnShowAll" name="btnShowAll" onclick="doShowAll()"></td>
          </tr>
          <tr>
            <td>
              Category:
              <select id="selCategory" name="selCategory" onchange="doFilter()">
                <option selected value="Political">Political</option>
                <option value="Military">Military</option>
                <option value="Social">Social</option>
                <option value="Economic">Economic</option>
                <option value="Information">Information</option>
                <option value="Infrastructure">Infrastructure</option>
              </select>
            </td>
            <td>
              Rating:
              <select id="selSiteRating" name="selSiteRating" onchange="doFilter()">
                <option selected value="5">5</option>
                <option value="4">4</option>
                <option value="3">3</option>
                <option value="2">2</option>
                <option value="1">1</option>
              </select>
            </td>
          </tr>
        </table>
      </div>
    </div>
  </form>
</body>
</html>
--

Joe (Microsoft MVP - XML)




Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Data Island Display Problem marcuslim XML 8 December 7th, 2004 04:00 AM
Converting an XML data island to 2 arrays NeilAtWork Classic ASP XML 0 April 14th, 2004 10:38 AM
Regional settings in a multi-tier environment rkoegelenberg Classic ASP Databases 0 July 31st, 2003 11:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.