Skip to content
This repository
Browse code

Added xslt script to add logging of state entry and exit actions to a…

…rbitrary scxml documents. This will be useful in debugging.
  • Loading branch information...
commit 558be1575e620ea6dcc343d52980a78ffadb0793 1 parent 40527a0
Jacob Beard authored

Showing 1 changed file with 70 additions and 0 deletions. Show diff stats Hide diff stats

  1. +70 0 src/main/xslt/add-entry-exit-logging.xsl
70 src/main/xslt/add-entry-exit-logging.xsl
... ... @@ -0,0 +1,70 @@
  1 +<?xml version="1.0"?>
  2 +<!--
  3 + Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
  4 +
  5 + Licensed under the Apache License, Version 2.0 (the "License");
  6 + you may not use this file except in compliance with the License.
  7 + You may obtain a copy of the License at
  8 +
  9 + http://www.apache.org/licenses/LICENSE-2.0
  10 +
  11 + Unless required by applicable law or agreed to in writing, software
  12 + distributed under the License is distributed on an "AS IS" BASIS,
  13 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 + See the License for the specific language governing permissions and
  15 + limitations under the License.
  16 +-->
  17 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  18 + xmlns:s="http://www.w3.org/2005/07/scxml"
  19 + xmlns="http://www.w3.org/2005/07/scxml"
  20 + version="1.0">
  21 + <xsl:output method="xml"/>
  22 +
  23 + <!-- identity transform -->
  24 + <xsl:template match="@*|node()">
  25 + <xsl:copy>
  26 + <xsl:apply-templates select="@*|node()"/>
  27 + </xsl:copy>
  28 + </xsl:template>
  29 +
  30 + <!-- match only basic states -->
  31 + <xsl:template match="s:state | s:parallel | s:history | s:final">
  32 +
  33 + <xsl:copy>
  34 + <xsl:apply-templates select="@*"/>
  35 +
  36 + <xsl:if test="not(s:onentry)">
  37 + <onentry>
  38 + <log expr="'entering state {@id}'"/>
  39 + </onentry>
  40 + </xsl:if>
  41 +
  42 + <xsl:if test="not(s:onexit)">
  43 + <onexit>
  44 + <log expr="'exiting state {@id}'"/>
  45 + </onexit>
  46 + </xsl:if>
  47 +
  48 + <xsl:apply-templates select="node()"/>
  49 + </xsl:copy>
  50 +
  51 + </xsl:template>
  52 +
  53 + <xsl:template match="s:onentry">
  54 + <xsl:copy>
  55 + <log expr="'entering state {../@id}'"/>
  56 +
  57 + <xsl:apply-templates select="@*|node()"/>
  58 + </xsl:copy>
  59 + </xsl:template>
  60 +
  61 + <xsl:template match="s:onexit">
  62 + <xsl:copy>
  63 + <log expr="'exiting state {../@id}'"/>
  64 +
  65 + <xsl:apply-templates select="@*|node()"/>
  66 + </xsl:copy>
  67 + </xsl:template>
  68 +
  69 +</xsl:stylesheet>
  70 +

0 comments on commit 558be15

Please sign in to comment.
Something went wrong with that request. Please try again.