使用 XSL:FO 从 XML 生成 PDF.将超链接内容从 XML 转换为 PDF [英] Generating PDF from XML using XSL:FO. Transforming the hyperlink content from XML to PDF

查看:25
本文介绍了使用 XSL:FO 从 XML 生成 PDF.将超链接内容从 XML 转换为 PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 XSL:FO 将以下包含超链接标签的 XML 转换为 PDF

How to transform the below XML that contains the hyperlink tag to PDF using XSL:FO

    <paragraphs>
     <paragraph>ahsbdgdgdg<a href="https://aaaa.com/xsd &did=jsjsj">Test</a>
     </paragraph>
    </paragraphs>

推荐答案

Use fo:basic-link (https://www.w3.org/TR/xsl11/#fo_basic-link) 并将 URI 放入 external-destination(https://www.w3.org/TR/xsl11/#external-destination):

Use fo:basic-link (https://www.w3.org/TR/xsl11/#fo_basic-link) and put the URI in external-destination (https://www.w3.org/TR/xsl11/#external-destination):

<fo:basic-link
  external-destination="url(https://aaaa.com/xsd%20&amp;did=jsjsj)">test</fo:basic-link>

URI 必须是格式良好的 XML,因此示例中的 & 必须是 XML 中的 &.

The URI has to be well-formed XML, so the & in your example has to be &amp; in your XML.

您是否需要将空格转义为 %20 可能取决于您使用的格式化程序.如果您使用的是 XSLT 2.0 或 XSLT 3.0,那么您将拥有可用于转义 URI 的内置函数.

Whether or not you need to escape the space as %20 possibly depends on which formatter you are using. If you were using XSLT 2.0 or XSLT 3.0, you would have built-in functions available to you for escaping the URI.

XSL 1.1 Recommendation 说您需要在 URI 之前和之后使用 url(),但可能大多数格式化程序会让您忽略它.

The XSL 1.1 Recommendation says that you need url( and ) before and after the URI, but probably most formatters will let you omit that.

这篇关于使用 XSL:FO 从 XML 生成 PDF.将超链接内容从 XML 转换为 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆