Skip to content

Instantly share code, notes, and snippets.

@tsjensen

tsjensen/sq-xml-sort.md

Last active Aug 25, 2017
Embed
What would you like to do?
How to sort exported SonarQube profile by repository and rule key

Sort exported SonarQube profile by repository and rule key

  1. Export SQ profile
  2. remove <profile> element, so that <rules> element is top level
  3. paste into http://www.freeformatter.com/xsl-transformer.html or http://integrationexpert.net/online-xslt-tool/
  4. paste xsl from below
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="rules">
    <xsl:copy>
      <xsl:apply-templates>
        <xsl:sort select="repositoryKey" data-type="text" order="ascending"/>
        <xsl:sort select="key" data-type="text" order="ascending"/>
      </xsl:apply-templates>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.