xsl stylesheet, assembly reference issue

P

PL

According to the documentation I'm supposed to be able to use any classes in the
..NET framework inside a msxml:script block if I use a fully qualified path.

I'm trying to test the XSL sheet below with ASP.NET and all I'm
getting is:

error CS0234: The type or namespace name 'Data' does not exist in
the class or namespace 'System' (are you missing an assembly reference?)

Could someone explain how you reference these classes from inside a msxml:script
block, I cannot find anything but really simple examples that do not reference any other
classes than the default.

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace"
version="1.0">

<!-- For this example use the book.xml example -->
<msxsl:script language="C#" implements-prefix="user">
<![CDATA[

string execSQL(string sql)
{
try{
System.Data.SqlClient.SqlConnection objconn = new System.Data.SqlClient.SqlConnection("connection-string-here");

objconn.Open();

System.Data.SqlClient.SqlCommand objcommand = new System.Data.SqlClient.SqlCommand(sql,objconn);

return((string)objcommand.ExecuteScalar());
}
catch(System.Exception ee)
{
return(ee.ToString());
}
finally
{
objconn.Close();
}
}
]]>
</msxsl:script>

<xsl:template match="/">
<xsl:value-of select="user:execSQL('SELECT TOP 1 Name FROM Table1')"/>
</xsl:template>
</xsl:stylesheet>
 
P

PL

bruce barker said:
to implement this you will need to use XSLT extension objects.

Ok, that's one way but this is supposed to work according to docs:

http://msdn.microsoft.com/library/d...onxsltstylesheetscriptingusingmsxslscript.asp

"The following table shows the namespaces that are supported by default. You can use classes outside the listed
namespaces. However, these classes must be fully qualified."

I'm just confused as to why it doesnt work, that must be a documentation
error then.

PL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top