Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Navigating a PlainXmlModel
Navigating a PlainXmlModel [message #1784863] Wed, 04 April 2018 21:27 Go to next message
Sina MadaniFriend
Messages: 160
Registered: November 2015
Location: York, UK
Senior Member
Hi,

I'm trying to query the values of a minimal XML model. The structure is:

<a>
	<b x="1">
	</b>
	<b x="2">
	</b>
	<c x="1">
	</c>
	<c x="2">
	</c>
</a>


However I can't seem to find any documentation regarding how one would go about accessing attributes and elements. The only workaround I've found is the following, for example trying to get attribute "x" of element "b" (of type t_b) is:

b.getAttributes().getNamedItem("x").getNodeValue()


Probably due to the way reflection works, this attempts to call the methods directly on the implementing instance (in this case, it's com.sun.org.apache.xerces.internal.dom.ElementImpl.getAttributes()) rather than on the interface, leading to warnings about illegal reflective access (from Java 9 onwards).

I was wondering if there's some obvious way that I've missed? Looking at the source for PlainXmlModel, I don't see any obvious notation.

Thanks,
Sina
Re: Navigating a PlainXmlModel [message #1784864 is a reply to message #1784863] Wed, 04 April 2018 21:32 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Sina,

b.a_x should do the trick as per [1].

Cheers,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/plain-xml/
Re: Navigating a PlainXmlModel [message #1784865 is a reply to message #1784863] Wed, 04 April 2018 21:34 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 119
Registered: September 2012
Location: York, UK
Senior Member
Hi,

You prefix the attribute name with keywords + underscore, for example, if the attribute is supposed to be integer you do
b.i_x to retrive its value
Of course if I understood your question correctly.

There are some examples on the Epsilon website, you can refer to [1].

Cheers,
Will

[1]. https://www.eclipse.org/epsilon/doc/articles/plain-xml/


Research Associate
Department of Computer Science
University of York
Re: Navigating a PlainXmlModel [message #1784866 is a reply to message #1784865] Wed, 04 April 2018 21:37 Go to previous message
Sina MadaniFriend
Messages: 160
Registered: November 2015
Location: York, UK
Senior Member
Thanks! I can't believe I didn't see that article on Epsilon website.
Previous Topic:EGL
Next Topic:Accessing enum outside Metamodel
Goto Forum:
  


Current Time: Wed Apr 24 14:16:30 GMT 2024

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

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

Back to the top