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 » DIRECT REFERENCING TO XML ATTRIBUTE

Post new topic  Reply to topic
 DIRECT REFERENCING TO XML ATTRIBUTE « View previous topic :: View next topic » 
Author Message
Bingo
PostPosted: Wed May 18, 2005 7:06 pm    Post subject: DIRECT REFERENCING TO XML ATTRIBUTE Reply with quote

Novice

Joined: 31 Mar 2005
Posts: 22

Hi ,

I have to create an XML in the following format.

<Root>
<Benefit>
<Profit type="one">
<Cash>CashBonusOptionCode</Cash>
</Benefit>
<Benefit>
<Profit type="two">
<EndDate>2001-01-01</EndDate>
</Benefit>
</Root>

What E-SQL code should i use so that the following XML is created ? I want to use REFERencing ........

I have been trying to do referencing to the XML attribute <Profit type="one">, but not been able to do so. Is it at all posiible in MB to reference it this way ?

The Benefit is a repeating element in the XML.

Please advise.
Back to top
View user's profile Send private message
Bingo
PostPosted: Wed May 18, 2005 7:09 pm    Post subject: Correcton Reply with quote

Novice

Joined: 31 Mar 2005
Posts: 22

The sample is actually like the one below:

<Root>
<Profit type="one">
<Cash>CashBonusOptionCode</Cash>
</Profit>
</Benefit>
<Profit type="two">
<EndDate>2001-01-01</EndDate>
</Profit>
</Benefit>
</Root>
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu May 19, 2005 2:04 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

The various keywords used to reference different types of XML data (elements, attributes, etc) are all clearly spelled out in the documentation.

And the REFERENCE keyword is also documented, and pretty well - particularly in the section on Referencing Anonymous Fields.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Bingo
PostPosted: Mon May 23, 2005 9:23 am    Post subject: Hello - Still need help Reply with quote

Novice

Joined: 31 Mar 2005
Posts: 22

Hello Jeff,

I am still struggling with this one. I have explained the complete scenario below. Please help.

Input XML
==========

<Message>
<E1>
<E11>
<E12>
<B>Data type = 'one'</B>
<C>TEST1</C>
<D>TEST4</D>
</E12>
</E11>
</E1>
<E1>
<E11>
<E12>
<B>Data1 type = 'two'</B>
<C>TEST2</C>
<D>TEST3</D>
</E12>
</E11>
</E1>
</Message>

What I am trying to do is to reference the attribute of the element <B> which is type = 'one'
and store it in some variable like below:


DECLARE myref REFERENCE TO InputRoot.MRM.Message.E1.E11.E12.B;

With this reference i can access two elements basically :

1. <B>Data type = 'one'</B>
2. <B>Data1 type = 'two'</B>

What i want to do is access these attributes through referencing and try to map it to output like the
following: For example store the reference to the attribute type = 'one' and do mapping as below.

IF myref.type = 'one' THEN

SET OutputRoot.MRM.TestOut.test = myref.C; (trying to map value TEST1)
SET OutputRoot.MRM.TestOut.test1 = myref.D;(trying to map value TEST4)

This code does not work as i have one more element under that reference. I want to know how can i store
the reference of an XML element's attribute so that i can do the mapping as explained above.One more thing, I
donot know how many such elements as <B>Data1 type = 'two'</B> can occur...so there occurance is dynamic.

Cardinality is an option, but how do i ensure that i am doing the mapping from the correct input element.Please help.
Back to top
View user's profile Send private message
Bingo
PostPosted: Mon May 23, 2005 9:39 am    Post subject: Correction in XML Reply with quote

Novice

Joined: 31 Mar 2005
Posts: 22

Actual XML looks like the follwoing..sorry for inconvenience.

Input XML
==========

<Message>
<E1>
<E11>
<E12>
<B>Data type = 'one'
<C>TEST1</C>
<D>TEST4</D>
</B>
</E12>
</E11>
</E1>
<E1>
<E11>
<E12>
<B>Data1 type = 'two'
<C>TEST2</C>
<D>TEST3</D>
</B>
</E12>
</E11>
</E1>
</Message>
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon May 23, 2005 9:46 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Everything you need to know to solve this problem is here.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Saadat
PostPosted: Wed May 25, 2005 5:14 am    Post subject: Reply with quote

Newbie

Joined: 16 May 2005
Posts: 5
Location: IBM Greenock, UK

Hi there,

This may help you to solve your issue.

DECLARE myref REFERENCE TO InputRoot.MRM.Message.E1.E11.E12.B;

IF myref.(XML.Attribute).type = 'one' THEN
--Your ESQL
Back to top
View user's profile Send private message
JT
PostPosted: Wed May 25, 2005 10:20 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Saadat wrote:
DECLARE myref REFERENCE TO InputRoot.MRM.Message.E1.E11.E12.B;

IF myref.(XML.Attribute).type = 'one' THEN
--Your ESQL

Saadat, your suggestion won't handle the other occurrences of the E1 element, since you don't specify an index for the E1 element.

Bingo wrote:

<Message>
<E1>
<E11>
<E12>
<B>Data type = 'one'
<C>TEST1</C>
<D>TEST4</D>
</B>
</E12>
</E11>
</E1>
<E1>
<E11>
<E12>
<B>Data1 type = 'two'
<C>TEST2</C>
<D>TEST3</D>
</B>
</E12>
</E11>
</E1>
</Message>

I could be wrong, but I thought spaces weren't allowed in an attribute name. So, if you remove the space, this code will produce the results you want:
Code:
SET OutputRoot.XML.TestOut.test  =
  THE(SELECT ITEM T.E11.E12.B.C FROM InputRoot.XML.Message.E1[] AS T WHERE T.E11.E12.B.(XML.attr)* = 'one');
SET OutputRoot.XML.TestOut.test1 =
  THE(SELECT ITEM T.E11.E12.B.D FROM InputRoot.XML.Message.E1[] AS T WHERE T.E11.E12.B.(XML.attr)* = 'one');

...or if you want to use REFERENCE datatypes, as you indicated, you could try this:
Code:

DECLARE inref  REFERENCE TO InputRoot.XML.Message.E1[1];
CREATE FIELD OutputRoot.XML.TestOut;
DECLARE outref REFERENCE TO OutputRoot.XML.TestOut;
      
WHILE LASTMOVE(inRef) DO
   IF FIELDVALUE(inRef.E11.E12.B.(XML.attr)*) = 'one'  THEN
      SET outRef.test  = inRef.E11.E12.B.C; 
      SET outRef.test1 = inRef.E11.E12.B.D;   
   END IF;
   MOVE inRef NEXTSIBLING;
END WHILE;
Back to top
View user's profile Send private message
Bingo
PostPosted: Thu May 26, 2005 6:35 am    Post subject: Working!!!!! BINGO Reply with quote

Novice

Joined: 31 Mar 2005
Posts: 22

Hi JT,

Thanx for the suggestion...its working . I have also tried to implement the same with While loop and its working. Thanx for all your suggestion.

Regds
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » DIRECT REFERENCING TO XML ATTRIBUTE
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.