Last active
November 9, 2015 10:48
-
-
Save spikeheap/695f79e52784cbe39d7f to your computer and use it in GitHub Desktop.
Add `m` attribute to all leaf nodes
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"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0" | |
xmlns:d="http://nihr.ac.uk/nhic/ICU/UCL/finalv8.3.2"> | |
<xsl:output indent="yes"/> | |
<xsl:strip-space elements="*"/> | |
<xsl:variable name="dateNow" select="format-date(current-date(), '[Y0001]-[M01]-[D01]')"/> | |
<xsl:template match="node()|@*"> | |
<xsl:copy> | |
<xsl:apply-templates select="node()|@*"/> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="//*[starts-with(name(), 'd:NIHR_HIC_ICU_')]"> | |
<xsl:variable name="elementName" select="name()"/> | |
<xsl:element name="{$elementName}"> | |
<xsl:attribute name="m"> | |
<xsl:value-of select="$dateNow" /> | |
</xsl:attribute> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:element> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment