Skip to content

Instantly share code, notes, and snippets.

@jetzerb
Last active March 13, 2020 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jetzerb/cb79140610e3653ed93e9fe09c32beb0 to your computer and use it in GitHub Desktop.
Save jetzerb/cb79140610e3653ed93e9fe09c32beb0 to your computer and use it in GitHub Desktop.
XSLT to dump out the list of hosts from your mRemoteNG config file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="text" omit-xml-declaration="yes" />
<xsl:variable name="pad" select="' '" />
<!-- override the default template that prints all text -->
<xsl:template match="text()|@*" />
<!-- Output indented list of nodes along with hostnames -->
<xsl:template match="//Node" >
<xsl:value-of select="concat(
substring($pad,1,2*(count(ancestor::*)-1))
,@Name)" />
<xsl:if test="@Hostname != '' and @Name != @Hostname" >
<xsl:value-of select="concat(
substring($pad,1,30 - string-length(@Name))
,' - '
,@Hostname)" />
</xsl:if>
<xsl:text>&#xa;</xsl:text>
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
@jetzerb
Copy link
Author

jetzerb commented Mar 13, 2020

Call it like this:

xsltproc mRemoteNG_hosts.xslt config_file_name_here.xml

The output looks like this:

Group1
  Subgroup1
    Entry 1 Description            - 12.34.56.78
    Entry 2 Description            - 23.45.67.89
    etc                            - etc
  Subgroup2
    Entry 1 Description            - 34.56.78.90
    Entry 2 Description            - 45.67.89.0
    etc                            - etc
  etc
Group2
  Subgroup1
    Entry 1 Description            - 56.78.90.12
    Entry 2 Description            - 67.89.1.23
    etc                            - etc
Group3
  Entry 1 Description            - 78.90.12.34
  Entry 2 Description            - 89.1.23.45
  etc                            - etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment