Howdy... :)
First time using the XSL so I might not be making much sense... I hope not though...
Okay... I am using ASP(I am not the ASP guy either) to pass in two variables, sField and sTerm, into the XSL file...
Quote:
quote:<xsl:param name="sField"/>
<xsl:param name="sTerm"/>
|
Here is the list of a couple of XML nodes as an example...
Quote:
quote:<?xml version="1.0" encoding="ISO-8859-1"?>
<Press>
<Release>
<title>The Downfall of "Always Connected"</title>
<category>MEDIA</category>
<source>iMedia Connection</source>
<date>March 29, 2006</date>
<linkType>WEB</linkType>
<linkURL1>http://www.imediaconnection.com/content/8842.asp</linkURL1>
<linkURL2></linkURL2>
</Release>
<Release>
<title>Fourth-graders deliver the news on TV broadcast every morning</title>
<category>EDUCATION</category>
<source>Kingsport Times-News</source>
<date>March 19, 2006</date>
<linkType>WEB</linkType>
<linkURL1>http://www.timesnews.net/communityArticle.dna?_StoryID=3613155</linkURL1>
<linkURL2></linkURL2>
</Release>
<Release>
<title>You Don't Need A Weatherman... WeatherBug's Strength Lies in its Vast Network of Data</title>
<category>GOVERNMENT</category>
<source>Federal Computer Week</source>
<date>February 27, 2006</date>
<linkType>PDF</linkType>
<linkURL1>http://www.aws.com/aws_2005/releases/2006/clipping_feb2006_fedcomputerweek.pdf</linkURL1>
<linkURL2></linkURL2>
</Release>
...
|
What I am trying to do is to display the nodes that contain 'EDUCATION' for example or 'MEDIA' or the ones whoes date is set to 2005 for example or even the nodes that meets both conditions...
In one of the template, I am trying to filter the data with the contains() function like this...
Quote:
quote:<xsl:template match="Press/Release">
<xsl:if test = "contains(., $sTerm)">
|
That attempt searchs the given $sTerm(MEDIA) from everythin in the node, I think...
I can change the '.' to 'category' to search for the specific category, and I can chage that to 'date' to search for specific year, but I cannot make that dynamic...
I tried to pass in $sField as either 'category' or 'date' and use this, but I get the error message...
Quote:
quote:<xsl:if test = "contains($sField, $sTerm)">
|
Quote:
quote:Error Type:
msxml3.dll (0x80004005)
The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.
/Coverage/Coverage.asp, line 32
|
I know I am babbling too much but here is a pseudo code of what I am looking to happen in the XSL document so that I can search for the 'MEDIA' category of all the 2005 records or something... I feel like I am getting the $sField passed in okay but it is not doing the comparison because of the type difference or something...
Quote:
quote:
if ($sField == null)
then $theField = "."
else $theField = $sField
<xsl:if test = "contains($theField, $sTerm)">
|
Any help would be appreciated...
Thanks... :)
CyanBlue
Just in case... This is the content of the XSL file...
Quote:
quote:<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:param name="sField"/>
<xsl:param name="sTerm"/>
<xsl:template match="/">
<xsl:apply-templates select="Press/Release"/>
</xsl:template>
<xsl:template match="Press/Release">
<xsl:if test = "contains(., $sTerm)">
<p><a href="{linkURL1}" target="_blank"><xsl:value-of select="title"/></a>
<xsl:if test = "contains(linkType, 'PDF')">
<xsl:text> </xsl:text><strong>(<xsl:value-of select="linkType"/>)</strong>
</xsl:if>
<br /><xsl:value-of select="source"/><xsl:text>, </xsl:text><strong><xsl:value-of select="date"/></strong></p>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
|
and this is the content of the ASP file...
Quote:
quote:<%@LANGUAGE="VBScript"%>
<%
dim xslDoc, xmlDoc
dim sTerm, sField
sField = Request.QueryString("sField")
sTerm = Request.QueryString("sTerm")
set xmlDoc=server.CreateObject("Msxml2.FreeThreadedDOM Document.3.0")
set xslDoc=server.CreateObject("Msxml2.FreeThreadedDOM Document.3.0")
xmldoc.async = false
xslDoc.async = false
If IsNull(sField) then
sField = "."
else
sField = UCase(sField)
end if
xmlDoc.load server.mapPath("Coverage.xml")
xslDoc.load server.mapPath("Coverage.xsl")
Set template = Server.CreateObject("MSXML2.XSLTemplate.3.0")
Set template.stylesheet = xslDoc
Set proc = template.createProcessor
proc.input = xmlDoc
If Len(sTerm) < 1 then
sTerm = "."
else
sTerm = UCase(sTerm)
end if
proc.addParameter "sField", sField
proc.addParameter "sTerm", sTerm
proc.transform
Response.Write proc.output
%>
|