带有命名空间的xml的xlst排序

原xml文件如下形式:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Data xmlns="http://www.ccccc/XMLtype">
  <Pipe name="weka" type="333" />
    <Filters>
    <Filter name="Loader" type="3333" caption="444">
      <Loader name="OLeDBReader" type="555">
        <Icon name="5555" type="Embeded" location="666">
        </Icon>
        <Properties>
          <Property name="ggg" type="System.String"></Property>
          <Property name="rr" type="System.String"></Property>
        </Properties>

        </Properties>

     </Loader>

   </Filter> 

后面是很多Filter但name等属性是不等同的。每个Filter内有很多子集,现要求对每个Filter下的子集排序。

 </Pipe>

</Data >

 

sort.xlst文件如下:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:d=http://www.ccccc/XMLtype>
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/" >
    <xsl:call-template name="process"></xsl:call-template>
  </xsl:template>
  <xsl:template match="Data/Filters" name="process" >
    <DataProcessToolKit >
      <xsl:copy-of select="/d:Datat/d:Pipe"/>
       <Filters>
        <xsl:for-each select="/d:Data/d:Filters/d:Filter">
          <Filter>
            <xsl:attribute name="name">
              <xsl:value-of select="@name"/>
            </xsl:attribute>
            <xsl:attribute name="type">
              <xsl:value-of select="@type"/>
            </xsl:attribute>
            <xsl:attribute name="caption">
              <xsl:value-of select="@caption"/>
            </xsl:attribute>
            <xsl:for-each select="./*">
              <xsl:sort data-type="text" order="ascending" select="@name"/>
              <xsl:copy-of select="."/>
            </xsl:for-each>
          </Filter>
        </xsl:for-each>
      </Filters>
    </Data>
  </xsl:template>
</xsl:stylesheet>

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值