Skip to content

Instantly share code, notes, and snippets.

@infojunkie
Created August 24, 2024 07:42
Show Gist options
  • Save infojunkie/958e5c7a11d16791947d911d23d88a10 to your computer and use it in GitHub Desktop.
Save infojunkie/958e5c7a11d16791947d911d23d88a10 to your computer and use it in GitHub Desktop.
XSL transformation to filter out some elements
<?xml version="1.0" encoding="UTF-8"?>
<!--
Filter out unwanted tags passed on the command line.
https://stackoverflow.com/a/2641719/209184
Usage: xslt3 -xsl:filter.xsl -s:share/instruments/instruments.xml filter="Channel|drumset|genre"
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output omit-xml-declaration="no" indent="yes"/>
<xsl:param name="filter" required="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[local-name()=tokenize($filter,'\|')]"/>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment