xsl:sort Question

admin

Administrator
Staff member
xsl:sort Question

I'm using the transformNode method to convert an XML doc and an XSL stylesheet to XHTML using an ASP.NET/VB.NET script, and it works great. But when I try to add an <xsl:sort... property to the xsl stylesheet, I get the following error message:
Server Error in '/' Application.
Keyword xsl:sort may not be used here.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Keyword xsl:sort may not be used here.

Source Error:
Line 18:
Line 19: 'Transform file
Line 20: Response.Write(xml.transformNode(xsl))
Line 21: %>
Source File: c:\inetpub\wwwroot\DIRECTORY\FILENAME.aspx Line: 20

I'm a complete newbie to XML and XSL/XSLT, so I'm not sure why I'm receiving this message. So my question is:
Is it not possible to use the <xsl:sort... method when using the transformNode method?

Thanks for any & all help.

P.S. Here's the code that I'm using in case it needs to be referenced:

XML doc:

<?xml version="1.0" encoding="UTF-8"?>
<formsdocs>
<form>
<title>FORM TITLE</title>
<url>http://DOMAIN/DIRECTORY/FORMNAME.pdf</url>
<format>pdf</format>
<target>_blank</target>
<type>internal</type>
<size>3053 KB</size>
<dept>DEPT</dept>
<div />
</form>
</formsdocs>

XSL stylesheet:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PAGETITLE</title>
</head>
<body>
<h1>PAGE HEADER</h1>
<table class="navyblueborder">
<tr bgcolor="#333366" class="whiteheader">
<th align="left">Title</th>
<th align="left">Format</th>
<th align="left">Type</th>
<th align="left">Size</th>
<th align="left">Dept</th>
</tr>
<xsl:for-each select="formsdocs/form">
<tr>
<td><a href=http://www.webdeveloper.com/forum/archive/index.php/"{url}" target="{target}"><xsl:value-of select="title" /></a></td>
<td><xsl:value-of select="format" /></td>
<td><xsl:value-of select="type" /></td>
<td><xsl:value-of select="size" /></td>
<td><xsl:value-of select="dept" />
<xsl:choose>
<xsl:when test="div =''">
</xsl:when>
<xsl:otherwise>
(<xsl:value-of select="div" /> Division)
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

ASP.NET/VB.NET script:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" Debug="true" %>
<%@ import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
'Load XML
Dim xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load("http://DOMAIN/DIRECTORY/XMLFILE.xml")

'Load XSL
Dim xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("http://DOMAIN/DIRECTORY/XSLFILE.xsl")

'Transform file
Response.Write(xml.transformNode(xsl))
%>
 
Back
Top