2013-10-06 19 views
0

請幫助我解釋和建議我應該如何處理以下情況。 我必須使用Excel 2007/2010宏將一個XML轉換爲另一個XML,並嘗試使用Altove MapForce工具,該工具大約6年前在Java中用於XSLT時沒有任何問題。映射XML(應該是一個樣式表)複製到下面。但是,Excel VB執行會引發有關xmlns的錯誤消息:fn =「http://www.w3.org/2005/xpath-functions」不包含任何函數。MapForce 2013「映射」爲適用於Excel 2010宏的XSLT

我確實使用MapfForce庫中的「contains」和「if-else」等轉換函數。

出了什麼問題?

我將非常感謝在這方面的任何幫助(特別是,我需要及時)。

問候, 邁克 -

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:core="http://www.altova.com/MapForce/UDF/core" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="core xs fn"> 
<xsl:template name="core:convert-uri-to-windows-file-path"> 
    <xsl:param name="uri" select="()"/> 
    <xsl:choose> 
     <xsl:when test="fn:starts-with($uri, 'file://')"> 
      <xsl:choose> 
       <xsl:when test="(fn:substring($uri, xs:double('6'), xs:double('3')) = '///')"> 
        <xsl:variable name="var1_resultof_url_decode" as="xs:string"> 
         <xsl:call-template name="core:url-decode"> 
          <xsl:with-param name="uri" select="fn:substring($uri, xs:double('9'), xs:double(fn:string-length($uri)))" as="xs:string"/> 
         </xsl:call-template> 
        </xsl:variable> 
        <xsl:sequence select="fn:translate($var1_resultof_url_decode, '/|', '\:')"/> 
       </xsl:when> 
       <xsl:otherwise> 
        <xsl:sequence select="$uri"/> 
       </xsl:otherwise> 
      </xsl:choose> 
     </xsl:when> 
     <xsl:otherwise> 
      <xsl:sequence select="$uri"/> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:template> 
<xsl:template name="core:url-decode"> 
    <xsl:param name="uri" select="()"/> 
    <xsl:choose> 
     <xsl:when test="fn:contains($uri, '%')"> 
      <xsl:variable name="var1_resultof_url_decode_part" as="xs:string"> 
       <xsl:call-template name="core:url-decode-part"> 
        <xsl:with-param name="uripart" select="fn:substring-after($uri, '%')" as="xs:string"/> 
       </xsl:call-template> 
      </xsl:variable> 
      <xsl:sequence select="fn:concat(fn:substring-before($uri, '%'), $var1_resultof_url_decode_part)"/> 
     </xsl:when> 
     <xsl:otherwise> 
      <xsl:sequence select="$uri"/> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:template> 
<xsl:template name="core:url-decode-part"> 

回答

0

用Excel VBA中使用的XSL處理器只接受XSLT版本1,而你的XSLT是第2版。它看起來並不難將其轉換爲第1版,雖然 - 它似乎沒有使用任何版本2特定功能。

這是轉換爲您發佈的部分版本1:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template name="convert-uri-to-windows-file-path"> 
    <xsl:param name="uri"/> 
    <xsl:choose> 
     <xsl:when test="starts-with($uri, 'file://')"> 
     <xsl:choose> 
      <xsl:when test="substring($uri, 6, 3) = '///'"> 
      <xsl:variable name="var1_resultof_url_decode"> 
       <xsl:call-template name="url-decode"> 
       <xsl:with-param name="uri" select="substring($uri, 9, string-length($uri))"/> 
       </xsl:call-template> 
      </xsl:variable> 
      <xsl:value-of select="translate($var1_resultof_url_decode, '/|', '\:')"/> 
      </xsl:when> 
      <xsl:otherwise> 
      <xsl:value-of select="$uri"/> 
      </xsl:otherwise> 
     </xsl:choose> 
     </xsl:when> 
     <xsl:otherwise> 
     <xsl:value-of select="$uri"/> 
     </xsl:otherwise> 
    </xsl:choose> 
    </xsl:template> 
    <xsl:template name="url-decode"> 
    <xsl:param name="uri"/> 
    <xsl:choose> 
     <xsl:when test="contains($uri, '%')"> 
     <xsl:variable name="var1_resultof_url_decode_part"> 
      <xsl:call-template name="url-decode-part"> 
      <xsl:with-param name="uripart" select="substring-after($uri, '%')"/> 
      </xsl:call-template> 
     </xsl:variable> 
     <xsl:value-of select="concat(substring-before($uri, '%'), $var1_resultof_url_decode_part)"/> 
     </xsl:when> 
     <xsl:otherwise> 
     <xsl:value-of select="$uri"/> 
     </xsl:otherwise> 
    </xsl:choose> 
    </xsl:template>