.:mmac:. said:
Chris, The sample above functions, but links to the wma file (from the
href in the asx file) , not the asx file itself.
I can't locate a call to the filename in the xsl because it isn't in the
.asx file. I can figure out a response.write solution but the xsl is so
interesting I want to stick with it. can you tell how to display the .asx
filename in the link?
Oh, I see. I misinterpreted the question above. Since the playlist file
does not contain a reference to the asx filename, you will need to pass in
a parameter to the stylesheet processor. This will involve the following
steps:
1. Add a global parameter tag to the stylesheet.
2. Add a link to the playlist file in the output of the stylesheet
referencing the asx_uri parameter.
3. Add code to ShowASX.asp to pass in the asx_uri parameter value to the
stylesheet processor.
Here are the modified versions of the asx2html.xsl and ShowASX.asp files.
These modifications are based on a directory structure where the asx
playlist files are in a "Files" subdirectory relative to the ShowASX.asp
and asx2html.xsl files. You will need to make adjustments based on your
own directory structure. You will also need to adjust for the case
sensitivity as you did before.
[ShowASX.asp]
<%
CONST PATH = "C:\INETPUB\ANSWER\PUBLIC_HTML\ASX\FILES\"
Dim xslt, xsl, proc, xml, fso, fld, fc, f
Set xsl = CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
xsl.Load Server.MapPath("asx2html.xsl")
Set xslt = CreateObject("MSXML2.XSLTemplate.4.0")
Set xslt.stylesheet = xsl
Set proc = xslt.createProcessor()
Set xml = CreateObject("MSXML2.DOMDocument.4.0")
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(PATH)
Set fc = fld.Files
Response.Write "<table border='1'>"
For Each f In fc
If UCase(Right(f.Name,4)) = ".ASX" Then
xml.Load PATH & f.Name
proc.input = xml
proc.addParameter "asx_uri", "Files/" & f.Name
proc.Transform
Response.Write proc.output
End If
Next
Response.Write "</table>"
Set f = Nothing
Set fc = Nothing
Set fld = Nothing
Set xml = Nothing
Set proc = Nothing
Set xslt = Nothing
Set xsl = Nothing
%>
[asx2html.xsl]
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl
utput method="html" version="4.0" indent="yes"/>
<xsl
aram name="asx_uri" select="concat('Files/',/Asx/Title,'.asx')"/>
<xsl:template match="Asx">
<tr>
<td colspan="3">
<a>
<xsl:attribute name="href">
<xsl:value-of select="$asx_uri"/>
</xsl:attribute>
<img src="icon.gif"/>
</a>
</td>
</tr>
<xsl:for-each select="Entry">
<xsl:sort
order="descending"
select="concat( substring(Ref/@href,string-length(Ref/@href)-5,2),
substring(Ref/@href,string-length(Ref/@href)-11,2),
substring(Ref/@href,string-length(Ref/@href)-8,2))"
/>
<tr>
<td><xsl:value-of select="Title"/></td>
<td><xsl:value-of select="Author"/></td>
<td>
<xsl:call-template name="String2Date">
<xsl:with-param name="s"
select="substring(Ref/@href,string-length(Ref/@href)-11,8)"/>
</xsl:call-template>
</td>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template name="String2Date">
<xsl
aram name="s"/>
<xsl:variable name="m" select="substring($s,1,2)"/>
<xsl:variable name="d" select="substring($s,4,2)"/>
<xsl:variable name="y" select="substring($s,7,2)"/>
<xsl:choose>
<xsl:when test="$m='01'">January</xsl:when>
<xsl:when test="$m='02'">February</xsl:when>
<xsl:when test="$m='03'">March</xsl:when>
<xsl:when test="$m='04'">April</xsl:when>
<xsl:when test="$m='05'">May</xsl:when>
<xsl:when test="$m='06'">June</xsl:when>
<xsl:when test="$m='07'">July</xsl:when>
<xsl:when test="$m='08'">August</xsl:when>
<xsl:when test="$m='09'">September</xsl:when>
<xsl:when test="$m='10'">October</xsl:when>
<xsl:when test="$m='11'">November</xsl:when>
<xsl:when test="$m='12'">December</xsl:when>
</xsl:choose>
<xsl:value-of select="concat(' ',$d,', ')"/>
<xsl:choose>
<xsl:when test="$m < '30'"><xsl:value-of
select="concat('20',$y)"/></xsl:when>
<xsl
therwise><xsl:value-of select="concat('19',$y)"/></xsl
therwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>