1

I am using XMetal's default stylesheet to generate PDF. My source xml file has a "title" tag that I want to keep track of, previously ,I used the following code:

<fo:inline>
    <fo:retrieve-marker retrieve-class-name="current-header"/>
</fo:inline>

However, this will never work since Markers can only be retrieved in static content in FO, not in the main fo:flow. So my question is, if I am in the main fo:flow, how could I retrieve the title of the xml file?

4

1 回答 1

1

Say your data looks like this:

<title name="Section 1">
    <tag1>
        <tag2>
        </tag2>
    </tag1>
</title>

and your template is currently in tag2.

Then you just use select by ancestor axis:

<xsl:value-of select="ancestor::title/@name"/>

If your titles are nested, just use ancestor::title[1]/@name

于 2012-05-19T12:25:26.830 回答