2014-10-30 105 views
2

我试图超链接一个值。超链接本身也存储在XML中。这用于输出pdf的订单项。XSLT:将XML超链接添加到另一个XML值

这是我当前的代码:

<fo:block font-size="8pt"> 
    <fo:inline> 
    <xsl:value-of select="substring-before(_preload_product_id, &quot; - &quot;)" /> 
    </fo:inline> 
</fo:block> 

我希望能够以超链接添加到字符串。实际的URL链接,就像我提到的,来自于XML以及因此它看起来像这样我的XSL:

<xsl:value-of select="cf_customer_quotation_line_item_product_url" /> 

我一直在四处寻找,但我经常发现代码较侧重的网站,但我做的PDF。 我也想知道是否有可能这个相同的超链接添加到图像象下面这样:

<fo:block> 
    <fo:external-graphic src="url()" content-height="2cm"> 
      <xsl:attribute name="src"> 
       <xsl:value-of select="cf_customer_quotation_line_item_image_url"/> 
      </xsl:attribute>           
    </fo:external-graphic> 
</fo:block> 
+0

你在使用什么渲染引擎?这可能是该产品的一个特征。我会看看我使用的产品并回馈给你。 – biscuit314 2014-10-30 18:45:29

+0

完全不确定,但是这个PDF是在一个名为Workbooks CRM的产品中生成的。 xml version =“1.0”encoding =“UTF-8” – idxearo 2014-10-30 18:55:58

回答

0

包装你的形象(或任何你想成为一个链接)在fo:basic-link

对于例如:

<fo:block> 
    <fo:basic-link external-link="url(--url to link destination--)"> 
     <fo:external-graphic src="url(--url to image--)" content-height="2cm" /> 
    </fo:basic-link>  
</fo:block> 

以一些具体数值为例。我的硬盘上有一张图片d:\images\smiley.jpg。超链接的目标的URL是一个元素访问从您的XSL命名cf_customer_quotation_line_item_product_url(如你的例子),以上变为:

<fo:block> 
    <fo:basic-link external-link="url({cf_customer_quotation_line_item_product_url})"> 
     <fo:external-graphic src="url(d:\images\smiley.jpg)" content-height="2cm" /> 
    </fo:basic-link>  
</fo:block> 

external-link的URL的花括号()值,导致评估样的像value-of但属于一个属性。

进一步编辑(根据您的回复):

更改此

<fo:block> 
    <fo:basic-link> 
    <xsl:attribute name="external-destination"> 
    <xsl:value-of select="cf_customer_quotation_line_item_product_url"/> 
    </xsl:attribute> 
     <fo:external-graphic src="url()" content-height="2cm"> 
     <xsl:attribute name="src"> 
     <xsl:value-of select="cf_customer_quotation_line_item_image_url"/> 
     </xsl:attribute>           
     </fo:external-graphic> 
    </fo:basic-link> 
</fo:block> 

这个

<fo:block> 
    <fo:basic-link external-destination="url({cf_customer_quotation_line_item_product_url})" text-altitude="2cm"> 
     <fo:external-graphic src="url({cf_customer_quotation_line_item_image_url})" content-height="2cm" /> 
    </fo:basic-link> 
</fo:block> 

如果你发现还是不行,请尝试单击底部的图像 - 它可能是超文本区域只是“文本高”。如果发生这种情况,请将text-altitude添加到与图像高度相同的fo:basic-link(我已更新上述示例)。

+0

饼干, 我用你的代码替换了我的代码,它和我的代码含义相同,图像没有超链接。尽管如此,图像仍然显示,所以至少没有中断。 – idxearo 2014-10-30 19:30:59

+0

@idxearo我做了另一个编辑。使用您的代码,链接是否显示在图像的底部?如果是这样,请将'text-altitude'添加到链接。 – biscuit314 2014-10-30 19:36:05

+0

你最初是正确的,“链接”低于图像在一个小的小区域。我已经添加了文字高度,因为您已经修改,但这不起作用。我相信我可能已经在某处看到文本高度在PDFS上不起作用(不确定PDF使用的引擎/ XSL类型的正确词语)。这个高度属性有不同的语法吗? 编辑称为FOP的文字海拔不起作用 – idxearo 2014-10-30 19:44:54

相关问题