Skip to content

Instantly share code, notes, and snippets.

@jbeard4
Created November 12, 2012 17:08
Show Gist options
  • Save jbeard4/4060570 to your computer and use it in GitHub Desktop.
Save jbeard4/4060570 to your computer and use it in GitHub Desktop.
Normalize Initial States
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="http://www.w3.org/2005/07/scxml"
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0">
<xsl:output method="xml"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="s:*[@initial]">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<initial id="{concat(@id,'_initial')}">
<transition target="{@initial}"/>
</initial>
<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