[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl transormation from flat tree to hierarchical t
Hi Andreas, May I propose a solution, which may be a start. I guess, your area of interest for transformation is following XML fragment (which is the only place, where I can see the "parent" attribute), <states> <state name="root" type="CompoundState"/> <state name="a" type="SimpleState" parent="root"/> <state name="choose" type="DecisionState" parent="root"/> <state name="b" type="SimpleState" parent="root"/> <state name="c" type="SimpleState" parent="root"/> </states> So here's my proposal for this transformation, <!-- starting point --> <xsl:call-template name="printStateTree"> <xsl:with-param name="curState" select="state[not(@parent)]"/> </xsl:call-template> <xsl:template name="printStateTree"> <xsl:param name="curState"/> <xsl:element name="{$curState/@name}"/> <xsl:for-each select="//state[@parent = $curState/@name]"> <xsl:call-template name="printStateTree"> <xsl:with-param name="curState" select="."/> </xsl:call-template> </xsl:for-each> </xsl:element> </xsl:template> This is not tested. The output format of this XSLT fragment is unrelated to your actual output (and it is not optimized -- since it has the expression //state, and output probably not normalized to be a good tree format). This XSLT fragment only intends to demonstrate the technique that I had in mind. Just some food for thought :) On Sat, Mar 10, 2012 at 1:44 PM, Andreas Volz <lists@xxxxxxxxxxxxx> wrote: > Am Sat, 3 Mar 2012 11:21:09 +0100 schrieb Andreas Volz: > >> Hello, >> >> I've a list with a flat tree that has a parent attribute to save >> child/father relations. >> >> http://stateval.googlecode.com/svn/trunk/stateval/test/features/ft2.smxml >> >> I just like to transform this state machine graph in DotML format to >> display it as SVG: >> >> http://martin-loetzsch.de/DOTML/record.html >> >> I've yet a somehow working version: >> >> http://stateval.googlecode.com/svn/trunk/stateval/doc/graph_gen/stateval_dotm l.xsl >> >> But it has only a flat list and shows transitions between them. I >> would like to handle CompoundStates as records in DotML. So I need >> some transformation from my flat tree into that hierarchical tree >> from DotML record. >> >> I've no idea how to do this in xsl. I'm using xsltproc in Ubuntu >> 11.10: >> >> > xsltproc --version >> Using libxml 20708, libxslt 10126 and libexslt 815 >> xsltproc was compiled against libxml 20708, libxslt 10126 and libexslt >> 815 libxslt 10126 was compiled against libxml 20708 >> libexslt 815 was compiled against libxml 20708 >> >> As fas as I know it supports only XSLT 1.0. >> >> Could you help me? > > No hints? Did I ask in a wrong way? Or isn't this possible? > > regards > B B B B Andreas > > > -- > Technical Blog <http://andreasvolz.wordpress.com/> -- Regards, Mukul Gandhi
|
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
|