[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re:Help needed in recursively converting the flat xml
Hi Wendell,
I think I made a significant progress with your explanation. Thanks, But still I am stuck with some problems. 1. As you said, I tried replacing <xsl:copy-of select="key('jname', $joinname)"/> with <xsl:copy-of select="key('jname', $joinname)[1]"/> but the problem here since I loop thru each activity-state whether I use your solution or not it is copying multiple joins (coz each activity-state can have multiple transitions and each activity-state may refer to the same join). 2. As I said there can be nested <concurrent-block> structures one inside the other. Though I am able to populate this structure with my code, the problem here I am facing is the internal <concurrent-block> is also being populated at the external level. The problem is I am using a for each select = "fork" at the template level which will loop through all the <concurrrent-block> structures in the original xml. But I am not able to figure out the solution. 3. The example I pasted here is fairly a simple one, which does not have multiple <activity-state> nodes inside a <concurrent-block> In this example the relation is <concurrent-block> ---> <activitiy-state>-----> <join>. Hence my code is working fine except the above two problems. But I can have a possible scenario like <concurrent-block>----> <activity-state>----><activity-state>----><decision>----><join> My latest xsl code is : <?xml version='1.0' encoding='UTF-8'?> <xsl:stylesheet exclude-result-prefixes="fo ms" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:ms-xsl" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/ |node()"><xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy></xsl:template> <xsl:template match="@*"> <xsl:copy> </xsl:copy> </xsl:template> <xsl:key name="act-name" match="/processXML/process-definition/activity-state" use="@name"/> <xsl:key name="act-name" match="/processXML/process-definition/decision" use="@name"/> <xsl:key name="jname" match="/processXML/process-definition/join" use="@name"/> <xsl:key name="con-name" match="/processXML/process-definition/concurrent-block" use="fork/@name"/> <xsl:key name="forktransitions" match="/processXML/process-definition/concurrent-block/fork/transition" use="@to"/> <xsl:template match="activity-state[(key('forktransitions',@name))]"/> <xsl:template match="join" /> <xsl:template name = "template1" match="/processXML/process-definition/concurrent-block"> <xsl:copy> <!-- To Copy Concurrent-Blocks --> <xsl:for-each select="fork"> <xsl:variable name="forkname" select="@name"/> <xsl:apply-templates select="/processXML/process-definition/concurrent-block/fork[@name=$forkname]"/> <xsl:for-each select="transition"> <xsl:variable name="transname"><xsl:value-of select="@to"/></xsl:variable> <xsl:copy-of select="key('act-name', $transname)"/> <xsl:for-each select="key('act-name', $transname)"> <xsl:variable name="joinname" select="transition/@to"/> <xsl:copy-of select="key('jname', $joinname)"/> <xsl:for-each select="key('act-name', $joinname)"> <xsl:copy-of select="key('act-name', $joinname)"/> </xsl:for-each> <xsl:for-each select="key('con-name', $joinname)"> <xsl:call-template name="template1" /> </xsl:for-each> </xsl:for-each> </xsl:for-each> </xsl:for-each> </xsl:copy> </xsl:template> </xsl:stylesheet> Thanks Sridhar Anupindi _________________________________________________________________ Post Classifieds on MSN classifieds. http://go.msnserver.com/IN/44045.asp Buy and Sell on MSN Classifieds.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|