Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem parsing XML elements when loading XML schemas with EMF
Problem parsing XML elements when loading XML schemas with EMF [message #1403425] Wed, 23 July 2014 15:26 Go to next message
lefteris80 skoutaraidis is currently offline lefteris80 skoutaraidisFriend
Messages: 1
Registered: July 2014
Junior Member
Greetings to all and thank you for your effort in advance for helping on this.

I will try to describe in steps where I stand with the model I have created and then the problem I am having.

1. I have created an XML document and corresponding schemas that all validate well. That is, the XML document conforms to the schemas.
2. I have created an EMF project in Eclipse which I used to load and model the schemas successfully
3. I have modeled the XML document as well, i.e., import it into eclipse as a model instance and set some conditions of how to process its elements using an editor

The problem I am facing is that I cannot set rules based on the document's XML elements but only on their values.

For instance:
If I want to set a rule for a student, unrelated to what is the student name, on an XML element as:

<Student>Tom</Student>

The parser does not take into account the element's name "student" but only the actual value. I.e., I would have to set a rule for a student called Tom.

I would like to achieve something like:
<Student>x</Student>

That is, set a variable, and define a rule for any student name. However, in this case the parser focus on the variable which can take any value and the element name is ignored.

Could this be a terminal, non-terminal issue? And the parser consider the XML element name as a terminal? Is there an easy way to workaround on this?
Re: Problem parsing XML elements when loading XML schemas with EMF [message #1403450 is a reply to message #1403425] Wed, 23 July 2014 19:09 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
Registered: July 2009
Senior Member
Comments below.

On 23/07/2014 7:58 PM, lefteris80 skoutaraidis wrote:
> Greetings to all and thank you for your effort in advance for helping
> on this.
>
> I will try to describe in steps where I stand with the model I have
> created and then the problem I am having.
>
> 1. I have created an XML document and corresponding schemas that all
> validate well.
With which tool did you validate?
> That is, the XML document conforms to the schemas.
> 2. I have created an EMF project in Eclipse which I used to load and
> model the schemas successfully
Which file extension did you choose?
> 3. I have modeled the XML document as well, i.e., import it into
> eclipse as a model instance and set some conditions of how to process
> its elements using an editor
The editor is registered with a specific file extension. Which one?
>
> The problem I am facing is that I cannot set rules based on the
> document's XML elements but only on their values.
Rules?
>
> For instance:
> If I want to set a rule for a student, unrelated to what is the
> student name, on an XML element as:
>
> <Student>Tom</Student>
>
> The parser does not take into account the element's name "student" but
> only the actual value. I.e., I would have to set a rule for a student
> called Tom.
I don't understand what a "rule" is supposed to mean..
>
> I would like to achieve something like:
> <Student>x</Student>
So set the student's name to x...
>
> That is, set a variable,
Variable? XML has not concept of variables.
> and define a rule for any student name. However, in this case the
> parser focus on the variable which can take any value and the element
> name is ignored.
The element name corresponds to an xsd:element declaration in your
schema. Presumably your schema models "Student" and "Tom" is just the
name of some student.
>
> Could this be a terminal, non-terminal issue?
What?
> And the parser consider the XML element name as a terminal? Is there
> an easy way to workaround on this?
I have no idea what you're asking. I don't know what your schema looks
like. I don't know what you mean by a "rule". I don't know what you
mean by a "variable". In the end, rules and variables are not XML
concepts and with no knowledge of your specific schema, there's nothing
I can meaningfully say about your problem or what it is you're needed to
work around. If you want to control the name of an element in the
serialization, you need to define XML Schemas or Ecore models because
the model controls the name of the elements, whereas the stuff between
the <element>your-data</element> brackets in the XML represent your
model instances, your data, and that's all your control when you set
values in your instances.
Previous Topic:Problem importing PSF file from oomph & questions about tartlets
Next Topic:Is it possible to exclude certain features from EMF Java code generation?
Goto Forum:
  


Current Time: Fri Aug 23 13:28:22 GMT 2019

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

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

Back to the top