【问题标题】:"URI has an authority component" when resolving URI解析 URI 时“URI 具有权限组件”
【发布时间】:2022-07-07 17:05:33
【问题描述】:

我在网络位置上的 XSLT 转换期间尝试创建文档时收到“URI has an authority component”错误。

转换在我的电脑上本地运行良好。

我原来的模板是:

<xsl:template match="map">
        <xsl:variable name="model" select="translate(@product,' ','')"/>
        <xsl:variable name="documentType" select="lower-case(@platform)"/>
        <xsl:variable name="locale" select="lower-case(translate(@audience,'-','_'))"/>
        <xsl:variable name="directory"><xsl:value-of select="substring-before(base-uri(/),'/toc.ditamap')"/></xsl:variable>
        <xsl:variable name="bookName" select="concat($documentType,'_',$model,'_info_',$locale,'.xml')"/>
        
        <xsl:result-document href="{$directory}/{$bookName}">
            <info>
                <xsl:for-each select="//topicref">
                    <xsl:variable name="topicFileName" select="@href"/>
                    <xsl:call-template name="enterMetadata">
                        <xsl:with-param name="topicFileName" select="$directory/$topicFileName"/>
                    </xsl:call-template>
                </xsl:for-each>
            </info>
        </xsl:result-document>
    </xsl:template>

xsl:result-document 中的 URI 被(错误地)解析如下:

file:/C:/[somepath]/DITA/Operator%20Manual/om_CSUV_info_en_us.xml

所以我把模板改成了这个(我知道字符串替换不是一个好方法,但我试图至少得到一些输出):

<xsl:template match="map">
        <xsl:variable name="model" select="translate(@product,' ','')"/>
        <xsl:variable name="documentType" select="lower-case(@platform)"/>
        <xsl:variable name="locale" select="lower-case(translate(@audience,'-','_'))"/>
        <xsl:variable name="directory"><xsl:value-of select="substring-before(replace(base-uri(/),'file:/C:/','file:/'),'/toc.ditamap')"/></xsl:variable>
        <xsl:variable name="bookName" select="concat($documentType,'_',$model,'_info_',$locale,'.xml')"/>
        
        <xsl:result-document href="{$directory}/{$bookName}">
            <info>
                <xsl:for-each select="//topicref">
                    <xsl:variable name="topicFileName" select="@href"/>
                    <xsl:call-template name="enterMetadata">
                        <xsl:with-param name="topicFileName" select="$directory/$topicFileName"/>
                    </xsl:call-template>
                </xsl:for-each>
            </info>
        </xsl:result-document>
    </xsl:template>

现在我收到以下错误:

Error in xsl:result-document/@href on line 30 column 62 of metadata.xsl:

  Cannot write to URI

  file://[somepath]/Publishing/DITA/Operator%20Manual/om_CSUV_info_en_us.xml (URI has an authority component)


  in built-in template rule


Cannot write to URI file://[somepath]/Publishing/DITA/Operator%20Manual/om_CSUV_info_en_us.xml (URI has an authority component)

https://saxonica.plan.io/issues/4280 对同样的问题进行了详细的讨论,但我仍然不清楚如何才能使其正常工作。我不是程序员,我只是写 XSLT 脚本。

我正在使用 Saxon PE 9.7 .Net。

【问题讨论】:

  • 好吧,如果您认为这是链接的错误条目中的问题,请在修复后尝试发布,例如PE 9.9.1.5 或更高版本。另一方面,该问题似乎与 EXPath 函数有关,您是否正在使用它?如果您拼出导致错误的 URI,这将有所帮助,了解 [somepath] 真正代表什么可能很重要。您是否要写入本地磁盘上的本地文件,例如Windows 下的C: 驱动器,或者您是否尝试使用 UNC 写入本地网络上的另一台服务器?

标签: .net xslt uri saxon


【解决方案1】:

如果您想写入已经映射到本地文件系统路径的网络位置,您可能应该使用带有明确空权限组件的file: URI,例如file:///c%3A/blah/blah/blah.xml

【讨论】:

    猜你喜欢
    • 2015-08-22
    • 1970-01-01
    • 2015-08-17
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 1970-01-01
    • 2015-05-19
    • 2016-10-27
    相关资源
    最近更新 更多