1

我想调用 vbscript 函数:

 VBCustomScript 

在 xslt 文件中,但我收到以下错误:

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

请帮忙?

<?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>
4

1 回答 1

1

您正在使用样式表中的函数

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

但是该函数未在此样式表中声明,而是在您正在生成的样式表中声明

这:

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

是里面的模板匹配

 <xsl:template match="xsd:element">
于 2013-01-22T17:17:23.127 回答