“retrieve-marker” 在属性值中

huangapple go评论58阅读模式
英文:

`retrieve-marker` in attribute value

问题

我试图使用标记来确定在页眉/页脚中显示的图像。每个章节都有一个标记,用于传达要使用的图像。当我在<xsl:attribute元素中使用fo:marker/fo:retrieve-marker时,它会理所当然地生成一个无效的src=值。

例如,页面:

  1. 第1章
  2. 第1章结束;第2章开始
  3. 第2章

页面1和2的页眉将引用,而第3页将引用

如何嵌入一个根据内容流而变化的页眉或页脚中的图像呢?

英文:

I'm trying to use a marker to determine the image to show in a header/footer. Each chapter has a marker which communicates the image to use. When I use &lt;fo:marker / &lt;fo:retreive-marker in an &lt;xsl:attribute element, it understandably produces an invalid src= value.

e.g. pages:

  1. Chapter 1
  2. Chapter 1 ends; chapter 2 begins
  3. Chapter 2

Header for page 1 and 2 would reference &lt;external-graphic src=&quot;1.png&quot;/&gt; and 3 would reference &lt;external-graphic src=&quot;2.png&quot;/&gt;.

How can I embed an image in a header or footer that varies based on the flow content?

答案1

得分: 1

fo:marker可以包含文本,但无法检索该文本以生成src属性的值。

可以工作的方法是检索具有正确src值的整个fo:external-graphic。类似以下内容(未经测试):

<fo:page-sequence master-reference="...">
  <fo:marker marker-class-name="image">
    <fo:external-graphic src="1.png"/>
  </fo:marker>
  <fo:static-content flow-name="xsl:region-after">
    <fo:block><fo:retrieve-marker retrieve-class-name="image"/></fo:block>
  </fo:static-content>
  <!-- 一些内容 -->
</fo:page-sequence>
<fo:page-sequence master-reference="...">
  <fo:marker marker-class-name="image">
    <fo:external-graphic src="2.png"/>
  </fo:marker>
  <fo:static-content flow-name="xsl:region-after">
    <fo:block><fo:retrieve-marker retrieve-class-name="image"/></fo:block>
  </fo:static-content>
  <!-- 更多内容 -->
</fo:page-sequence>
英文:

An fo:marker could contain just text, but you can't retrieve that text to make the value of a src property.

What would work is to retrieve an entire fo:external-graphic that has the correct src value. Something like (untested):

&lt;fo:page-sequence master-reference=&quot;...&quot;&gt;
  &lt;fo:marker marker-class-name=&quot;image&quot;&gt;
    &lt;fo:external-graphic src=&quot;1.png&quot;/&gt;
  &lt;/fo:marker&gt;
  &lt;fo:static-content flow-name=&quot;xsl:region-after&quot;&gt;
    &lt;fo:block&gt;&lt;fo:retrieve-marker retrieve-class-name=&quot;image&quot;/&gt;&lt;/fo:block&gt;
  &lt;/fo:static-content&gt;
  &lt;!-- Stuff --&gt;
&lt;/fo:page-sequence&gt;
&lt;fo:page-sequence master-reference=&quot;...&quot;&gt;
  &lt;fo:marker marker-class-name=&quot;image&quot;&gt;
    &lt;fo:external-graphic src=&quot;2.png&quot;/&gt;
  &lt;/fo:marker&gt;
  &lt;fo:static-content flow-name=&quot;xsl:region-after&quot;&gt;
    &lt;fo:block&gt;&lt;fo:retrieve-marker retrieve-class-name=&quot;image&quot;/&gt;&lt;/fo:block&gt;
  &lt;/fo:static-content&gt;
  &lt;!-- More stuff --&gt;
&lt;/fo:page-sequence&gt;

答案2

得分: 0

把整个图像放在标记中,不仅仅是URL。

英文:

Put the entire image in the marker, not just the URL.

huangapple
  • 本文由 发表于 2023年4月11日 08:39:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75981662.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定