TODO:
Have you ever wanted to copy all nodes of an xml document, and add an attribute to each node?
SOLUTION:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="dirty">true</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
NOTES:
I had a problem, in that I had an Object that had over 50+ properties. When I took in XML and deserialized it, I did not know what nodes were supplied. I wanted to allow folks to pass in just the parts of the document they wanted to update, but had no notion of "dirty". This will add a "dirty" attribute to all nodes, which allows me to easily grab only the dirty ones, and update my database accordingly.