Question

I'm trying to modify and existing project in order to add some features. I would like to pass some parameters to my xsl stylesheet, but any use of parameters causes an error. I've tried inserting the simplest examples found in tutorials, etc. to no avail. I believe the problem may be with the version of xslt being used?

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="VBScript">
  <xsl:param name="test">TEST</xsl:param>

<xsl:template match="/">
  <xsl:value-of select="$test"></xsl:value-of>  
</xsl:template>

</xsl:stylesheet>

I've removed all of the other code in order to keep the example as simple as possible. According to my understanding, this code should simply output TEST on the html page. However, what I get is a classic IIS error:

An error occurred on the server when processing the URL. Please contact the system administrator.

If you are the system administrator please click here to find out more about this error.

Does anyone have any insight as to why this is happening? The same problem occurs when I try to use variables in any way. Is it a problem with my Web Server, or the version of xslt being used?

Thank you for your help!

Was it helpful?

Solution 2

Expanding on Michael Kay's answer, Microsoft may be dropping support for the old legacy "http://www.w3.org/TR/WD-xsl" namespace, so it can't be guarenteed to work much longer. This is certainly the case for IE9, as explained on MSDN

http://msdn.microsoft.com/en-gb/library/ie/hh180178(v=vs.85).aspx

I recently had to change an XSLT stylesheet that was using "http://www.w3.org/TR/WD-xsl" to get it to work in IE9. It might be just a simple case of changing it to use the correct namespace of "http://www.w3.org/1999/XSL/Transform", but you might also have to make changes if you are using constructs that are not actually supported in the current namespace. These are the things I noticed that were supported in the legacy one, but not in the current

  • xsl:apply-templates had an order-by attribute. Replace this with xsl:sort instead.
  • xsl:if allowed a match attribute. Replace this with test
  • xsl:eval was supported. This may need some re-work to replace depending on what it was used for.

OTHER TIPS

It may be worth spending some time to see if there aren't any better error messages lurking in a log file somewhere. I don't know IIS, but Microsoft technologies seem to have a habit of producing copious diagnostics and then not telling you where they are.

But the attribute language="VBScript" on the xsl:stylesheet element is an error, and any conformant XSLT processor, at either version 1.0 or 2.0, should reject this stylesheet for that reason.

WHOOPS: I just noticed you used xmlns:xsl="http://www.w3.org/TR/WD-xsl". That means you're not using XSLT at all, but the Microsoft-proprietary "working-draft XSL" language which they introduced in 1998 and which became obsolete about a year later. This language, which has some family resemblances to XSLT, still works, I believe, but it's almost impossible to get documentation on it nowadays except by scouring second-hand bookshops.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top