2013-01-22 24 views
1

我想調用VBScript函數:從XSLT錯誤調用函數:命名空間不包含任何功能

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('[email protected]',@{@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> 
+0

那麼您使用哪種XSLT處理器?它的文檔是否說它支持使用VB或VBScript在命名空間'urn:schemas-microsoft-com:xslt'中使用'ms:script'元素來編寫擴展函數?這是Microsoft的MSXML引入的非標準功能,進一步得到了微軟XSLT處理器的.NET版本('XslCompiledTransform','XslTransform')的支持,我認爲這些日子受到AltovaXML和XmlPrime等XSLT 2.0處理器的支持。但是像Saxon這樣的其他XSLT 2.0處理器不支持這一點。即使與MSXML和XslCompiledTransform有區別 –

+0

對於noob答案感到抱歉,但我怎麼知道如果urn:schemas-microsoft-com:xslt支持vbscript函數? –

+1

您是否在Web瀏覽器中使用此XSLT?如果是這樣,哪一個?我認爲這可能只適用於IE。如果沒有,你能告訴我們你用來執行XSLT的代碼嗎? – JLRishe

回答

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"> 
+0

我不能再說了,因爲我離開這種方式來編輯文件,但我認爲這是一個谷歌的答案我必須檢查它,當我有時間,但好吧我把它作爲好的答案 –

+0

我在運行時使用了javascript和表格編輯...所以我不需要修改xslt –