我有一个 XML 文件,其中包含以文件名开头的部分:
<madcapfile filename="C:\1\Outputpath\The 7% solution.xlf">
每个部分必须保存到单独的文件中。
这是我的 XSLT:
<xsl:template match="madcapfile">
<xsl:variable name="file1" select="concat('file:///',@filename)"/>
<xsl:variable name="file2" select="encode-for-uri($file1)"/>
<xsl:variable name="file3" select="concat('file:///',replace(@filename,'%','%25'))"/>
<xsl:result-document method="xml" href="{$file2}">
<xsl:apply-templates select="node()"/>
</xsl:result-document>
</xsl:template>
变量 file1、file2、file3 是我迄今为止的尝试。
变量 file1 在所有文件的正确位置创建文件(文件名中带有 % 的文件除外)。
变量 file3 在所有文件的正确位置创建文件,因此这是一个可行的解决方案。
使用变量 file2 会出现错误:XSLT 处理器 (Saxon 9.7) 尝试将文件写入
C:\Path-to-XSLT\C:\1\Outputpath\The 7% solution.xlf
即它看起来像encode-for-uri 将其输入视为相对路径,即使它以“C:\”开头
我还尝试将“file:///”添加到路径的开头,这不会改变encode-for-uri的行为。
有没有办法强制encode-for-uri 将其输入视为绝对路径?