1

i want call the vbscript function:

 VBCustomScript 

inside xslt file but i get the following error:

 Error (0x80004005): Namespace 'extra-functions' does not contain any functions. 

please any help?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:x="http://www.w3.org/1999/XSL/Transform-alternate" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:lsd="http://www.lodestar.com"
    xmlns:i="urn:ls-i18n-formatter"
    exclude-result-prefixes="xsl xsd lsd">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:namespace-alias stylesheet-prefix="x" result-prefix="xsl"/>
<xsl:param name="Exclude">UIDACCOUNT</xsl:param>
<xsl:param name="Include">UIDACCOUNT</xsl:param>
<xsl:variable name="DateSep" select="i:GetLocaleData(29)" />
<xsl:param name="RslvPrefix">RSLV_</xsl:param>
<xsl:param name="RslvSuffix">.RSLV</xsl:param>
<xsl:template match="xsd:element">
    <x:stylesheet version="1.0"
    xmlns:i="urn:ls-i18n-formatter"
    xmlns:ms="urn:schemas-microsoft-com:xslt"
    xmlns:user="http://www.lodestarcorp.com/user"
    xmlns:extra="urn:extra-functions"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    exclude-result-prefixes="i ms user extra msxml"
    > 

<x:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

<ms:script language="JScript" implements-prefix="user">
    function MonthYear(val, sep) {
        var mon= "00" + (val &amp; 0x000f);
        return !val ? "" : ("" + mon.substr(mon.length - 2) + sep + ((val &amp; 0xffff) &gt;&gt; 4));
    }
</ms:script>
<msxsl:script xmlns:msxsl="urn:schemas-microsoft-com:xslt"
language="VBScript" implements-prefix="extra">
    function VBCustomScript(str)
        VBCustomScript= "test"
    end function 
</msxsl:script>
<x:template match="ENTITIES">
    <xsl:variable name="LookupSecondary" select="xsd:keyref/xsd:field[position() &gt; 1]/@xpath"/>
    <xsl:variable name="Fields" 
        select="xsd:complexType/xsd:attribute[not(contains($Exclude, @name) or @lsd:ISUID='Y' or @name= 'COLLECTIONHISTNUM' or @name='LSUSER' or @name='LSTIME' or @type = 'BLOB' or @type = 'Bit' or @name = $LookupSecondary)]"/>

    <table class="Stripy" cellpadding="2" cellspacing="0" border="0">
        <thead><tr>
            <th onclick='event.cancelBubble=true'>&#160;</th>
            <xsl:if test="@name[.='METERHISTORY']">
                <th>&#160;</th>
            </xsl:if>
            <xsl:for-each select="$Fields">
                <xsl:sort select="@lsd:COLUMNNUMBER" data-type="number" />
                <th nowrap="" onclick="">
                    <xsl:if test="@type != 'XML_DOCUMENT'">
                        <xsl:attribute name="onclick">NavSort('<xsl:value-of select="@name"/>')</xsl:attribute>
                    </xsl:if>
                    <xsl:variable name="Lookup" select="../../xsd:keyref[xsd:field/@xpath=current()/@name]"/>
                    <xsl:variable name="LookupTable" select="//xsd:element[xsd:key/@name=$Lookup/@refer]"/>

                    <xsl:choose>
                          <xsl:when test="$Lookup">
                            <xsl:value-of select="i:FM(concat('tables/',$LookupTable/@name, '/ref/', ../../@name, '/', @name))"/>
                          </xsl:when>
                          <xsl:when test="@name='URL_CONVERTITORE'">
                            Foto Co
                          </xsl:when>
                          <xsl:when test="@name='URL_MISURATORE'">
                            Foto Mi
                          </xsl:when>
                          <xsl:otherwise>
                            <xsl:value-of select="i:FM(concat('tables/', ../../@name, '/fld/', @name))"/>
                          </xsl:otherwise>
                    </xsl:choose>
                </th>
            </xsl:for-each>
            <th nowrap="" onclick="">
            CAMPO DI PROVA
            </th>
        </tr></thead>
        <tbody>
            <xsl:variable name="Params" select="xsd:complexType/xsd:attribute[@lsd:ISUID='Y' or (@lsd:ISIDENTITY='Y' and not(../xsd:attribute[@lsd:ISUID='Y']))]"/>
            <x:for-each select="*">
                <tr class="r{{position() mod 2}}" onclick="event.cancelBubble=true;" id="r{{position()}}">
                    <td>
                    <a>
                        <xsl:attribute name="href">javascript:Edit('<xsl:for-each select="$Params">
                                <xsl:value-of select="@name"/>:{<xsl:choose>
                                    <xsl:when test="@type='UID' or @type='Small_UID'">substring-before(concat(@<xsl:value-of select="@name"/>, ":"), ":")</xsl:when>
                                    <xsl:otherwise>@<xsl:value-of select="@name"/></xsl:otherwise>
                                </xsl:choose>}<xsl:if test="position() &lt; last()">;</xsl:if>
                            </xsl:for-each>')
                        </xsl:attribute>[...]
                    </a>
                            <xsl:variable name="Params1" select="xsd:complexType/xsd:attribute[@name='UIDREAD']"/>
                            <input type = "checkbox" id="{{position()}}"  onclick="change(id);">
                                <xsl:attribute name="value">{
                                    @<xsl:value-of select="$Params1/@name"/>
                                }</xsl:attribute>
                                <xsl:attribute name="name">uidread</xsl:attribute>
                            </input>
                    </td>
                    <xsl:if test="@name[.='METERHISTORY']">
                        <td>
                            <a href="#">
                            <xsl:attribute name="onclick">ShowMeterRead('{@UIDMETERHISTORY}')</xsl:attribute>
                            &lt;...&gt;
                            </a>
                        </td>
                    </xsl:if>
                    <xsl:for-each select="$Fields">
                        <xsl:sort select="@lsd:COLUMNNUMBER" data-type="number" />
                        <xsl:variable name="Type" select="//xsd:simpleType[@name=current()/@type]"/>
                        <xsl:variable name="Field" select="."/>
                        <td align="center">
                            <xsl:choose>

                                <xsl:when test="$Type//xsd:enumeration">
                                    <x:choose>
                                        <xsl:for-each select="$Type//xsd:enumeration">
                                            <!-- GESTIONE DEL TIPO MITTENTE -->
                                            <x:when test="@{$Field/@name} = '{@value}' and '{$Type/@name}' = 'ITGp2_SENDERTYPE_DOMMD'">
                                              <xsl:value-of select="concat($Type/@name, '@', @value)"/>
                                            </x:when>

                                            <x:when test="@{$Field/@name} = '{@value}' and '{$Type/@name}' != 'ITGp2_SENDERTYPE_DOMMD'">                        
                                              <xsl:value-of select="i:FM(concat('types/typename[@id=&quot;', $Type/@name, '&quot;]/value[@id=&quot;', @value, '&quot;]'))"/>
                                            </x:when>
                                        </xsl:for-each>
                                          <x:when test="'{$Field/@name}' = 'SENDERTYPE'">
                                            <x:value-of select="concat('ITGp2_SENDERTYPE_DOMMD@',@{@name})" />
                                          </x:when>
                                        <x:otherwise><x:value-of select="@{@name}" />&#160;</x:otherwise>
                                    </x:choose>
                                </xsl:when>
                                <!--Aggiunta F. Perricone per fotoletture in data 21/02/2011-->
                                <xsl:when test="@name='URL_MISURATORE' or @name='URL_CONVERTITORE'">
                                  <x:if test="(@{@name})!=''">
                                    <xsl:variable name="Params1" select="xsd:complexType/xsd:attribute[*]"/>
                                    <img style="cursor:hand" src="../cust_facility/images/fotocamera.png" alt="Fotolettura">
                                      <xsl:attribute name="onclick">javascript : ShowPhoto('<xsl:value-of select="@name"/>;<xsl:for-each select="$Fields">
                                        <xsl:if test="@name='STOPREADTIME' or @name='STOPREADING' or @name='CORRSTOPREAD' or @name='UIDMETER' or @name='UIDREADSHEET'">
                                        <xsl:value-of select="@name"/>|{<xsl:choose>
                                          <xsl:when test="@type='UID' or @type='Small_UID'">
                                            substring-before(concat(@<xsl:value-of select="@name"/>, "|"), "|")
                                          </xsl:when>
                                          <xsl:otherwise>
                                            @<xsl:value-of select="@name"/>
                                          </xsl:otherwise>
                                        </xsl:choose>}<xsl:if test="position() &lt; last()">;</xsl:if>
                                        </xsl:if>
                                      </xsl:for-each>')</xsl:attribute></img>
                                  </x:if>
                                </xsl:when>
                                <!--FINE Aggiunta F. Perricone per fotoletture in data 21/02/2011-->
                                <xsl:when test="@type='UID' or @type='Small_UID'"><x:value-of select=" @{@name}{$RslvSuffix} "/></xsl:when>
                                <xsl:when test="@type = 'Float' or @type = 'Real'">
                                    <x:value-of select="@{@name}"/>
                                </xsl:when>
                                <xsl:when test="$Type/xsd:restriction/@base='xsd:decimal'">
                                    <x:value-of select="i:FR( @{@name}, {$Type/xsd:restriction/xsd:fractionDigits/@value}, 1 )"/>
                                </xsl:when>
                                <xsl:when test="@type = 'Date'"><x:value-of select="i:FD(@{@name})"/></xsl:when>
                                <xsl:when test="@type = 'Timestamp'"><x:value-of select="i:FD(@{@name}, 2, 4)"/></xsl:when>
                                <xsl:when test="@type = 'Bill_Month'">
                                    <x:if test="@{@name}">
                                        <x:value-of select="user:MonthYear(number(@{@name}), '{$DateSep}')"/>
                                    </x:if>
                                </xsl:when>
                            <xsl:otherwise>
                            <x:value-of select="@{@name}" />
                            </xsl:otherwise>
                            </xsl:choose>&#160;
                        </td>
                    </xsl:for-each>
                    <td>
                     <xsl:value-of select="extra:VBCustomScript(string(@UIDMETERHISTORY))"/> 
                    </td>
                </tr>
            </x:for-each>
        </tbody>
    </table>
</x:template>
</x:stylesheet>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
5
  • Well which XSLT processor do you use? Does its documentation say it supports writing extension function using VB or VBScript with the ms:script element in the namespace urn:schemas-microsoft-com:xslt? That is a non standard feature introduced by Microsoft's MSXML, further supported with the .NET versions of Microsoft's XSLT processors (XslCompiledTransform, XslTransform) and I think these days supported by some XSLT 2.0 processors like AltovaXML and XmlPrime. But other XSLT 2.0 processors like Saxon do not support that. And even with MSXML and XslCompiledTransform there are differences Commented Jan 22, 2013 at 14:24
  • sorry for the noob answer but how i know if urn:schemas-microsoft-com:xslt support the vbscript function? Commented Jan 22, 2013 at 14:31
  • 1
    Are you using this XSLT in a web browser? If so, which one? I think it's likely to only work in IE. If not, could you show us the code you're using to execute the XSLT? Commented Jan 22, 2013 at 14:40
  • Which software do you use to run the XSLT, which software is that that says "Error (0x80004005): Namespace 'extra-functions' does not contain any functions.". As for support of VBScript to implement extension functions, MSXML 3,4,5 and 6 do support that. Default security settings in MSXML 6 might however disallow that. XslCompiledTransform support VB.NET, not VBScript. For AltovaXML and XmlPrime I would need to check the documentation. Commented Jan 22, 2013 at 14:42
  • The provided code doesn't have any extension functions defined in the namespace (i:) "urn:ls-i18n-formatter". Please, edit the question and provide these. Also, it seems that your XSLT processor isn't MSXML -- and this is likely the reason VBScript extension functions aren't recognized by it. Commented Jan 22, 2013 at 15:33

1 Answer 1

1

You are using the function in this stylesheet

                     <xsl:value-of select="extra:VBCustomScript(string(@UIDMETERHISTORY))"/> 

But the function is not declared in this stylesheet it is declared in the stylesheet that you are generating

This:

<msxsl:script xmlns:msxsl="urn:schemas-microsoft-com:xslt"
language="VBScript" implements-prefix="extra">
    function VBCustomScript(str)
        VBCustomScript= "test"
    end function 
</msxsl:script>

Is inside the template matching

 <xsl:template match="xsd:element">
Sign up to request clarification or add additional context in comments.

2 Comments

i can't say it anymore cause i left this way to edit the file but i think it is a google answer i have to check it when i have the time but ok i get it as good answer
i have used javascript with table editing at run time... so i didn't need to modify the xslt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.