Dynamically change page header in XSLT

旧城冷巷雨未停 提交于 2019-12-02 18:09:41

问题


Dynamic change of page header in XSLT

I want same Image to be in Header however the content over image should change dynamically according to value in XML node

<fo:flow flow-name="header">
  <fo:table>
     <fo:table-body>
          <fo:table-cell border="0pt">
            <fo:block>
               <fo:external-graphic ID="headerlogo" src="url('imgae_url')" content-width="50%" content-height="50%">
                <fo:table-cell border="0pt">
                  <fo:block margin-top="1.5cm" margin-right="1.2cm" text-align="left" >
                    <fo:inline font-size="30pt" color="white" >
                      <xsl:value-of select="path_url"/>
                    </fo:inline>
                  </fo:block>
                </fo:table-cell>
              </fo:external-graphic>
            </fo:block>
          </fo:table-cell>
         </fo:table-body>
      </fo:table>
    </fo:flow>

回答1:


As @potame already mentioned in comments, <fo:marker> and <fo:retrieve-marker> are designed specially for this. Since you don't give any xml I created a simple example to show how to retrieve the marker and the logic behind it then you should be able to adapt to your code.

<fo:flow flow_name="xsl-region-before">
    <fo:table table-layout="fixed" width="100%">
        <fo:table-body>
            <fo:table-row>
                <fo:table-cell>
                    <fo:block>
                        <!-- Retrieve the marker value -->
                        <fo:retrieve-marker retrieve-class-name="header_value"/>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-body>
    </fo:table>
</fo:flow>

Then somewhere in your code (probably in the region-body you will set the marker value (In your case it would be a path url if I understand your question) depending on your wanted condition. Something like :

<xsl:when test="condition">
    <fo:marker marker-class-name="header_value"/>
        <xsl:value-of select="path_url"/>
    </fo:marker>
</xsl:when>
<xsl:when test="condition2">
    <fo:marker marker-class-name="header_value"/>
        <xsl:value-of select="path_url2"/>
    </fo:marker>
</xsl:when>


来源:https://stackoverflow.com/questions/28279694/dynamically-change-page-header-in-xslt

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