Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » A question about walkers/visitors
A question about walkers/visitors [message #44318] Wed, 12 May 2004 22:51 Go to next message
Eclipse UserFriend
Originally posted by: vranganath.sbcglobal.net

Hi,

I am new to EMF/XSD. I am planning on using XSD to load up a schema
and visit parts of it. However, I could not find a visitor or a
walker that will enable me to do this. So, is there such a class
available in XSD? If so, can you point me to it? If not, is there a
reason for it's absence? Also, how can I contribute one if I do
implement such a class?

waiting for reply,

--

Venkatesh Prasad Ranganath,
Dept. Computing and Information Science,
Kansas State University, US.
web: http://www.cis.ksu.edu/~rvprasad
Re: A question about walkers/visitors [message #44350 is a reply to message #44318] Wed, 12 May 2004 23:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Venkatesh,

EcoreUtil.getAllContents and/or EObject.eAllContents can be used to walk
the containment tree and the generated XSDSwitch can be used to do
visiting.


Venkatesh Prasad Ranganath wrote:

> Hi,
>
> I am new to EMF/XSD. I am planning on using XSD to load up a schema
> and visit parts of it. However, I could not find a visitor or a
> walker that will enable me to do this. So, is there such a class
> available in XSD? If so, can you point me to it? If not, is there a
> reason for it's absence? Also, how can I contribute one if I do
> implement such a class?
>
> waiting for reply,
>
> --
>
> Venkatesh Prasad Ranganath,
> Dept. Computing and Information Science,
> Kansas State University, US.
> web: http://www.cis.ksu.edu/~rvprasad
Re: A question about walkers/visitors [message #45103 is a reply to message #44350] Fri, 21 May 2004 01:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: comfortably007numb-python.yahoo.com

Ed Merks wrote:

>Venkatesh,
>
>EcoreUtil.getAllContents and/or EObject.eAllContents can be used to walk
>the containment tree and the generated XSDSwitch can be used to do
>visiting.
>
>
>
Thanks for the pointer. However, I have questions about your suggestion.

I looked at the docs for XSDSwitch.doSwitch() says

"The *Switch* for the model's inheritance hierarchy. It supports the
call |doSwitch(object)|
< http://download.eclipse.org/technology/xsd/javadoc/org/eclip se/xsd/util/XSDSwitch.html#doSwitch%28org.eclipse.emf.ecore. EObject%29>
to invoke the |caseXXX| method for each class of the model, starting
with the actual class of the object and proceeding up the inheritance
hierarchy until a non-null result is returned, which is the result of
the switch."

Does this mean it is not a model/instance walker? In other words, given
a object of type X which inherits from Y, the switch will call caseX(),
then caseY(), and so on depending on the return value. If X contains a
reference to an object Z, it will not call caseX() followed by caseZ().
Am I right?

If so, as you suggested I can use TreeIterator to visit the elements
reachable from the root element. The only question is that what is the
ordering of iteration? Is it implicit that if elem1 occurs before elem2
in the container then the TreeIterator will return elem1 before
returning elem2 via next()?

waiting for reply,

- Venkatesh

>Venkatesh Prasad Ranganath wrote:
>
>
>
>>Hi,
>>
>>I am new to EMF/XSD. I am planning on using XSD to load up a schema
>>and visit parts of it. However, I could not find a visitor or a
>>walker that will enable me to do this. So, is there such a class
>>available in XSD? If so, can you point me to it? If not, is there a
>>reason for it's absence? Also, how can I contribute one if I do
>>implement such a class?
>>
>>waiting for reply,
>>
>>--
>>
>>Venkatesh Prasad Ranganath,
>>Dept. Computing and Information Science,
>>Kansas State University, US.
>>web: http://www.cis.ksu.edu/~rvprasad
>>
>>
>
>
>
Re: A question about walkers/visitors [message #45163 is a reply to message #45103] Fri, 21 May 2004 14:51 Go to previous message
Frank Budinsky is currently offline Frank BudinskyFriend
Messages: 478
Registered: July 2009
Senior Member
You're right that a switch is only for a single instance. The switch on
object X won't call caseZ() in your example.

The TreeIterator will do a depth-first traversal of the containment
structure.

This visitor pattern is described in the EMF book (starting on page
337), if you can get your hands on a copy.

Frank.


Venkatesh Prasad Ranganath wrote:

> Ed Merks wrote:
>
>> Venkatesh,
>>
>> EcoreUtil.getAllContents and/or EObject.eAllContents can be used to walk
>> the containment tree and the generated XSDSwitch can be used to do
>> visiting.
>>
>>
>>
> Thanks for the pointer. However, I have questions about your suggestion.
>
> I looked at the docs for XSDSwitch.doSwitch() says
>
> "The *Switch* for the model's inheritance hierarchy. It supports the
> call |doSwitch(object)|
> < http://download.eclipse.org/technology/xsd/javadoc/org/eclip se/xsd/util/XSDSwitch.html#doSwitch%28org.eclipse.emf.ecore. EObject%29>
> to invoke the |caseXXX| method for each class of the model, starting
> with the actual class of the object and proceeding up the inheritance
> hierarchy until a non-null result is returned, which is the result of
> the switch."
>
> Does this mean it is not a model/instance walker? In other words,
> given a object of type X which inherits from Y, the switch will call
> caseX(), then caseY(), and so on depending on the return value. If X
> contains a reference to an object Z, it will not call caseX() followed
> by caseZ(). Am I right?
>
> If so, as you suggested I can use TreeIterator to visit the elements
> reachable from the root element. The only question is that what is
> the ordering of iteration? Is it implicit that if elem1 occurs before
> elem2 in the container then the TreeIterator will return elem1 before
> returning elem2 via next()?
>
> waiting for reply,
>
> - Venkatesh
>
>> Venkatesh Prasad Ranganath wrote:
>>
>>
>>
>>> Hi,
>>>
>>> I am new to EMF/XSD. I am planning on using XSD to load up a schema
>>> and visit parts of it. However, I could not find a visitor or a
>>> walker that will enable me to do this. So, is there such a class
>>> available in XSD? If so, can you point me to it? If not, is there a
>>> reason for it's absence? Also, how can I contribute one if I do
>>> implement such a class?
>>>
>>> waiting for reply,
>>>
>>> --
>>>
>>> Venkatesh Prasad Ranganath,
>>> Dept. Computing and Information Science,
>>> Kansas State University, US.
>>> web: http://www.cis.ksu.edu/~rvprasad
>>>
>>
>>
>>
>>
Re: A question about walkers/visitors [message #587039 is a reply to message #44318] Wed, 12 May 2004 23:39 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Venkatesh,

EcoreUtil.getAllContents and/or EObject.eAllContents can be used to walk
the containment tree and the generated XSDSwitch can be used to do
visiting.


Venkatesh Prasad Ranganath wrote:

> Hi,
>
> I am new to EMF/XSD. I am planning on using XSD to load up a schema
> and visit parts of it. However, I could not find a visitor or a
> walker that will enable me to do this. So, is there such a class
> available in XSD? If so, can you point me to it? If not, is there a
> reason for it's absence? Also, how can I contribute one if I do
> implement such a class?
>
> waiting for reply,
>
> --
>
> Venkatesh Prasad Ranganath,
> Dept. Computing and Information Science,
> Kansas State University, US.
> web: http://www.cis.ksu.edu/~rvprasad


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: A question about walkers/visitors [message #587308 is a reply to message #44350] Fri, 21 May 2004 01:38 Go to previous message
Eclipse UserFriend
Originally posted by: comfortably007numb-python.yahoo.com

Ed Merks wrote:

>Venkatesh,
>
>EcoreUtil.getAllContents and/or EObject.eAllContents can be used to walk
>the containment tree and the generated XSDSwitch can be used to do
>visiting.
>
>
>
Thanks for the pointer. However, I have questions about your suggestion.

I looked at the docs for XSDSwitch.doSwitch() says

"The *Switch* for the model's inheritance hierarchy. It supports the
call |doSwitch(object)|
< http://download.eclipse.org/technology/xsd/javadoc/org/eclip se/xsd/util/XSDSwitch.html#doSwitch%28org.eclipse.emf.ecore. EObject%29>
to invoke the |caseXXX| method for each class of the model, starting
with the actual class of the object and proceeding up the inheritance
hierarchy until a non-null result is returned, which is the result of
the switch."

Does this mean it is not a model/instance walker? In other words, given
a object of type X which inherits from Y, the switch will call caseX(),
then caseY(), and so on depending on the return value. If X contains a
reference to an object Z, it will not call caseX() followed by caseZ().
Am I right?

If so, as you suggested I can use TreeIterator to visit the elements
reachable from the root element. The only question is that what is the
ordering of iteration? Is it implicit that if elem1 occurs before elem2
in the container then the TreeIterator will return elem1 before
returning elem2 via next()?

waiting for reply,

- Venkatesh

>Venkatesh Prasad Ranganath wrote:
>
>
>
>>Hi,
>>
>>I am new to EMF/XSD. I am planning on using XSD to load up a schema
>>and visit parts of it. However, I could not find a visitor or a
>>walker that will enable me to do this. So, is there such a class
>>available in XSD? If so, can you point me to it? If not, is there a
>>reason for it's absence? Also, how can I contribute one if I do
>>implement such a class?
>>
>>waiting for reply,
>>
>>--
>>
>>Venkatesh Prasad Ranganath,
>>Dept. Computing and Information Science,
>>Kansas State University, US.
>>web: http://www.cis.ksu.edu/~rvprasad
>>
>>
>
>
>
Re: A question about walkers/visitors [message #587343 is a reply to message #45103] Fri, 21 May 2004 14:51 Go to previous message
Frank Budinsky is currently offline Frank BudinskyFriend
Messages: 478
Registered: July 2009
Senior Member
You're right that a switch is only for a single instance. The switch on
object X won't call caseZ() in your example.

The TreeIterator will do a depth-first traversal of the containment
structure.

This visitor pattern is described in the EMF book (starting on page
337), if you can get your hands on a copy.

Frank.


Venkatesh Prasad Ranganath wrote:

> Ed Merks wrote:
>
>> Venkatesh,
>>
>> EcoreUtil.getAllContents and/or EObject.eAllContents can be used to walk
>> the containment tree and the generated XSDSwitch can be used to do
>> visiting.
>>
>>
>>
> Thanks for the pointer. However, I have questions about your suggestion.
>
> I looked at the docs for XSDSwitch.doSwitch() says
>
> "The *Switch* for the model's inheritance hierarchy. It supports the
> call |doSwitch(object)|
> < http://download.eclipse.org/technology/xsd/javadoc/org/eclip se/xsd/util/XSDSwitch.html#doSwitch%28org.eclipse.emf.ecore. EObject%29>
> to invoke the |caseXXX| method for each class of the model, starting
> with the actual class of the object and proceeding up the inheritance
> hierarchy until a non-null result is returned, which is the result of
> the switch."
>
> Does this mean it is not a model/instance walker? In other words,
> given a object of type X which inherits from Y, the switch will call
> caseX(), then caseY(), and so on depending on the return value. If X
> contains a reference to an object Z, it will not call caseX() followed
> by caseZ(). Am I right?
>
> If so, as you suggested I can use TreeIterator to visit the elements
> reachable from the root element. The only question is that what is
> the ordering of iteration? Is it implicit that if elem1 occurs before
> elem2 in the container then the TreeIterator will return elem1 before
> returning elem2 via next()?
>
> waiting for reply,
>
> - Venkatesh
>
>> Venkatesh Prasad Ranganath wrote:
>>
>>
>>
>>> Hi,
>>>
>>> I am new to EMF/XSD. I am planning on using XSD to load up a schema
>>> and visit parts of it. However, I could not find a visitor or a
>>> walker that will enable me to do this. So, is there such a class
>>> available in XSD? If so, can you point me to it? If not, is there a
>>> reason for it's absence? Also, how can I contribute one if I do
>>> implement such a class?
>>>
>>> waiting for reply,
>>>
>>> --
>>>
>>> Venkatesh Prasad Ranganath,
>>> Dept. Computing and Information Science,
>>> Kansas State University, US.
>>> web: http://www.cis.ksu.edu/~rvprasad
>>>
>>
>>
>>
>>
Previous Topic:building XSDComplexTypeDefinition programmatically
Next Topic:XSDSchema serialization
Goto Forum:
  


Current Time: Thu Apr 25 21:54:37 GMT 2024

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

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

Back to the top