是否有可能运用tempates对XML之前应用在XSL参数模板

出处:http://codego.net/3400505/

我有一个XSL的字符串。我要解析的字符串,分割,并为每个子的价值我想申请模板中的XSL。


1.编辑:Missundertood的问题,不好意思。 答案是肯定的。 输入:

<secuence>Item1 Item2 Item3</secuence>
样式表:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="@*|node()">
  <xsl:copy>
   <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
 </xsl:template>
 <xsl:template match="secuence/text()" name="secuence">
  <xsl:param name="string" select="."/>
  <xsl:param name="separator" select="' '"/>
  <xsl:if test="$string != ''">
   <xsl:choose>
    <xsl:when test="contains($string,$separator)">
     <xsl:call-template name="secuence">
      <xsl:with-param name="string" select="substring-before($string,$separator)"/>
      <xsl:with-param name="separator" select="$separator"/>
     </xsl:call-template>
     <xsl:call-template name="secuence">
      <xsl:with-param name="string" select="substring-after($string,$separator)"/>
      <xsl:with-param name="separator" select="$separator"/>
     </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
     <!-- Your desired template -->
     <Item>
      <xsl:value-of select="$string"/>
     </Item>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>
结果:
<secuence>
 <Item>Item1</Item>
 <Item>Item2</Item>
 <Item>Item3</Item>
</secuence>

2.  不能确定什么,但复制这种模式可能会有所帮助:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值