[xsl] problem with xml searching with xsl

Subject: [xsl] problem with xml searching with xsl
From: Gatis <mr.g@xxxxxxxxx>
Date: Tue, 30 Sep 2003 16:51:50 +0300
Hi!

I'm a new in xml/xsl and have a problem with user input handling.
The aim is to create searchable xml database on the cdrom. I have the xml and
xsl for user input handling and searching. Unfortunately it didn't works.
First attemt was:
<?xml version="1.0" encoding="ISO-8859-1"?>

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

<xsl:output method="html"/>

<xsl:template match="/">
  <html>
  <body>

<form method="get">
<xsl:element name="input">
<xsl:attribute name="name">search</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="search"/>
</xsl:attribute>
</xsl:element>
<input type="submit" name="button"/>
 </form>

 <table border="1">
      <tr bgcolor="#9acd32">
        <th align="left">kods</th>
        <th align="left">nosaukums</th>
      </tr>
      <xsl:for-each select="Import/Row">
       <xsl:if test="contains(NOSAUKUMS, @search)">
      <tr>
        <td><xsl:value-of select="KODS"/></td>
        <td><xsl:value-of select="NOSAUKUMS"/></td>
      </tr>
      </xsl:if>
      </xsl:for-each>
    </table>
     
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>


Then I try to get values for searching from url string, but javascript didn't executes.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v4.2 -->
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
      xmlns:msxsl="urn:schemas-microsoft-com:xslt"
      xmlns:user="http://mycompany.com/mynamespace";>
 <xsl:output method="html"/>
<xsl:template match="/">
  <html>
  <body>

<form method="get">
<xsl:element name="input">
<xsl:attribute name="name">search</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="search"/>
</xsl:attribute>
</xsl:element>
<input type="submit" name="button"/>
 </form>

<xsl:variable name="url">
<msxsl:script language="JavaScript">
var url;
url = location.href;
document.write(url);
document.write(location.href);
</msxsl:script>
</xsl:variable>

 <table border="1">
      <tr bgcolor="#9acd32">
        <th align="left">kods</th>
        <th align="left">nosaukums</th>
      </tr>
      <xsl:for-each select="Import/Row">
       <xsl:if test="contains(NOSAUKUMS, $url)">
      <tr>
        <td><xsl:value-of select="KODS"/></td>
        <td><xsl:value-of select="NOSAUKUMS"/></td>
      </tr>
      </xsl:if>
      </xsl:for-each>
    </table>
     
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>

Pls help!

obender


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


Current Thread