Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 如何根据祖先选择祖先';s属性_Xslt - Fatal编程技术网

Xslt 如何根据祖先选择祖先';s属性

Xslt 如何根据祖先选择祖先';s属性,xslt,Xslt,我是新手,所以请容忍我 我需要非常简单地根据模板匹配修改内容: 主题/正文/章节/标题 此模板匹配工作正常。但是,我只需要在topic元素有一个title元素的值为“preduce”时才需要这样做 有人能帮我写代码吗 代码如下: <topic> <title>Preface</title> <body> <p>This publication was written for...</p> <se

我是新手,所以请容忍我

我需要非常简单地根据模板匹配修改内容: 主题/正文/章节/标题

此模板匹配工作正常。但是,我只需要在topic元素有一个title元素的值为“preduce”时才需要这样做

有人能帮我写代码吗

代码如下:

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

前言
这份出版物是为……而写的

刊物资料/版本
以下是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>

投石机
28磅
大胆的
9磅
总是
这段代码可以工作,但我只希望它在具有topic/title[text()='preference']的祖先时修改节/标题


有意义吗?

没有代码,很难说出您想要什么,但可能是这样的:

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


如果没有,请澄清您的问题。

哦,对不起,我不清楚。这是我需要返回的结构。前言本出版物是为…

出版物信息/版本而编写的,以澄清-当主题下有标题(其文本=“前言”)时,我需要能够修改章节/标题的后代。希望这能有所帮助。谢谢您的快速反馈。@kman:最好是您发布原始文档、样式表和期望的结果。但如果我的回答已经对你有所帮助,那也没关系;)备选方案:
topic[title='preference']/body/section/title
section/title[祖先::topic[title='preference']