lenin
Feb 20th, 2001, 10:35 AM
Hi,
can anyone provide pointers on how to filter data in XML. I have a simple XML based search engine, which passes a paramter from a web page.
Based on the search I ( at the moment ) use ASP to check for the occurence of the search work in the XML file.
However I am keen to implement the project with an XSL file. This means that I ( think I ) will have to filter the XML data prior to applying the XSL file, but have been unsuccessful up to date.
At the moment I have:
HTML Source:
<html>
<body>
<script language="javascript">
// Load XML
var objFiler
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("database.xml")
// Set variable selection
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("search.xsl")
// Filter XML File
//NEED SOURCE HERE
// Transform
document.write(xml.transformNode(xsl))
</script>
</body>
</html>
XML FILE:
<CODE>
<SOURCE ID="1">
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ADO CONNECTION OBJECT</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>connection</URL>
<DESCRIPTION>Simple Source for a generic ADO connection to SQL Server</DESCRIPTION>
</SOURCE>
<SOURCE ID="2">
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ADO COMMAND OBJECT</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>command</URL>
<DESCRIPTION>Simple Source for a generic ADO command with parameterised query variables</DESCRIPTION>
</SOURCE>
<SOURCE ID="3">
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ERROR MODULE</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>Error</URL>
<DESCRIPTION>Source for a generic Error Module</DESCRIPTION>
</SOURCE>
</CODE>
XSL:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="0">
<tr bgcolor = "Green">
<th>URL</th>
<th>Description</th>
</tr>
<xsl:for-each select="CODE/SOURCE">
<tr>
<td bgcolor = "Yellow"><xsl:value-of select="URL"/></td>
<td bgcolor = "Yellow"><xsl:value-of select="DESCRIPTION"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
thanks in advance.
Lenin.
can anyone provide pointers on how to filter data in XML. I have a simple XML based search engine, which passes a paramter from a web page.
Based on the search I ( at the moment ) use ASP to check for the occurence of the search work in the XML file.
However I am keen to implement the project with an XSL file. This means that I ( think I ) will have to filter the XML data prior to applying the XSL file, but have been unsuccessful up to date.
At the moment I have:
HTML Source:
<html>
<body>
<script language="javascript">
// Load XML
var objFiler
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("database.xml")
// Set variable selection
// Load the XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("search.xsl")
// Filter XML File
//NEED SOURCE HERE
// Transform
document.write(xml.transformNode(xsl))
</script>
</body>
</html>
XML FILE:
<CODE>
<SOURCE ID="1">
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ADO CONNECTION OBJECT</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>connection</URL>
<DESCRIPTION>Simple Source for a generic ADO connection to SQL Server</DESCRIPTION>
</SOURCE>
<SOURCE ID="2">
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ADO COMMAND OBJECT</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>command</URL>
<DESCRIPTION>Simple Source for a generic ADO command with parameterised query variables</DESCRIPTION>
</SOURCE>
<SOURCE ID="3">
<LANGUAGE>VB</LANGUAGE>
<KEYWORDS>ERROR MODULE</KEYWORDS>
<PATH>../Connection.html</PATH>
<URL>Error</URL>
<DESCRIPTION>Source for a generic Error Module</DESCRIPTION>
</SOURCE>
</CODE>
XSL:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="0">
<tr bgcolor = "Green">
<th>URL</th>
<th>Description</th>
</tr>
<xsl:for-each select="CODE/SOURCE">
<tr>
<td bgcolor = "Yellow"><xsl:value-of select="URL"/></td>
<td bgcolor = "Yellow"><xsl:value-of select="DESCRIPTION"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
thanks in advance.
Lenin.