Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gendoc » Processing recursive data structures?
Processing recursive data structures? [message #1768130] Thu, 13 July 2017 21:25 Go to next message
Reinhold Usolf is currently offline Reinhold UsolfFriend
Messages: 18
Registered: December 2016
Junior Member
Hi,

My models are basically trees (with some objects between the tree nodes carrying additional data, i.e. an edge between a parent A and a child B looks like A->E->B). I would like to generate a document that reflects the tree structure. That means for a node A with two children B (with child C) and D, the output should look like
- A
  - B
    - C
  - D

My problem: I don't want to impose a limit on the depth of the tree!

I don't see how I can process such a recursive data structure in a gendoc template. I first thought I can do recursive calls between fragments, but that's not allowed in gendoc.

Then I thought that maybe I could first flatten the tree structure (with Acceleo/Ocl collect) and process all children iteratively. However, that also doesn't work. The collect function doesn't know how to handle the edges (it probably only works for simple package structures with contain-relationships).

Any other idea? Invoke a Java function?

[Updated on: Thu, 13 July 2017 21:34]

Report message to a moderator

Re: Processing recursive data structures? [message #1768156 is a reply to message #1768130] Fri, 14 July 2017 08:36 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hello
you were right as long as recursive were not allowed the ideal solution was using collect or closure

but actually recursive is allowed in fragments. They are used in the generic templates on the wiki : https://wiki.eclipse.org/Gendoc/samples/genericTemplate

Can you take a look at it and tell us if it answers your question ?




Re: Processing recursive data structures? [message #1768780 is a reply to message #1768156] Sun, 23 July 2017 19:51 Go to previous messageGo to next message
Reinhold Usolf is currently offline Reinhold UsolfFriend
Messages: 18
Registered: December 2016
Junior Member
(oops, duplicate post)

[Updated on: Sun, 23 July 2017 19:53]

Report message to a moderator

Re: Processing recursive data structures? [message #1768781 is a reply to message #1768156] Sun, 23 July 2017 19:51 Go to previous messageGo to next message
Reinhold Usolf is currently offline Reinhold UsolfFriend
Messages: 18
Registered: December 2016
Junior Member
Thank you for your answer!
I tried something (very) similar to your genericTemplate example and got an error message that led me to https://www.eclipse.org/forums/index.php/t/873042/
Looks like I have to check again...

Re: Processing recursive data structures? [message #1768785 is a reply to message #1768781] Sun, 23 July 2017 20:41 Go to previous messageGo to next message
Reinhold Usolf is currently offline Reinhold UsolfFriend
Messages: 18
Registered: December 2016
Junior Member
Ah, it works!

Recursions of the form
fragmentX -> fragmentX -> fragmentX

are allowed, but not indirect recursions of the form
fragmentX -> fragmentY -> fragmentX

(gives an "fragment dependency error")

Copied the code of fragmentY into fragmentX and the problem was solved :) (although the code becomes very hard to read)

[Updated on: Sun, 23 July 2017 20:45]

Report message to a moderator

Re: Processing recursive data structures? [message #1769378 is a reply to message #1768785] Mon, 31 July 2017 08:07 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Exact, I forgot this problem. Can you open a bug ? If the problem of polymorphism is fixed one day it should also fixed this problem



Re: Processing recursive data structures? [message #1770531 is a reply to message #1769378] Mon, 14 August 2017 06:24 Go to previous message
Antonio Campesino is currently offline Antonio CampesinoFriend
Messages: 56
Registered: August 2016
Member
Hi,

I have been looking at that issue, and we have some code that prevent loops in the invokation of fragments. This is basically due to we put the fragment in a new acceleo template and use acceleo includes which does not allow loops in the template dependency.

When I have a little of time, I will try to submit a patch.

I have been working on put all the fragments inside the same acceleo template, so the recursion will work for all the cases. Actually the issue with the polymorphism is there using fragment recursion or just calling a fragment.

Another issue we have is that we can not define queries in the gendoc templates, but that is another issue.
Previous Topic:What HTML tags are supported in RichText?
Next Topic:international characters in richtext
Goto Forum:
  


Current Time: Sat Oct 12 19:20:04 GMT 2024

Powered by FUDForum. Page generated in 0.04949 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top