代码之家  ›  专栏  ›  技术社区  ›  Shud

将分号符号“;”添加到元素的值

  •  0
  • Shud  · 技术社区  · 1 年前

    我将变量“cond_in”作为“文档节点”类型。例如

        <entry attribute1="att1", attribute2="att2">
            <p>Value1</p>
            <p>Value2</p>
            <p>Value3</p>
        </entry>
    

    因此,我想将变量“cond_out”创建为“文档节点”类型,但添加到每个

    元素“;”字符串:

        <entry attribute1="att1", attribute2="att2">
            <p>Value1; </p>
            <p>Value2; </p>
            <p>Value3; </p>
        </entry>
    

    我该怎么做? 提前谢谢!

    我尝试了以下操作:

        <xsl:variable name="cond_out">
            <xsl:apply-templates select="$cond_in" mode="addsymbol"/>
        </xsl:variable>
        
        
        <xsl:template match="entry" mode="addsymbol">
            <xsl:copy-of select="entry"/>
        </xsl:template>
    

    我不知道如何将分号“;”添加到元素的值中

    ....

    1 回复  |  直到 1 年前
        1
  •  0
  •   Martin Honnen    1 年前

    模板 <xsl:template match="entry/p"><xsl:copy><xsl:value-of select="concat(., '; ')"/></xsl:copy></xsl:template> 应该完成转换的工作 p 元素,当然,您需要确保使用 xsl:apply-templates 并设置身份转换模板,以复制其他所有内容。