Skip to content

Instantly share code, notes, and snippets.

@TurekBot
Created October 15, 2019 23:37
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 TurekBot/869fce5e7624cdc40cd9e737261feb32 to your computer and use it in GitHub Desktop.
Save TurekBot/869fce5e7624cdc40cd9e737261feb32 to your computer and use it in GitHub Desktop.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- This template will return the Message, changing the email address to the one provided. -->
<xsl:output method="xml" omit-xml-declaration="yes"/>
<!-- Here we set up a parameter that will be passed in. -->
<xsl:param name="emailReplacement"/>
<!-- This block copies the whole thing (the input) into the output. -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<!-- This block replaces the `email_addr` atribute of the Email element with the given email. -->
<xsl:template match="/Message/Email/@email_addr">
<!-- The name attribute is required, so we just specify the same name as before. `name()` uses the same name the attribute had previously—we don't want to change the attribute name, just its value. -->
<xsl:attribute name="{name()}">
<xsl:value-of select="$emailReplacement"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment