开发者

How to select ancestor based on ancestor's attribute

I am new to this, so please bear with me...

I need to very simply modify content based on a template match: topic/body/section/title

This template match works fine. However, I need this to only happen if the topic element has a title element with the value of "Preface".

Can someone please help with the code?

Here is the code:

<topic>
  <title>Preface</title>
  <body>
    <p>This publication was written for...</p>
    <section>
      <title>Publication Information/Version</title>

Here is the xslt:

<xsl:template match="topic/body/section/title">
        <fo:block xsl:use-attribute-sets="prefacetitle" 
            keep-with-next.within-page="always" 
            keep-together.within-column="always" 
            color="{$docColor}">
            <!--<fo:marker marker-class-name="title-marker"><xsl:value-of select="normalize-space(.)"/></fo:marker>-->
            <xsl:apply-imports/>
   开发者_开发知识库     </fo:block>
    </xsl:template>

<xsl:attribute-set name="prefacetitle" >
        <xsl:attribute name="font-family">Trebuchet MS</xsl:attribute>
        <xsl:attribute name="font-size">28pt</xsl:attribute>
        <xsl:attribute name="font-weight">bold</xsl:attribute>
        <xsl:attribute name="margin-bottom">9pt</xsl:attribute>
        <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
    </xsl:attribute-set>

This code works, but I only want it to modify a section/title when it has an ancestor of topic/title[text()='Preface'].

make sense?


Without code it is difficult to tell what you want, but maybe something like this:

<xsl:template match="topic[title/text()='Preface']/body/section/title" >

If not, please clarify your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜