Generating PDF from XML using XSL:FO. Transforming the hyperlink content from XML to PDF

♀尐吖头ヾ 提交于 2019-12-11 15:44:18

问题


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>

回答1:


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>

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

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.

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.



来源:https://stackoverflow.com/questions/52711204/generating-pdf-from-xml-using-xslfo-transforming-the-hyperlink-content-from-xm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!