Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » multivalued attributes
multivalued attributes [message #44900] Thu, 01 May 2008 17:17 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
hey paul,

is it possible to set an attribute value more than once? accessing that
attribute would result in a list or so, over which i could iterate.

this would be cool..
Re: multivalued attributes [message #45012 is a reply to message #44900] Sun, 04 May 2008 01:32 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member

JET (XPath, too) has problems with multi-valued attributes. XML doesn't
really have the concept (apart from the lame semantic used in types like
IDREF, were multiple values are separated by some special char in a single
attribute value).

I have though about have some way to annotate a model element with new
model elements (just as you can annotate a model element with a new
attribute via c:set). But, I haven't got around to doing it. If we play
thought experiments for a second, it would be something like the current
c:addElement (which only works if the underlying meta-model allows:

<%-- assuming $r some model element --%>
<c:addAnnotationElement select="$r" name="foo" var="foo"/>
<c:set select="$foo" name="name">foo 1</c:set>
<c:addAnnotationElement select="$r" name="foo" var="foo"/>
<c:set select="$foo" name="name">foo 2</c:set>

Then, you could do:
<c:iterate select="$r/foo" var="foo">
<c:get select="$foo/@name"/>

and expect results like:
foo 1
foo 2

I also have some ideas about making multivalued attributes addressable by
XPath. Again, I haven't had time yet, but it might work something like:

<c:get select="$r/@aMVAttr[1]"/>
<c:get select="$r/@aMVAttr[2]"/>

Anyone familiar with XPath in the XML context would assert that the first
expression is equivalent to $r/@aMVAttr, and the second would never return
a result. But, if multivalued attributes existed (as they do in EMF
models), then I think this would be a reasonable way to index them.

Anyhow, if I get around supporting that, then maybe we could have c:set
extended to do something like:

<c:set select="$r" name="aMVAttr" index="2">a value</c:set>

or maybe

<c:set select="$r" name="aMVAttr" index="atEnd">a value</c:set>

If you think this may be worthwhile, please submit a bugzilla enhancement.
I remember things better if they show up in bugzilla:-) Here's a
'shortcut' to submit one: version=unspecified&component=Jet&rep_platform=PC&am p;op_sys=Windows%20XP&priority=P3&bug_severity=enhan cement&bug_status=NEW&bug_file_loc=http%3A%2F%2F& ;short_desc=&comment=&commentprivacy=0&keywords= &dependson=&blocked=&maketemplate=Remember%20val ues%20as%20bookmarkable%20template&form_name=enter_bug&a mp;

Previous Topic:Getting the name of an element which is itself an attribute value
Next Topic:ensure import programatically
Goto Forum:

Current Time: Sat May 26 04:21:31 GMT 2018

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

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

Back to the top