Your MyFunctions.cs is not listed as namespace 'urn:aspdnsf'. You're still calling the methods from XSLTExtensionBase.cs
Your MyFunctions.cs is not listed as namespace 'urn:aspdnsf'. You're still calling the methods from XSLTExtensionBase.cs
ah, i'm an idiot. got it now, thanks!
Hi,
When i try to register my custom xslt extension in web.config file. Can someone paste the exact syntax of the changes to be made in web.config for resistering custom xslt extensions for xmlPackage.
I think I properly converted this code into vb. But when I run the code, I get the following error:
XmlPackage Exception: Exception=Last Trace Point=[]. Cannot find the script or external object that implements prefix 'urn:myFunctions'.
My gut says i'm missing some link between the xml and the vb.
Much thanks in advance.
You still have to add your function call to the XSLTExtensions node of your web.config, and declare the namespace in your package.
Ok, so my web.config xsltobject section is:
<!-- Add your own custom XSLTExtensionObjects here-->
<xsltobjects defaultExtension="">
<extensions>
<clear/>
<add name="receipt" namespace="urn:receipt" type="ReceiptXsltExtension, app_code"></add>
<!--Added on January 15th, 2009-->
<add name="myCustomFunctions" namespace="urn:myFunctions" type="mynamespace.slug" ></add>
</extensions>
</xsltobjects>
My xml package called usabb.xml.config is:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- ################################################## ################################################## ## -->
<!-- Copyright AspDotNetStorefront.com, 1995-2006. All Rights Reserved. -->
<!-- http://www.aspdotnetstorefront.com -->
<!-- For details on this license please visit the product homepage at the URL above. -->
<!-- THE ABOVE NOTICE MUST REMAIN INTACT. -->
<!-- $Header: /v6.1/Web/XmlPackages/test.xml.config 1 12/30/05 2:33p Administrator $ -->
<!-- ################################################## ################################################## ## -->
<package version="2.1" displayname="Variants In Right Bar" allowengine="true" debug="true" includeentityhelper="true">
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:mynamespace="urn:mynamespace" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myFunctions="urn:myFunctions" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xslutput method="html" omit-xml-declaration="yes" />
<xsl:template match="*">
I AM HEAR!!!!
<xsl:value-of select="myFunctions:getmylistbox()" disable-output-escaping="yes" />
aspdnsf:GetMLValue(Name)
</xsl:template>
</xsl:stylesheet>
</PackageTransform>
</package>
my app_code vb file called usabb_test.vb is:
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
'<summary>
'Summary description for MyCode
'</summary>
Namespace mynamespace
Public Class slug
Public Function getmylistbox() As String
Return "<select id='Select1'> <option>hello</option></select> "
End Function
End Class
End Namespace
What gives? What am I doing incorrectly?
I followed all the following steps to add a custom function, my function compiles, but when I run it I get the following error-could not load type 'mynamespace.slug and pints me to the following line in showproduct.aspx.cs line 365
using (Xmlpackage2 p=new XMLpackage2(m_xmlpackage, this customer, skinID, "", "entityName=" + etc etc. I am currently making modifications to the product.variantsIntableCondensed,xml.config, pulling in data from an addition database which works fine until I started added this function.
I am calling the function with
<xsl: value-of select="myfunctions:getmyMF(/root/Fcusaweb/Info/MF)" disable-output-escaping="yes"/>
and my function is in the
App_Code/CustomFunctions.cs and the function is
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
///<summary>
/// This code will take the Molecular formula and convert the numbers to subscripts
///</summary>
///
namespace mynamespace
{
public class Slug
{
public string getmyMF(string MF)
{
string FixedMF=string.Empty;
string result;
//if ((MF).Length != 0)
if (MF==null)
{
result = MF;
return result;
}
else
for (int i = 1; i <= MF.Length; i++)
{
if (char.IsDigit(MF[i]))
{
FixedMF = FixedMF + "<SUB>" + MF[i] + "</SUB>";
}
else
{
FixedMF = FixedMF + MF[i];
}
}
return FixedMF;
}
}
}
I am new to this can someone help![]()
above code doesn't work because when extending XSLTExtensionBase, there is no empty parameter constructor. When the extension method is instantiated, it is looking for a constructor with zero parameters.
I used the code below to get the customer object, then set it to a global variable.
Customer = ((AspDotNetStorefrontPrincipal)HttpContext.Current .User).ThisCustomer;
This is some example code for how you would inherit from XSLTExtensionBase in C#
Code:public class CellUpFunctions : XSLTExtensionBase
Code:public CustomFunctions(Customer cust, int skin):base(cust, skin) { } public CustomFunctions(Customer cust, int skin, Dictionary<string,EntityHelper> helpers): base(cust, skin) { }