Skip to main content



      Home
Home » Eclipse Projects » Gendoc » Processing recursive data structures?
Processing recursive data structures? [message #1768130] Thu, 13 July 2017 17:25 Go to next message
Eclipse UserFriend
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 17:34] by Moderator

Re: Processing recursive data structures? [message #1768156 is a reply to message #1768130] Fri, 14 July 2017 04:36 Go to previous messageGo to next message
Eclipse UserFriend
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 15:51 Go to previous messageGo to next message
Eclipse UserFriend
(oops, duplicate post)

[Updated on: Sun, 23 July 2017 15:53] by Moderator

Re: Processing recursive data structures? [message #1768781 is a reply to message #1768156] Sun, 23 July 2017 15:51 Go to previous messageGo to next message
Eclipse UserFriend
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 16:41 Go to previous messageGo to next message
Eclipse UserFriend
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 16:45] by Moderator

Re: Processing recursive data structures? [message #1769378 is a reply to message #1768785] Mon, 31 July 2017 04:07 Go to previous messageGo to next message
Eclipse UserFriend
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 02:24 Go to previous message
Eclipse UserFriend
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: Tue Mar 25 23:47:51 EDT 2025

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

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

Back to the top