Extending C1

Topics: General, XSLT
Jun 11, 2011 at 1:47 AM

I currently have an ecommerce site that I use that for the most part is xslt driven, that said I would like to take all the xsl files and import them into C1 XSLT Function to be used in my pages. my issue I am having that I can't wrap my head around is registering the xslns tags. I am a windows/asp.net developer so xslt is very new and learning more and more everyday. is there some documents or a walkthrough I could follow?

here is an example xslt package that I am trying to integrate

<?xml version="1.0" standalone="yes" ?>
<package version="2.1" displayname="Staff Page" debug="false">

 <query name="StaffArticles" rowElementName="Article">
                select StaffID, Name, Title, Bio, Phone, FAX, EMail, DisplayOrder, Wholesale, ExtensionData from Staff with (nolock)
                where Published=1 and Deleted=0
                order by DisplayOrder, Name desc

        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xre="urn:xre" exclude-result-prefixes="xre">
         <xsl:output method="html" omit-xml-declaration="yes" />

            <xsl:param name="LocaleSetting" select="/root/Runtime/LocaleSetting" />
            <xsl:param name="WebConfigLocaleSetting" select="/root/Runtime/WebConfigLocaleSetting" />

            <xsl:template match="/">
                    <table width="100%" cellpadding="2" cellspacing="0" border="0">
                        <xsl:apply-templates select="/root/StaffArticles/Article" />
                <table width="100%" cellpadding="2" cellspacing="0" border="0">


            <xsl:template match="Article">
                        <td align="left" valign="top">
      <xsl:value-of select="xre:LookupImage(StaffID, 'staff', 'medium', 0)" disable-output-escaping="yes"/>
      <td align="left" valign="top">
      <b><xsl:value-of select="Name" disable-output-escaping="yes"/></b>
      <xsl:value-of select="Bio" disable-output-escaping="yes"/>
     <tr><td colspan="2" height="5"><img src="images/spacer.gif" width="10" height="5"/></td></tr>

as you can see there is a xre tag to register somewhere and also all the paths start with /root/ I am assuming I will have to change them to /Page/ but not to sure. again xslt is new to me but liking it

Jun 24, 2011 at 8:16 AM

If we talking about xre tag / xslt.. - such functionality could be done at least in 2 ways:
1) C# in XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl in lang"

notice xmlns:csharp here, instead csharp you can write any non-used name.


	<msxsl:script implements-prefix="csharp" language="C#" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
		<msxsl:assembly name="Composite"/>
		<msxsl:using namespace="Composite.Core.ResourceSystem"/>
		public string Localize(string providerName, string label)
			return StringResourceSystemFacade.GetString(providerName, label);

and u can use it:

<xsl:value-of select="csharp:Localize('Composite.Community.Extranet', 'LoginStatus.Login')" />

2) XSLT extentions (my favourite, more clean and nice):
In App_Data\Composite\Composite.config add "AeontXsltExtensionsFunction" (if you have your code in App_Code) or like "ShopXsltExtensions" if you have your code in dll:

      <add name="ConfigurationBasedXslExtensionsProvider" type="Composite.Plugins.Functions.XslExtensionsProviders.ConfigBasedXslExtensionsProvider.ConfigBasedXslExtensionsProvider">
		<add name="#AeontXsltExtensionsFunction" type="Aeont.C1.Library.XsltExtensionsFacade, App_Code" />
		<add name="#ShopXsltExtensions" type="Shop.ShopXsltExtensions, Shop" />

 than add it:  xmlns:s="#ShopXsltExtensions" and use same way.

I've checked your xslt.. you have to re-done it a bit in order to work with C1.. first of all - sql - create sql function - http://docs.composite.net/C1/XSLT/SQLFunctions.aspx and use it's output OR if it's something complex - create C# function, get your data from sql here and via function call in XSLT function use its data.