问题
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&did=jsjsj)">test</fo:basic-link>
The URI has to be well-formed XML, so the &
in your example has to be &
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