我有一个子元素名称为 nextElement 的元素
a.nextElement is b
b.nextElement is c
c.nextElement is d
当我请求 a->closure(a.nextElement) 时,我希望得到一个带有 b、c 和 d 的集合,但我只得到 b。我不理解或做错了什么?
我有一个子元素名称为 nextElement 的元素
a.nextElement is b
b.nextElement is c
c.nextElement is d
当我请求 a->closure(a.nextElement) 时,我希望得到一个带有 b、c 和 d 的集合,但我只得到 b。我不理解或做错了什么?
你有没有尝试过类似的东西?:
a -> closure(child:Element | true)
true 是一个表达式。您可以在那里指定您需要的任何条件。
我在这里看到了
即使我不确定closure
Acceleo 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
/]
我希望这会有所帮助!