Ticket #801: templates_sorter_2011_07_30.diff

File templates_sorter_2011_07_30.diff, 2.0 KB (added by fcxSanya, 13 years ago)
  • templatessorter/templatessorter.xsl

     
     1<xsl:stylesheet
     2  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     3  version="1.0">
     4
     5  <xsl:output encoding="utf-8" indent="yes"/>
     6
     7  <xsl:template match="@* | node() | comment()">
     8    <xsl:copy>
     9      <xsl:apply-templates select="@* | node() | comment()"/>
     10    </xsl:copy>
     11  </xsl:template>
     12
     13  <!-- we use match="/Entity" because we want to sort only second-level elements (contained in top level Entity) -->
     14  <xsl:template match="/Entity">
     15    <xsl:copy>
     16      <xsl:apply-templates select="@* | comment()"/>
     17      <xsl:apply-templates select="*">
     18        <!-- with translate function sorting will be case-insensitive,
     19             because it will change lower-case letter to upper-case for sorting -->
     20        <xsl:sort select="translate(local-name(), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
     21      </xsl:apply-templates>
     22    </xsl:copy>
     23  </xsl:template>
     24
     25</xsl:stylesheet>
     26
  • templatessorter/templatessorter.sh

     
     1#!/bin/bash
     2# check arguments count
     3if [ $# -ne 1 ]; then
     4  echo 'usage: '$0' directory'
     5  exit
     6fi
     7# assign arguments to variables with readable names
     8input_directory=$1
     9# perform work
     10find $input_directory -name \*.xml -exec xsltproc -o {} templatessorter.xsl {} \;
     11
  • templatessorter/readme.txt

     
     1Templates sorting utility aimed to sort components (second level xml elements) in simulation templates in alphabetical order.
     2
     3Usage:
     4./templatessorter.sh path_to_folder_with_simulation_templates
     5