Created
August 24, 2024 07:42
-
-
Save infojunkie/958e5c7a11d16791947d911d23d88a10 to your computer and use it in GitHub Desktop.
XSL transformation to filter out some elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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