Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt XPath选择器在PDF转换期间不工作_Xslt_Xpath_Dita - Fatal编程技术网

Xslt XPath选择器在PDF转换期间不工作

Xslt XPath选择器在PDF转换期间不工作,xslt,xpath,dita,Xslt,Xpath,Dita,我有一个DITA bookmap,用于存储图像路径: <bookmap> <bookmeta> <data id="productLogo"> <image href="images/_notrans/frontcover/productLogo.svg" /> </data> <data id="productPhoto" >

我有一个DITA bookmap,用于存储图像路径:

<bookmap>
    <bookmeta>
        <data id="productLogo">
            <image href="images/_notrans/frontcover/productLogo.svg" />
        </data>
        <data id="productPhoto" >
            <image href="images/_notrans/frontcover/productPhoto.jpg" />
        </data>
    </bookmeta>
</bookmap>

然后我尝试通过数据[@id]获取href值:

<xsl:variable name="productLogo"><xsl:value-of select="//data[@id='productLogo']/image/@href" /></xsl:variable>
<xsl:variable name="productPhoto"><xsl:value-of select="//data[@id='productPhoto']/image/@href" /></xsl:variable> 

(当我在Oxygen中测试bookmap时,这些XPath表达式与href匹配。)

在转换I输出期间:

<xsl:message>productPhoto: <xsl:value-of select="$productPhoto"/></xsl:message>
productPhoto:
的值始终为空

但是,如果我将id属性替换为数字,则一切正常:

<xsl:variable name="productLogo"><xsl:value-of select="//data[1]/image/@href" /></xsl:variable>
<xsl:variable name="productPhoto"><xsl:value-of select="//data[2]/image/@href" /></xsl:variable> 


我做错了什么阻止使用@id=“whatever”

XSLT不是直接应用于Bookmap内容,而是应用于包含Bookmap的XML文档,其中所有主题引用都在其中展开,并对其应用了一些预处理。 如果将“clean.temp”参数设置为“no”,您将在临时文件文件夹中找到一个名为“mapName_MERGED.xml”的文件,这是应用XSLT的xml文档,您将在其中看到,所有ID都已更改为在整个xml文档的上下文中唯一

通常使用数据元素时,应将@name属性设置为如下所示:

并在XSLT代码中匹配该名称。 DITA 1.2规范中也有使用“数据”的示例:


另一个选项是根据需要为产品照片制定命名约定,并使用元素构建URI。由于产品系列的产品徽标不应更改,因此在XSLT代码中硬编码也不会有什么坏处。

这对Radu来说非常有意义。使用名称而不是id非常有效。非常感谢。