更新属性值

问题描述 投票:0回答:1
xml xslt
1个回答
1
投票

使用 XSLT 3 和

xsl:iterate

  <xsl:mode on-no-match="shallow-copy"/>
  
  <xsl:template match="p">
    <xsl:copy>
      <xsl:iterate select="x">
        <xsl:param name="n" select="()"/>
        <xsl:variable name="n" select="if (@n and @n != '') then @n else $n + 1"/>
        <xsl:copy>
          <xsl:attribute name="n" select="$n"/>
        </xsl:copy>
        <xsl:next-iteration>
          <xsl:with-param name="n" select="$n"/>
        </xsl:next-iteration>
      </xsl:iterate>
    </xsl:copy>
  </xsl:template>

在线示例.

© www.soinside.com 2019 - 2024. All rights reserved.