Public feed
#892169
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" > <!-- whole document --> <xsl:template match="/"> <xsl:call-template name="recurse"/> </xsl:template> <!-- Recurses down the tree looking for inherting elements --> <xsl:template name="recurse"> <xsl:choose > <xsl:when test="@inherits"> <xsl:call-template name="inherits"/> </xsl:when> <xsl:otherwise> <xsl:call-template name="noInherits"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name ="inherits"> <!--Copy child element attributes, except 'inherits'--> <xsl:for-each select="@*"> <xsl:if test="name(.) != 'inherits'"> <xsl:copy/> </xsl:if> </xsl:for-each> <xsl:variable name="BaseClass" select="@inherits"></xsl:variable> <xsl:variable name="ChildElements"> <!-- Put child elements first--> <xsl:for-each select="./*"> <xsl:copy> <!-- Find the ID of the item we are overriding, if any--> <xsl:variable name="OverrideClass" select="@id"></xsl:variable> <!-- Copy all the attributes from the parent--> <xsl:copy-of select="//*[@id=$BaseClass]/*[@id=$OverrideClass]/@*"/> <xsl:call-template name="recurse"/> <!--Copy any remaining children of the override--> <xsl:copy-of select="//*[@id=$BaseClass]/*[@id=$OverrideClass]/*"/> </xsl:copy> </xsl:for-each> </xsl:variable> <xsl:copy-of select="$ChildElements"/> <!--Now we need to copy the elements from the base class specified by id, except overrides--> <xsl:for-each select="//*[@id=$BaseClass]/*"> <xsl:variable name="CurrentChild" select="@id"/> <xsl:if test="not(msxsl:node-set($ChildElements)/*[@id = $CurrentChild])"> <xsl:copy-of select="."/> </xsl:if> </xsl:for-each> </xsl:template><!--This template deals with elements that do not inherit--> <xsl:template name ="noInherits"> <!--Copy child element attributes--> <xsl:copy-of select="@*"/> <!-- Put child elements--> <xsl:for-each select="./*"> <xsl:copy> <xsl:call-template name="recurse"/> </xsl:copy> </xsl:for-each> </xsl:template></xsl:stylesheet>