我在显示 PDF 中的文档(图像/.pdf/.doc/.xls)的超链接时遇到问题。当用户点击超链接时,相应的文档(image/.pdf/.doc/.xls)必须显示在新窗口中。
书籍.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Book xmlns="http://book.com/one/1.2/" xmlns:ns2="http://test2.com/one/1.2/" xmlns:ns3="http://test3.com/one/1.2/" >
<Title>Java</Title>
<ISBN>123</ISBN>
<Author>Test</Author>
<BookDocument>
<ns2:DocumentName>images1.jpeg</ns2:DocumentName>
<ns2:DocumentContent>/aN2r9pT8HwKXpmvvmt2ifpz5xvmt2ifpz5xukZHBb9Wn4FL0xwW/VpD=</ns2:DocumentContent>
</BookDocument>
<BookDocument>
<ns2:DocumentName>images2.jpeg</ns2:DocumentName>
<ns2:DocumentContent>/aN2r9pT8HwKXpmvvmt2ifpz5xvmt2ifpz5xukZHBb9Wn4FL0x/VpD=</ns2:DocumentContent>
</BookDocument>
</Book>
书籍.xsl
<xsl:template match="*[local-name() = 'Book']">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="ex"
page-height="29.7cm" page-width="21cm" margin-top="2cm"
margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="ex">
<fo:flow flow-name="xsl-region-body">
<fo:block space-after="15mm">
</fo:block>
<fo:block font-size="16pt" font-weight="bold" space-after="5mm">
Book Details
</fo:block>
<fo:block font-size="10pt">
<fo:table table-layout="fixed" width="100%"
border-collapse="collapse" border="solid 1px black">
<fo:table-body>
<fo:table-row>
<fo:table-cell border="solid 1px black" padding="1mm">
<fo:block font-weight="bold">Title :</fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border="solid 1px black">
<fo:block>
<xsl:value-of select="*[local-name() = 'Title']" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="solid 1px black" padding="1mm">
<fo:block font-weight="bold">ISBN :
</fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border="solid 1px black">
<fo:block>
<xsl:value-of select="*[local-name() = 'ISBN']" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="solid 1px black" padding="1mm">
<fo:block font-weight="bold">Author :</fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border="solid 1px black">
<fo:block>
<xsl:value-of select="*[local-name() = 'Author']" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="solid 1px black" padding="1mm">
<fo:block font-weight="bold">Image Names :</fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border="solid 1px black">
<fo:block>
<xsl:for-each select="*[local-name() = 'BookDocument']">
<xsl:value-of select="*[local-name() = 'DocumentName']"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
里面的数据<ns2:DocumentContent>
是base64编码格式。我需要使用<ns2:DocumentContent>
. 请帮助我。
这是对 2013 年 6 月 19 日凯文评论的回复
嗨,凯文,我是 xslt 和 xsl-fo 的新手,正如您所说,我尝试使用 提供超链接<fo:basic-link>
,但未打开链接以显示附件。下面是我正在尝试的代码
<fo:basic-link padding-left="65mm" show-destination="new" text-decoration="underline">
<xsl:attribute name="external-destination">
<xsl:text>url('data:</xsl:text>
<xsl:value-of select="*[local-name() = 'FileType']" />
<xsl:text>;base64,</xsl:text>
<xsl:value-of select="*[local-name() = 'FileAttachment']" />
<xsl:text>')</xsl:text>
</xsl:attribute>
<fo:inline font-family="Arial" font-size="10pt" color="#0000ff" text-decoration="underline"><xsl:value-of select="*[local-name() = 'FileName']"/></fo:inline>
</fo:basic-link>
你能帮忙吗?