<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="process-definition">
<xsl:element name="decomposition">
<xsl:attribute name="id">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:for-each select="task-node">
<xsl:element name="task">
<xsl:attribute name="id">
<xsl:value-of select="@name"/>
</xsl:attribute>
<name><xsl:value-of select="@name"/></name>
<xsl:choose>
<xsl:when test="not(transition/@to=//process-definition/task-node/@name)">
<flowsInto>
<xsl:element name="nextElementRef">
<xsl:attribute name="id">
<xsl:for-each select="/process-definition/decision" >
<xsl:value-of select="descendant::transition/@to"/>
</xsl:for-each>
</xsl:attribute>
</xsl:element>
</flowsInto>
<flowsInto>
<xsl:element name="nextElementRef">
<xsl:attribute name="id">
<xsl:value-of select="//process-definition/decision/transition/@to"/>
</xsl:attribute>
</xsl:element>
</flowsInto>
</xsl:when>
<xsl:otherwise>
<flowsInto>
<xsl:element name="nextElementRef">
<xsl:attribute name="id">
<xsl:value-of select="transition/@to"/>
</xsl:attribute>
</xsl:element>
</flowsInto>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Solomon Gizaw 0 Newbie Poster
<?xml version="1.0" encoding="UTF-8"?>
<decomposition id="sample">
<task id="Order1">
<flowsInto>
<nextElementRef id="Order2"/>
</flowsInto>
</task>
<task id="Order2">
<flowsInto>
<nextElementRef id="Order5"/>
</flowsInto>
<flowsInto>
<nextElementRef id="Order3"/>
</flowsInto></task>
<task id="Order3">
<flowsInto>
<nextElementRef id="Order5"/>
</flowsInto>
<flowsInto>
<nextElementRef id="Order4"/>
</flowsInto>
</task>
<task id="Order5">
<flowsInto>
<nextElementRef id="Exit"/>
</flowsInto>
</task>
<task id="Order4">
<flowsInto>
<nextElementRef id="Exit"/>
</flowsInto>
</task>
</decomposition>
<?xml version="1.0" encoding="UTF-8"?>
<process-definition name="sample">
<task-node name="Order1">
<task name="task_Order1">
<activity>order</activity>
<role_type>false</role_type>
<sequence>0</sequence>
</task>
<transition name="Action1" to="Order2"/>
</task-node>
<task-node name="Order2">
<task name="task_Order2">
<activity>order</activity>
<role_type>false</role_type>
<sequence>0</sequence>
</task>
<transition name="Action2" to="Condition1"/>
</task-node>
<task-node name="Order3">
<task name="task_order3">
<activity>order</activity>
<role_type>false</role_type>
<sequence>0</sequence>
</task>
<transition name="Action3" to="Condition2"/>
</task-node>
<decision name="Condition1">
<transition name="default" to="Order3"/>
<transition name="option" to="Order5"/>
</decision>
<task-node name="Order5">
<task name="task_Order5">
<activity>order</activity>
<role_type>false</role_type>
<sequence>0</sequence>
</task>
<transition name="Action5" to="Exit"/>
</task-node>
<decision name="Condition2">
<transition name="default" to="Order5"/>
<transition name="option" to="Order4"/>
</decision>
<task-node name="Order4">
<task name="task_Order4">
<activity>order</activity>
<role_type>false</role_type>
<sequence>0</sequence>
</task>
<transition name="Action4" to="Exit"/>
</task-node>
</process-definition>
xml_looser 3 Junior Poster
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="xml"/>
<xsl:template match="/">
<xsl:apply-templates select="process-definition"/>
</xsl:template>
<xsl:template match="process-definition">
<decomposition>
<xsl:attribute name="id">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:apply-templates select="task-node"/>
</decomposition>
</xsl:template>
<xsl:template match="task-node">
<task>
<xsl:attribute name="id">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="contains(./transition/@to,'Condition')">
<xsl:variable name="to" select="./transition/@to"/>
<xsl:apply-templates select="../decision[./@name=$to]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="transition"/>
</xsl:otherwise>
</xsl:choose>
</task>
</xsl:template>
<xsl:template match="transition">
<flowsInto>
<nextElementRef>
<xsl:attribute name="id">
<xsl:value-of select="@to"/>
</xsl:attribute>
</nextElementRef>
</flowsInto>
</xsl:template>
<xsl:template match="decision">
<xsl:apply-templates select="transition"/>
</xsl:template>
</xsl:stylesheet>
fpmurphy commented: Very nice solution! +2
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.