【发布时间】:2013-02-06 17:48:36
【问题描述】:
是否可以设置一个规则,允许 Xpand 方法根据输入输出指定的文本字符串。例如:
«FOR a:e.attributes»
Type = «a.eClass.name»
Value = «a.name.toFirstUpper»
«ENDFOR»
上面的代码可能会输出:
Type = StringAttribute
Value = String1
Type = IntegerAttribute
Value = 123
我将如何制作这个输出:
Type = String
Value = String1
Type = int
Value = 123
我知道这可以通过 if 语句来完成,但我希望它或多或少是自动的。每次我需要在同一个文件中输出这些细节时都必须指定这样的规则是一种浪费。有人可以告诉我我可以使用什么样的代码来实现这一目标吗?谢谢。
【问题讨论】:
标签: java loops xtext xtend xpand