Community
Participate
Working Groups
Build Identifier: 20100917-0705 It is not possible to retrieve all subelements from the annotation of a uml2 model. It is possible to get the first (of many) src element with (for example) the following code: uml2.stereotype($prop, 'Annotation::@field')/@src But this code: uml2.stereotype($prop, 'Annotation::@field')/src fails to return the set of all src elements like one would expect from a xpath expression Reproducible: Always Steps to Reproduce: 1. Create a stereotyped uml2 model which has an element with several subelements like this: <?xml version="1.0" encoding="UTF-8"?> <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Annotation="http:///schemas/Annotation/_251QsF-ZEeCpw_IcgN3SyA/0" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xsi:schemaLocation="http:///schemas/Annotation/_251QsF-ZEeCpw_IcgN3SyA/0 ./resources/Annotation.profile.uml#_25_owF-ZEeCpw_IcgN3SyA"> ... <uml:Model xmi:id="_BjRMsHu2EeCRLJRuz6xI2Q" name="m3o-API"> ... </uml:Model> ... <Annotation:_field xmi:id="_BtDa03u2EeCRLJRuz6xI2Q"> <src>classifiesSubject.AppliedMethodRole</src> <src>classifiesObject.Method</src> <src>satisfiesObject.Description</src> <src>isRelatedToConceptSubject.MethodConcept</src> </Annotation:_field> ... 2. Run the JET transformation and try to extract the src elements via uml2.stereotype (where $prop is the correct property of the stereotype): something like this: <c:setVariable var="propSrc" select="string(uml2.stereotype($prop, 'Annotation::@field')/@src)" /> will provide "classifiesSubject.AppliedMethodRole", i.e. the first value of the src elements. It is _not_ possible to retrieve a list of the src elements with something like this: <c:setVariable var="propSrc" select="uml2.stereotype($prop, 'Annotation::@field')/src" /> (or several variations that i can't remember)
This is not a problem with uml2.stereotype. Rather, it is a limitation of the XPath language (or perhaps JET's implementation of it). The XPath implementation does not expect attributes to be multi-valued. See: http://wiki.eclipse.org/JET_FAQ/How_do_I_access_multi-valued_attributes%3F for ideas on working around this.