Can I access methods in a dll, already in the GAC, without having to declare them inside a CDATA section within the msxsl:script element?

Here's one example of what i don't want:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-       result-prefixes="xsl in lang user"     xmlns:in="http://www.composite.net/ns/transformation/input/1.0" xmlns:lang="http://www.composite.net/ns/localization/1.0" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts"> 
 <msxsl:script language="C#" implements-prefix="user"> 
    <msxsl:assembly name="System.Web" /> 
    <msxsl:using namespace="System.Web" />
<![CDATA[public string GetDate(string DateFormat){return DateTime.Now.ToString(DateFormat);}]]></msxsl:script> 
  <xsl:template match="/">  
      <sometag> 
          <xsl:value-of select="user:GetDate('dddd, dd MMMM yyyy')" /> 
      </sometag> 
  </xsl:template> 
</xsl:stylesheet>

I dont want to have to put my function inside a CDATA, can't i reference the dll and call my function inside the template tag like in the example above?

有帮助吗?

解决方案

It all depends on the XSLT processor you use and its API. Microsoft's XslCompiledTransform allows you to pass in extension objects, see http://msdn.microsoft.com/en-us/library/tf741884.aspx and http://msdn.microsoft.com/en-us/library/system.xml.xsl.xsltargumentlist.addextensionobject.aspx. So you don't have to use the msxsl:script element but you need to define a namespace and make sure you pass in your object as an extension object bound to that namespace.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top