Skip to content

Instantly share code, notes, and snippets.

@john-craft
Last active July 13, 2020 16:08
Show Gist options
  • Save john-craft/9fdc0e6e901cadd83ca37dc469a17e31 to your computer and use it in GitHub Desktop.
Save john-craft/9fdc0e6e901cadd83ca37dc469a17e31 to your computer and use it in GitHub Desktop.
Remove hyphens and periods from IDs
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="2.0">
<xsl:template match="@linkend | @id">
<xsl:attribute name="{node-name(.)}">
<xsl:value-of select="replace(., '[-.]', '')"/>
</xsl:attribute>
</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