Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Resolving of id attribute value in xml handler
Resolving of id attribute value in xml handler [message #518339] Wed, 03 March 2010 20:12 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
I have data in xmi (created by exporting through a XMIResource) similar to this:
<a id="urn:schema:12345"/>
<b a="urn:schema:12345"/>

when importing the value of a is however not set in b. I can see that the XMLHandler uses the id (urn:schema:12345) but
it sets null in the a value of b.
It follows this flow:
XMLHandler.setValueFromId is called with ids equal to urn:schema:12345.

it goes into the while loop inside setValueFromId where it gets here:
else if (id.indexOf(':', 0) != -1)
{
qName = id;
continue;
}

the id has value urn:schema:12345 so it enters the if and continues with the loop. However as there is only id in the
ids variable, the loop stops. Then next it gets to this if statement:
if (position == 0)
{
setFeatureValue(object, eReference, null, -2);
}

as the loops stops before it can increase the position to 1, so therefore it gets into this if statement and null is set
in the feature (although it has the id of an object).

The : has a special meaning here, is there a way to let EMF see these names with : as a standard id? Or am I missing
something very obvious....

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Resolving of id attribute value in xml handler [message #518380 is a reply to message #518339] Wed, 03 March 2010 22:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33146
Registered: July 2009
Senior Member
Martin,

Comments below.


Martin Taal wrote:
> Hi,
> I have data in xmi (created by exporting through a XMIResource)
> similar to this:
> <a id="urn:schema:12345"/>
> <b a="urn:schema:12345"/>
That's not actually a well formed XML Schema ID. Technically, IDs need
to be NCNames, i.e., non-colonized names.
>
> when importing the value of a is however not set in b. I can see that
> the XMLHandler uses the id (urn:schema:12345) but it sets null in the
> a value of b.
> It follows this flow:
> XMLHandler.setValueFromId is called with ids equal to urn:schema:12345.
>
> it goes into the while loop inside setValueFromId where it gets here:
> else if (id.indexOf(':', 0) != -1)
> {
> qName = id;
> continue;
> }
>
> the id has value urn:schema:12345 so it enters the if and continues
> with the loop. However as there is only id in the ids variable, the
> loop stops. Then next it gets to this if statement:
> if (position == 0)
> {
> setFeatureValue(object, eReference, null, -2);
> }
>
> as the loops stops before it can increase the position to 1, so
> therefore it gets into this if statement and null is set in the
> feature (although it has the id of an object).
>
> The : has a special meaning here, is there a way to let EMF see these
> names with : as a standard id? Or am I missing something very obvious....
No because ":" isn't a standard character in an ID. In general, EMF
will expect QName ID/anyURI pairs where the QName is optional. An anyURI
is recognized by the fact it contains "#", a character that can't
appear in an ID or a QName, and ID is then recognized by virtue of
having no ":" while the QName will have a ":". If you need the actual
value in the model to have a ":", you should define an EDataType that
encodes the ":" to result in a well formed ID in the serialization.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EMF newbie wholly unable to "regenerate" EMF: what is wrong?
Next Topic:how to add OCL constraints in my metamodel ?
Goto Forum:
  


Current Time: Sat May 11 07:09:57 GMT 2024

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

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

Back to the top