0

我有一个子元素名称为 nextElement 的元素

a.nextElement is b
b.nextElement is c
c.nextElement is d

当我请求 a->closure(a.nextElement) 时,我希望得到一个带有 b、c 和 d 的集合,但我只得到 b。我不理解或做错了什么?

4

1 回答 1

0

你有没有尝试过类似的东西?:

a -> closure(child:Element | true)

true 是一个表达式。您可以在那里指定您需要的任何条件。

我在这里看到了

即使我不确定closureAcceleo API 中是否包含它(我重复一遍,不确定)。我尝试使用closure函数,但 IDE 没有向我建议。

在我的项目中,我自己做了这个通用查询:

[query public descendants(aElement : Node): 
    Set(Node) =  if (aElement.oclIsTypeOf(Element)) then
                        Set{aElement} -> union (aElement.oclAsType(Element).children 
                            -> collect (n : Node | descendants(n)) -> asSet() )  
                    else
                        Set{aElement}
                    endif 
    /]

我希望这会有所帮助!

于 2015-04-21T06:26:36.533 回答