<;fo:基本链接>;不创建可点击链接XSL-FO XSLT 1.0
鉴于此XML:<;fo:基本链接>;不创建可点击链接XSL-FO XSLT 1.0,xslt,hyperlink,xsl-fo,Xslt,Hyperlink,Xsl Fo,鉴于此XML: <figure id="fig-0011"> <title>Removal of Shipping Kit(s)</title> <graphic id="fig-0011-gra-0001" infoEntityIdent="66503-00129-A-001-01"></graphic> </figure> 这是正确的数字编号,但2不是指向图形的可单击链接 dmcode模板生成一个字符串。如果我将其从X
<figure id="fig-0011">
<title>Removal of Shipping Kit(s)</title>
<graphic id="fig-0011-gra-0001" infoEntityIdent="66503-00129-A-001-01"></graphic>
</figure>
这是正确的数字编号,但2不是指向图形的可单击链接
dmcode模板生成一个字符串。如果我将其从XSLT中删除,那么图形编号将不再链接到图形
我正在使用XSLT1.0。非常感谢您的帮助。第二个
internalRef
指的是图形。XSLT似乎没有将graphic/@id
复制到结果树中的FO中。使用AH格式化程序和不复制graphic/@id
的样式表,我没有得到任何链接和错误消息:
Unresolved internal-destination: "fig-0011-gra-0001".
当没有匹配的目标ID时,FO格式化程序似乎也没有创建链接
如果看不到您的xsl:key
声明、figure
和graphic
的模板,并且知道graphic
是否可以出现在figure
之外,我就帮不了您多少忙了
重新编辑为使用图/@id
和图/@id
:
<xsl:key name="id" match="*" use="@id" />
<xsl:variable name="prefix">
<xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode" />
</xsl:variable>
<xsl:template match="internalRef">
<xsl:for-each select="key('id', @internalRefId)">
<fo:basic-link internal-destination="{$prefix}{@id}">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" from="content" level="any" />
</fo:basic-link>
</xsl:for-each>
</xsl:template>
<xsl:template match="figure">
<fo:wrapper id="{@id}">
<xsl:apply-templates select="graphic" />
</fo:wrapper>
</xsl:template>
<xsl:template match="figure/graphic" priority="10">
<fo:block text-align="center" start-indent="0pt" color="black" keep-with-next="always">
<xsl:if test="@id">
<xsl:attribute name="id">
<xsl:value-of select="$prefix" />
<xsl:value-of select="@id" />
</xsl:attribute>
</xsl:if>
<xsl:call-template name="do-graphic">
<xsl:with-param name="include-graphic" select="true()" />
</xsl:call-template>
</fo:block>
<xsl:if test="position() = last()">
<xsl:apply-templates select="../legend" />
</xsl:if>
<xsl:if test="@infoEntityIdent">
<fo:block text-align="right" keep-with-previous="always">
<xsl:value-of select="@infoEntityIdent" />
</fo:block>
</xsl:if>
<fo:block font-weight="normal" font-style="italic" text-align="center" space-before="12pt" space-after="8pt" start-indent="0pt" keep-with-previous="always">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" level="any" format="1" from="content" />
<xsl:apply-templates select="../title" />
<xsl:variable name="numSheets" select="count(../graphic)" />
<xsl:choose>
<xsl:when test="$numSheets > 1">
<xsl:text> (Sheet </xsl:text>
<xsl:number count="graphic" level="any" format="1" from="figure" />
<xsl:text> of </xsl:text>
<xsl:value-of select="$numSheets" />
<xsl:text>)</xsl:text>
</xsl:when>
</xsl:choose>
</fo:block>
</xsl:template>
无花果
无花果
(张)
属于
)
我还将图形的ID移动到figure/graphic
模板中的第一个fo:block
。如果将它放在最后一个fo:block
上,则意味着您每次跟随图形链接时都会向上滚动查看图形。第二个internalRef
指的是图形。XSLT似乎没有将graphic/@id
复制到结果树中的FO中。使用AH格式化程序和不复制graphic/@id
的样式表,我没有得到任何链接和错误消息:
Unresolved internal-destination: "fig-0011-gra-0001".
当没有匹配的目标ID时,FO格式化程序似乎也没有创建链接
如果看不到您的xsl:key
声明、figure
和graphic
的模板,并且知道graphic
是否可以出现在figure
之外,我就帮不了您多少忙了
重新编辑为使用图/@id
和图/@id
:
<xsl:key name="id" match="*" use="@id" />
<xsl:variable name="prefix">
<xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode" />
</xsl:variable>
<xsl:template match="internalRef">
<xsl:for-each select="key('id', @internalRefId)">
<fo:basic-link internal-destination="{$prefix}{@id}">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" from="content" level="any" />
</fo:basic-link>
</xsl:for-each>
</xsl:template>
<xsl:template match="figure">
<fo:wrapper id="{@id}">
<xsl:apply-templates select="graphic" />
</fo:wrapper>
</xsl:template>
<xsl:template match="figure/graphic" priority="10">
<fo:block text-align="center" start-indent="0pt" color="black" keep-with-next="always">
<xsl:if test="@id">
<xsl:attribute name="id">
<xsl:value-of select="$prefix" />
<xsl:value-of select="@id" />
</xsl:attribute>
</xsl:if>
<xsl:call-template name="do-graphic">
<xsl:with-param name="include-graphic" select="true()" />
</xsl:call-template>
</fo:block>
<xsl:if test="position() = last()">
<xsl:apply-templates select="../legend" />
</xsl:if>
<xsl:if test="@infoEntityIdent">
<fo:block text-align="right" keep-with-previous="always">
<xsl:value-of select="@infoEntityIdent" />
</fo:block>
</xsl:if>
<fo:block font-weight="normal" font-style="italic" text-align="center" space-before="12pt" space-after="8pt" start-indent="0pt" keep-with-previous="always">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" level="any" format="1" from="content" />
<xsl:apply-templates select="../title" />
<xsl:variable name="numSheets" select="count(../graphic)" />
<xsl:choose>
<xsl:when test="$numSheets > 1">
<xsl:text> (Sheet </xsl:text>
<xsl:number count="graphic" level="any" format="1" from="figure" />
<xsl:text> of </xsl:text>
<xsl:value-of select="$numSheets" />
<xsl:text>)</xsl:text>
</xsl:when>
</xsl:choose>
</fo:block>
</xsl:template>
无花果
无花果
(张)
属于
)
我还将图形的ID移动到figure/graphic
模板中的第一个fo:block
。将其放在最后一个fo:block
上意味着每次跟随图形链接时都要向上滚动查看图形。建议将
添加到do图形模板中的
,这似乎解决了问题:
<xsl:template name="do-graphic">
<xsl:param name="include-graphic" select="true()"/>
<xsl:variable name="content-width">
<xsl:choose>
<xsl:when test="@reproductionWidth != ''">
<xsl:value-of select="@reproductionWidth"/>
<xsl:call-template name="checkForUom">
<xsl:with-param name="measure" select="@reproductionWidth"/>
</xsl:call-template>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="@reproductionScale != ''">
<xsl:value-of select="@reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="content-height">
<xsl:choose>
<xsl:when test="@reproductionHeight != ''">
<xsl:value-of select="@reproductionHeight"/>
<xsl:call-template name="checkForUom">
<xsl:with-param name="measure" select="@reproductionWidth"/>
</xsl:call-template>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="@reproductionScale != ''">
<xsl:value-of select="@reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$include-graphic">
<fo:external-graphic src="{unparsed-entity-uri(@infoEntityIdent)}" scaling="uniform" content-height="{$content-height}" content-width="{$content-width}">
<xsl:attribute name="id"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="@id"/></xsl:attribute>
</fo:external-graphic>
</xsl:when>
<xsl:otherwise>
<fo:inline-container display-align="center" text-align="center" block-progression-dimension="{$content-height}" inline-progression-dimension="{$content-width}" background-color="silver" color="red">
<fo:block>Graphic Not Included</fo:block>
</fo:inline-container>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
%
95%
%
95%
不包括图形
建议将
添加到do图形模板中的
,这似乎解决了问题:
<xsl:template name="do-graphic">
<xsl:param name="include-graphic" select="true()"/>
<xsl:variable name="content-width">
<xsl:choose>
<xsl:when test="@reproductionWidth != ''">
<xsl:value-of select="@reproductionWidth"/>
<xsl:call-template name="checkForUom">
<xsl:with-param name="measure" select="@reproductionWidth"/>
</xsl:call-template>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="@reproductionScale != ''">
<xsl:value-of select="@reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="content-height">
<xsl:choose>
<xsl:when test="@reproductionHeight != ''">
<xsl:value-of select="@reproductionHeight"/>
<xsl:call-template name="checkForUom">
<xsl:with-param name="measure" select="@reproductionWidth"/>
</xsl:call-template>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="@reproductionScale != ''">
<xsl:value-of select="@reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$include-graphic">
<fo:external-graphic src="{unparsed-entity-uri(@infoEntityIdent)}" scaling="uniform" content-height="{$content-height}" content-width="{$content-width}">
<xsl:attribute name="id"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="@id"/></xsl:attribute>
</fo:external-graphic>
</xsl:when>
<xsl:otherwise>
<fo:inline-container display-align="center" text-align="center" block-progression-dimension="{$content-height}" inline-progression-dimension="{$content-width}" background-color="silver" color="red">
<fo:block>Graphic Not Included</fo:block>
</fo:inline-container>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
%
95%
%
95%
不包括图形
谢谢,托尼<代码>图形
不能超出图形
。托尼,非常感谢您抽出时间。我确实是为了配合你的建议才这样做的,但是,通常每个图都有一个以上的图形,正如预期的那样,链接总是指向第一个图。还有其他带有ID的项,比如表
,所以我在xsl:key
声明中添加了
,效果很好。你的解决方案比我的有所改进。我的格式化程序是Antenna House 6.2。谢谢,Tony,我确实获得了图形链接,可以使用您修改的代码。AH支持人员指出,我需要在
中添加一个
,这更容易实现。我很感谢你的努力。谢谢,托尼<代码>图形
不能超出图形
。托尼,非常感谢您抽出时间。我确实是为了配合你的建议才这样做的,但是,通常每个图都有一个以上的图形,正如预期的那样,链接总是指向第一个图。还有其他带有ID的项,比如表
,所以我在xsl:key
声明中添加了
,效果很好。你的解决方案比我的有所改进。我的格式化程序是天线屋6.2。谢谢,托尼,我确实获得了图形链接,可以与您的re一起使用
Unresolved internal-destination: "fig-0011-gra-0001".
<xsl:key name="id" match="*" use="@id" />
<xsl:variable name="prefix">
<xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode" />
</xsl:variable>
<xsl:template match="internalRef">
<xsl:for-each select="key('id', @internalRefId)">
<fo:basic-link internal-destination="{$prefix}{@id}">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" from="content" level="any" />
</fo:basic-link>
</xsl:for-each>
</xsl:template>
<xsl:template match="figure">
<fo:wrapper id="{@id}">
<xsl:apply-templates select="graphic" />
</fo:wrapper>
</xsl:template>
<xsl:template match="figure/graphic" priority="10">
<fo:block text-align="center" start-indent="0pt" color="black" keep-with-next="always">
<xsl:if test="@id">
<xsl:attribute name="id">
<xsl:value-of select="$prefix" />
<xsl:value-of select="@id" />
</xsl:attribute>
</xsl:if>
<xsl:call-template name="do-graphic">
<xsl:with-param name="include-graphic" select="true()" />
</xsl:call-template>
</fo:block>
<xsl:if test="position() = last()">
<xsl:apply-templates select="../legend" />
</xsl:if>
<xsl:if test="@infoEntityIdent">
<fo:block text-align="right" keep-with-previous="always">
<xsl:value-of select="@infoEntityIdent" />
</fo:block>
</xsl:if>
<fo:block font-weight="normal" font-style="italic" text-align="center" space-before="12pt" space-after="8pt" start-indent="0pt" keep-with-previous="always">
<xsl:text>Fig </xsl:text>
<xsl:number count="figure" level="any" format="1" from="content" />
<xsl:apply-templates select="../title" />
<xsl:variable name="numSheets" select="count(../graphic)" />
<xsl:choose>
<xsl:when test="$numSheets > 1">
<xsl:text> (Sheet </xsl:text>
<xsl:number count="graphic" level="any" format="1" from="figure" />
<xsl:text> of </xsl:text>
<xsl:value-of select="$numSheets" />
<xsl:text>)</xsl:text>
</xsl:when>
</xsl:choose>
</fo:block>
</xsl:template>
<xsl:template name="do-graphic">
<xsl:param name="include-graphic" select="true()"/>
<xsl:variable name="content-width">
<xsl:choose>
<xsl:when test="@reproductionWidth != ''">
<xsl:value-of select="@reproductionWidth"/>
<xsl:call-template name="checkForUom">
<xsl:with-param name="measure" select="@reproductionWidth"/>
</xsl:call-template>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="@reproductionScale != ''">
<xsl:value-of select="@reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="content-height">
<xsl:choose>
<xsl:when test="@reproductionHeight != ''">
<xsl:value-of select="@reproductionHeight"/>
<xsl:call-template name="checkForUom">
<xsl:with-param name="measure" select="@reproductionWidth"/>
</xsl:call-template>
</xsl:when>
<!-- coding for reproduction scale based on clarifications in Issue 4.1 -->
<xsl:when test="@reproductionScale != ''">
<xsl:value-of select="@reproductionScale"/>
<xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>95%</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$include-graphic">
<fo:external-graphic src="{unparsed-entity-uri(@infoEntityIdent)}" scaling="uniform" content-height="{$content-height}" content-width="{$content-width}">
<xsl:attribute name="id"><xsl:apply-templates select="//dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/><xsl:value-of select="@id"/></xsl:attribute>
</fo:external-graphic>
</xsl:when>
<xsl:otherwise>
<fo:inline-container display-align="center" text-align="center" block-progression-dimension="{$content-height}" inline-progression-dimension="{$content-width}" background-color="silver" color="red">
<fo:block>Graphic Not Included</fo:block>
</fo:inline-container>
</xsl:otherwise>
</xsl:choose>
</xsl:template>