XSLT concat字符串

XSLT concat字符串,xslt,string-concatenation,Xslt,String Concatenation,我有以下XML <R N="14" MIME="application/pdf"> <RK>7</RK> <FS NAME="date" VALUE="2007-11-01" /> <MT N="Abstract" V="Lorem Ipsum is simply dummy text of the printing " /> <MT N="Abstract1" V="

我有以下XML

   <R N="14" MIME="application/pdf">
       <RK>7</RK>
       <FS NAME="date" VALUE="2007-11-01" />
       <MT N="Abstract" V="Lorem Ipsum is simply dummy text of the printing " />
       <MT N="Abstract1" V="and typesetting industry. Lorem Ipsum has been the industry's standard " />
       <MT N="Abstract2" V="dummy text ever since the 1500s, when an unknown printer took a galley" />
       <MT N="CreationDate" V="D:20070730173554+05'30'" />
       <MT N="Creator" V="PageMaker 6.5" />
       <MT N="Producer" V="Acrobat Distiller 8.0.0 (Windows)" />
       <MT N="ModDate" V="D:20071024091122+05'30'" />
       <S>
           <b>...</b> handling / storage. Operational reactor physics plays an important role in<br/>
           efficient, smooth and safe operation of <b>nuclear reactor</b>. In <b>...</b>
       </S>
       <LANG>en</LANG>
   </R>

7.
... 搬运/储存。运行反应堆物理在
核反应堆高效、平稳、安全运行。在里面 EN
使用XSLT,我需要连接Abstract、Abstract1、Abstract2、Abstract3。。。等等

我的XSLT是这样的

 <xsl:template match="R">
    <xsl:choose>
        <xsl:when test="MT[@N = 'Abstract' and @V != '']">
            <xsl:call-template name="reformat_keyword">
                <xsl:with-param name="orig_string" select="concat(MT[@N='Abstract']/@V,MT[@N='Abstract1']/@V,MT[@N='Abstract2']/@V)" />
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <xsl:if test="$show_res_snippet != '0'">
                <xsl:call-template name="reformat_keyword">
                    <xsl:with-param name="orig_string" select="S" />
                </xsl:call-template>
            </xsl:if>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>


我需要的不是静态连接,而是一个泛型函数。

如果我没弄错,您可以执行以下操作

<xsl:variable name="con-cats"><xsl:apply-templates
    select="MT[starts-with(@N,'Abstract')]"
    mode="concatthem"/></xsl:variable>

其他地方:

<xsl:template match="MT" mode="concatthem">
 <xsl:value-of select="@V"/>
</xsl:template>
<xsl:template match="*|text()" mode="concatthem" />


(未测试,可能有错误)。

如果我没弄错,您可以执行以下操作

<xsl:variable name="con-cats"><xsl:apply-templates
    select="MT[starts-with(@N,'Abstract')]"
    mode="concatthem"/></xsl:variable>

其他地方:

<xsl:template match="MT" mode="concatthem">
 <xsl:value-of select="@V"/>
</xsl:template>
<xsl:template match="*|text()" mode="concatthem" />

(未测试,可能有错误)。

在XSLT2.0中,它是

<xsl:variable name="answer" 
    select="string-join(MT[starts-with(@N, 'Abstract']/@V, '')"/>

在XSLT1.0中,它是

<xsl:variable name="answer">
  <xsl:for-each select="MT[starts-with(@N, 'Abstract']">
    <xsl:value-of select="@V"/>
  </xsl:for-each>
</xsl:variable>

在XSLT2.0中

<xsl:variable name="answer" 
    select="string-join(MT[starts-with(@N, 'Abstract']/@V, '')"/>

在XSLT1.0中,它是

<xsl:variable name="answer">
  <xsl:for-each select="MT[starts-with(@N, 'Abstract']">
    <xsl:value-of select="@V"/>
  </xsl:for-each>
</xsl:variable>


我认为问题在于如何选择属性具有非常量值的节点……谢谢。就这样结束了。它连接MT下的所有字符串。我只需要有选择地连接Abstract、Abstract1、Abstract2。。等如果这是通用的,那就最好了。意思,现在是抽象的,以后可能是创作者1,创作者2等等,啊。好的,您可以选择
MT[以(@N,'Abstract')开头]
,选择部分只是一个例子。我认为问题在于如何选择属性具有非常量值的节点…谢谢。结束了。它连接MT下的所有字符串。我只需要有选择地连接Abstract、Abstract1、Abstract2。。等如果这是通用的,那就最好了。意思,现在是抽象的,以后可能是创作者1,创作者2等等,啊。好的,您可以选择
MT[以(@N,'Abstract')开头]
,select部分只是一个示例