ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Build XML tree dynamically

Post new topic  Reply to topic Goto page 1, 2  Next
 Build XML tree dynamically « View previous topic :: View next topic » 
Author Message
theone
PostPosted: Mon Feb 05, 2007 4:57 am    Post subject: Build XML tree dynamically Reply with quote

Novice

Joined: 04 Dec 2006
Posts: 15

Hi,

I need to build XML tree at runtime.
For example:

The xml path to create is a.b.c (known at runtime only) and the value should be taken from InputRoot.XML.c.d (c.d known at runtime).

The result should be:

Code:
<a>
    <b>
       <c>..</c>
    </b>
</a>


Any idea how to do that?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 05, 2007 5:03 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Yes.

This is basic use of the product. You can do this with ESQL SET statements.

The Info Center has a specific section on how to address fields dynamically and another section on how to address fields anonymously in ESQL.

Also, please use the XMLNS or XMLNSC domain, and not the XML domain.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
theone
PostPosted: Mon Feb 05, 2007 5:23 am    Post subject: Reply with quote

Novice

Joined: 04 Dec 2006
Posts: 15

Using anonymous field references let me refer to the array of children, and accessing fields dynamically let me navigate the tree using a reference. I don’t see how it can help me achieving my request. Remember that I don’t know which field I need to access and from where to take the value at build time.

How do I create a sub tree at run time? If I get the path as a runtime parameter, how do I then create it under Outputroot.XMLNS?

Lets say I get a Message:
<Root>
<First>
<Second>second</Second>
</First>
</Root>

In a db I have a column source and target (similar to mapping node, but dynamic).

Source = Root.First.Second
Target = Root.Second

I need to then create a message:
<Root>
<Second>second</Second>
</Root>

Hope it explains my requirements properly.

Thanks
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Feb 05, 2007 5:33 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

theone wrote:
Remember that I don’t know which field I need to access and from where to take the value at build time.


That's why they're called dynamic....

This is fairly straightforward stuff. You're just trying to create a sub-tree based on a pattern retrieved from a database.

I'll not comment on the wisdom of doing it. You know your requirements best.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 05, 2007 5:38 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Okay. So you have a path in the database, that is an ESQL path.

Ideally, one would like to just use {} to evaluate the variable that holds that path.

You can't, though, as {} only supports a single level (one dot).

Everything else in your question is just using the SET command.

You can also look at using XPath - but you'll likely want to do that from Java instead of ESQL, as you'd have to write at least some Java to evaluate XPath anyway.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
theone
PostPosted: Mon Feb 05, 2007 5:44 am    Post subject: Reply with quote

Novice

Joined: 04 Dec 2006
Posts: 15

Hi,

It is dynamic in the sense that you can navigate the tree without the need to know the field name.

However, in my case the field name is known at runtime. I don’t want to go over the xml tree and compare the field name of each element to the value from db.

I want to take the target value from the db and evaluate it in such way that it will create the sub tree.

I tried something like:
DECLARE path CHARACTER ‘a.b’;

SET OutputRoot.XML.{path} = ‘aaa’;

The result of it was a field called a.b.

Please comment on the wisdom of doing it. I may learn something new
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 05, 2007 5:47 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

jefflowrey wrote:
{} only supports a single level (one dot).

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
theone
PostPosted: Mon Feb 05, 2007 5:49 am    Post subject: Reply with quote

Novice

Joined: 04 Dec 2006
Posts: 15

I posted my reply before I seen your response

So based on what you say, I cannot do it in ESQL?

Thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 05, 2007 5:56 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

No.

You can do it in ESQL. You just have to evaluate the path one dot at a time.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
theone
PostPosted: Mon Feb 05, 2007 6:01 am    Post subject: Reply with quote

Novice

Joined: 04 Dec 2006
Posts: 15

Well, yes. I really don’t like it
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Feb 05, 2007 6:06 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I agree that it would be nice if one could use XPath from ESQL without having to write at least some Java.

But it's not a *lot* of Java that one has to write, nor entirely difficult. A static procedure will do the trick.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Feb 05, 2007 6:10 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

theone wrote:
Well, yes. I really don’t like it


Life is filled with injustice. We must all try the best we can to make the world a better place.

Or simply keep our heads down and work out which is the easiest / less stressful way of achieving a goal. This choice now faces you.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
theone
PostPosted: Mon Feb 05, 2007 6:10 am    Post subject: Reply with quote

Novice

Joined: 04 Dec 2006
Posts: 15

Sure.

Thanks for your help
Back to top
View user's profile Send private message
theone
PostPosted: Mon Feb 05, 2007 6:14 am    Post subject: Reply with quote

Novice

Joined: 04 Dec 2006
Posts: 15

Vitor,

Just think something so trivial should be supported by ESQL. However, I always love doing Java coding
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Feb 05, 2007 6:17 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

theone wrote:
Just think something so trivial should be supported by ESQL. However, I always love doing Java coding


Be glad you have v6 and access to Java. Some of us are condemed to remain on v2.1 for a few months longer.

I love Java coding too. I can watch the Java developers doing it for hours, longer if someone's bringing me coffee....
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Build XML tree dynamically
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.