Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Customize XML reading/writing with ExtendedMetaData
Customize XML reading/writing with ExtendedMetaData [message #1750876] Fri, 30 December 2016 15:47 Go to next message
Joachim Engelhardt is currently offline Joachim EngelhardtFriend
Messages: 53
Registered: September 2013
Member

Hello,

I'm currently becoming desperate while trying to load an extended ecore model. In particular, I want to handle a ReqIF compliant XMI file which contains so called tool extension. The belonging excerpt of the ReqIF Ecore file is
index.php/fa/27986/0/

What already works
For the tool extensions of DOORS I created an additional Ecore definition which works for most of the concrete Ecore types which are stored in extensions.

This will work fine for the following example:
index.php/fa/27987/0/
This is my own defined Ecore class for the APPLICATION-INFO in the XML document and works for the following XML snippet:
...
  <REQ-IF-TOOL-EXTENSION>
    ...
    <doors:APPLICATION-INFO>
      <doors:VERSION>9.6.1.6</doors:VERSION>
      <doors:DOORS-REQ-IF-VERSION>4</doors:DOORS-REQ-IF-VERSION>
      <doors:BUILD-NUMBER>96451</doors:BUILD-NUMBER>
      <doors:BUILD-DATE>Mar 23 2016 22:04:27</doors:BUILD-DATE>
    </doors:APPLICATION-INFO>
  </REQ-IF-TOOL-EXTENSION>
...


The Problem
My problem is, that the DOORS extension also contains list of items which is stored directly as an element of extensions. The XML part of this will look like this:
...
  <REQ-IF-TOOL-EXTENSION>
    ...
    <doors:READONLY-ATTRIBUTES>
      <ATTRIBUTE-DEFINITION-INTEGER-REF>_db2a8224-d181-4701-b498-47942f3ceff4</ATTRIBUTE-DEFINITION-INTEGER-REF>
      <ATTRIBUTE-DEFINITION-XHTML-REF>_db2a8224-d181-4701-b498-47942f3ceff4</ATTRIBUTE-DEFINITION-XHTML-REF>
      <ATTRIBUTE-DEFINITION-DATE-REF>_db2a8224-d181-4701-b498-47942f3ceff4</ATTRIBUTE-DEFINITION-DATE-REF>
      <ATTRIBUTE-DEFINITION-ENUMERATION-REF>_db2a8224-d181-4701-b498-47942f3ceff4</ATTRIBUTE-DEFINITION-ENUMERATION-REF>
    </doors:READONLY-ATTRIBUTES>
  </REQ-IF-TOOL-EXTENSION>
...


The content of <doors:READONLY-ATTRIBUTES> are references to AttributeDefinitions which are defined in the default ReqIF namespace.
If I create an EClass for the element <doors:READONLY-ATTRIBUTES> according to the example above, I get the following result:
index.php/fa/27988/0/
This is the own defined EClass for READONLY-ATTRIBUTES which is configured by ExtendedMetaData EAnnotations for XML persistence.

Reading the example above does not work. Writing a file using this configuration results in the following XML content:
...
  <REQ-IF-TOOL-EXTENSION>
    ...
    <doors:READONLY-ATTRIBUTES>
      <doors:ATTRIBUTE-DEFINITIONS>
        <ATTRIBUTE-DEFINITION-INTEGER-REF>_db2a8224-d181-4701-b498-47942f3ceff4</ATTRIBUTE-DEFINITION-INTEGER-REF>
        <ATTRIBUTE-DEFINITION-XHTML-REF>_db2a8224-d181-4701-b498-47942f3ceff4</ATTRIBUTE-DEFINITION-XHTML-REF>
        <ATTRIBUTE-DEFINITION-DATE-REF>_db2a8224-d181-4701-b498-47942f3ceff4</ATTRIBUTE-DEFINITION-DATE-REF>
        <ATTRIBUTE-DEFINITION-ENUMERATION-REF>_db2a8224-d181-4701-b498-47942f3ceff4</ATTRIBUTE-DEFINITION-ENUMERATION-REF>
      <doors:ATTRIBUTE-DEFINITIONS>
    </doors:READONLY-ATTRIBUTES>
  </REQ-IF-TOOL-EXTENSION>
...

As you can see, during serialization there will be created the XML-Element for the EClass READONLY_ATTRIBUTES and for the EReference attributeDefinitions.

Is there a way to configure the ExtendedMetaData to work correctly with this format or is there another way how this will get feasible? For example by using the XMLHelper somehow?

I will be very thankful for any hint.

With best regards,
Joachim
Re: Customize XML reading/writing with ExtendedMetaData [message #1750888 is a reply to message #1750876] Sat, 31 December 2016 07:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
I wonder if https://www.eclipse.org/rmf/ already provides a model that parses this. I also wonder how the XML Schema defines the complex type for the doors:READONLY-ATTRIBUTES element. Is there an XML Schema for that? Perhaps it uses a lax element wildcard for the element content? A wildcard maps to a feature map. The XMLTypePackage's AnyType, corresponding to xsd:anyType, for example, has an attribute wildcard, an element wildcard, and allows mixed content and can therefore represent arbitrary XML. Modeling the Ecore EClass for READ_ONLY_ATTRIBUTES to be more like AnyType would be one way to address this problem. Otherwise, it's not clear why you haven't modeled the specific features that appear under READONLY-ATTRIBUTES; it must somehow be open ended and for that a wildcard must be used show how in the definition...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Customize XML reading/writing with ExtendedMetaData [message #1750939 is a reply to message #1750888] Mon, 02 January 2017 13:19 Go to previous messageGo to next message
Joachim Engelhardt is currently offline Joachim EngelhardtFriend
Messages: 53
Registered: September 2013
Member

Hi Ed and a Happy New Year to you,
thank you for your fast reply. Actually RMF does read this model, but the content of the ReqIFToolExtension is only shown as AnyType elements.
An (public) XML Schema for the DOORS extension does not exist unfortunately.
I see, that the ReqIFToolExtension.extensions is defined as lax element wildcard by the ExtendedMetaData.
index.php/fa/27995/0/
But I don't know how to use it for my purpose because I want to read the content of READONLY-ATTRIBUTES not as AnyType but semantically as references to a AttributeDefinition from the ReqIF Ecore meta model.
What do you mean with Modeling the Ecore EClass for READ_ONLY_ATTRIBUTES to be more like AnyType?
I haven't modeled the specific features under READONLY-ATTRIBUTES because it is a list of any specific EClass which derives from AttributeDefinition.
Re: Customize XML reading/writing with ExtendedMetaData [message #1750940 is a reply to message #1750888] Mon, 02 January 2017 13:19 Go to previous messageGo to next message
Joachim Engelhardt is currently offline Joachim EngelhardtFriend
Messages: 53
Registered: September 2013
Member

Hi Ed and a Happy New Year to you,
thank you for your fast reply. Actually RMF does read this model, but the content of the ReqIFToolExtension is only shown as AnyType elements.
An (public) XML Schema for the DOORS extension does not exist unfortunately.
I see, that the ReqIFToolExtension.extensions is defined as lax element wildcard by the ExtendedMetaData.
index.php/fa/27995/0/
But I don't know how to use it for my purpose because I want to read the content of READONLY-ATTRIBUTES not as AnyType but semantically as references to a AttributeDefinition from the ReqIF Ecore meta model.
What do you mean with Modeling the Ecore EClass for READ_ONLY_ATTRIBUTES to be more like AnyType?
I haven't modeled the specific features under READONLY-ATTRIBUTES because it is a list of any specific EClass which derives from AttributeDefinition.
Re: Customize XML reading/writing with ExtendedMetaData [message #1750976 is a reply to message #1750888] Tue, 03 January 2017 10:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
It's very hard for me to provide guidance because it's clear that some addition mapping information is coming from XMLPersistenceMappingExtendedMetadata and I know nothing about that. Just looking at what the annotation key names suggest (classifierElement -> true), what you mentioned (subclasses of AttributeDefinition), and looking at the XML you showed (ATTRIBUTE-DEFINITION-INTEGER-REF), I imagine something is interpreting the element name as a classifier name, i.e., ATTRIBUTE-DEFINITION-INTEGER-REF is somehow mapped to an EClass for some subclass of AttributeDefinition. Using purely EMF, that could be accomplished by an EPackage for the no-target-namespace scheme that defines an EReference ATTRIBUTE-DEFINITION-INTEGER-REF with the corresponding type for that from the model; it's all not pretty. But your picture in the first post doesn't show any of the annotation details for your READONLY-ATTRIBUTES class. If you're using mechanisms provided by the RMF project, it's probably better to ask on their forum, but I can't only guess at what's going on.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Emf cross reference in sphinx
Next Topic:Cross-reference type?
Goto Forum:
  


Current Time: Fri Apr 19 00:16:28 GMT 2024

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

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

Back to the top