原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>