Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Epsilon Plain Xml Transformation(Error in Quering Xml Elements CDATA In EOL Program)
Epsilon Plain Xml Transformation [message #1383944] Tue, 27 May 2014 10:43 Go to next message
Gurdeep gsr is currently offline Gurdeep gsrFriend
Messages: 2
Registered: May 2014
Junior Member
I have the following xml file:

<xyz-abc name="op">
<a>ddm</a>
<b>jdkd</b>
<xyz-abc name="ot">
<xyz-abc>
<a>kjdk</a>
<b>nkdnc</b>
</xyz-abc>.

So here, the element xyz-abc has a 'hyphen' in the tagname.
Now, to read xyz-abc element in the eol file :
var element=`t_xyz-abc`.all

(PS: I am using back ticks as I was getting an exception when not using them. Without back ticks, only the part after the hyphen ie., abc was being taken as the tagname.)

Althought back ticks are doing the trick to retrieve the element (not sure), but I am facing problem when I am trying to retrieve the attributes etc., of that element.
For instance, element.println() prints:
] org.eclipse.epsilon.eol.types.EolModelElementType@4094da61


But,

element.a_name.println() raises the following exception :
Property 'a_name' not found in object org.eclipse.epsilon.eol.types.EolModelElementType@4094da61


I need some suggestion on how to deal with elements which have hyphen in their tag names.
Re: Epsilon Plain Xml Transformation [message #1383975 is a reply to message #1383944] Tue, 27 May 2014 15:40 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2162
Registered: July 2009
Location: York, UK
Senior Member

Hi,

You can get hold of all xyz-abc elements using `t_xyz-abc`.all. To get the values of their name attribute, you need to iterate through them i.e.

for (xyz in `t_xyz-abc`.all) {
xyz.a_name.println();
}

Cheers,
Dimitris
Re: Epsilon Plain Xml Transformation [message #1384077 is a reply to message #1383975] Wed, 28 May 2014 04:54 Go to previous messageGo to next message
Gurdeep gsr is currently offline Gurdeep gsrFriend
Messages: 2
Registered: May 2014
Junior Member
Thankyou Dimitris. That works.

There are two other problems which I am facing:
1)Is there a way to append a new child at a particular position .ie.,
consider this file:
<school>
<student>a</student>
<student>b</student>
<teacher>x</teacher>
<teacher>y</teacher>
..
..
</school>
Now when I add a new student:
var s=t_school;
s.createStudent();
operation Element createStudent()
{
var s=new t_student;
self.appendChild(s);
}


After this the file looks like:
<school>
<student>a</student>
<student>b</student>
//Can new student be added here??
<teacher>x</teacher>
<teacher>y</teacher>
..
..
<student/>
</school>

I want the new 'student' be added in place with the previous 'students' , as there is some validation process which requires such placement.

2)Once the file has been edited by the eol, the file is left with some unwanted escaped characters:
For eg.,
<student id ="123" status='query.isdaysScholar("123")'/>
After running the eol, this appears:
<student id ="123" status="query.isdayscholar(&quot;123&quot;)"/>

So, the single quotes surround a method call are being replaced by double quotes and also, the double quotes around the method parameter are being escaped to "&quot;".
Is there a way to force stop this escaping ?

[Updated on: Wed, 28 May 2014 09:03]

Report message to a moderator

Re: Epsilon Plain Xml Transformation [message #1384131 is a reply to message #1384077] Wed, 28 May 2014 07:54 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2162
Registered: July 2009
Location: York, UK
Senior Member

Hi Gurdeep,

1) I'd suggest using http://docs.oracle.com/javase/6/docs/api/org/w3c/dom/Node.html#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)

2) I'm afraid that this is not possible at the moment. If you need such a feature, please feel free to file an enhancement request using the link below

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=epsilon

Cheers,
Dimitris
Previous Topic:Broken Link to the Model File in the EGL Tutorial
Next Topic:org.eclipse.epsilon.erl.IErlModule can't be resolved?
Goto Forum:
  


Current Time: Fri Apr 19 12:06:53 GMT 2024

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

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

Back to the top