FallbackDo2And.xsl

From RIF
Jump to: navigation, search
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:rif="http://www.w3.org/2007/rif#">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no"/>

<!-- identity template -->
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<!-- Change <Do> elements into <And> elements -->
<xsl:template match="rif:Do">
   <xsl:element name="And" namespace="http://www.w3.org/2007/rif#">
     <xsl:apply-templates select="node()"/>
   </xsl:element>
</xsl:template>

<!-- Removes the <actions> elements and their "ordered" attribute -->
<xsl:template match="rif:actions">
     <xsl:apply-templates select="node()"/>
</xsl:template>

<!-- Replace the <Assert><target> pairs of elements by a <formula> element -->
<xsl:template match="rif:Assert">
     <xsl:apply-templates select="rif:target" mode="formula"/>
</xsl:template>

<xsl:template match="rif:target" mode="formula">
   <xsl:element name="formula" namespace="http://www.w3.org/2007/rif#">
     <xsl:apply-templates select="@*|node()"/>
   </xsl:element>
</xsl:template>

</xsl:stylesheet>