Author |
Message
|
xela |
Posted: Fri Sep 01, 2006 9:00 am Post subject: Access attributes in MRM |
|
|
Newbie
Joined: 01 Sep 2006 Posts: 3
|
How can I access atributes in a MRM.
On a V5 broker (z/OS) I did was the following :
- created a messageset set from a XML schema
- use MRM as runtime parser
- message set has namespace support
Then I used the msgset in a flow and the trace file showed me elements with correct namespace and associated with it its attributes, which were shown prefixed with a @.
This worked : SET OutputRoot.MRM.Test = InputRoot.MRM.Field.ns:Field;
(ns was declared as namespace)
This did not work
SET OutputRoot.MRM.Test = InputRoot.MRM.Field.ns:Field.attr;
nor did the follwing work
SET OutputRoot.MRM.Test = InputRoot.MRM.Field.ns:Field.(XML.Attribute)attr;
So I can access the element, but not its attributes.
Any suggestions? I would apprecate that very much.
Alex
[/list]
Last edited by xela on Mon Sep 04, 2006 4:23 am; edited 3 times in total |
|
Back to top |
|
 |
rajasri |
Posted: Sat Sep 02, 2006 12:06 am Post subject: attributes |
|
|
 Centurion
Joined: 11 Jun 2006 Posts: 114
|
hi xela, try specifying the namespace prefix for the attribute. i think this works surely |
|
Back to top |
|
 |
kimbert |
Posted: Sat Sep 02, 2006 3:55 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
the trace file showed me elements with correct namespace and associated with it its attributes, which were shown prefixed with a @. |
If you see an attribute name prefixed with '@' you can be absolutely certain that it is 'self-defining'. In other words, your message definition does not match your input XML.
One very common reason for this is leaving the XML Root Tag Name property set to its default value of 'MRM'. ( in v6 we changed the default to an empty string to avoid this ). |
|
Back to top |
|
 |
xela |
Posted: Mon Sep 04, 2006 4:22 am Post subject: |
|
|
Newbie
Joined: 01 Sep 2006 Posts: 3
|
I have tried acessing the attributes with namespace with the following code:
DECLARE ns01 NAMESPACE 'http://www.klm.com/schema/services/rcs/ViewPNR';
SET OutputRoot.MRM.Code1 = InputRoot.MRM.ns01:PNR.HostBookingReferenceID;
SET OutputRoot.MRM.Code2 = InputRoot.MRM.ns01:PNR.ns01:HostBookingReferenceID;
SET OutputRoot.MRM.Code3 = InputRoot.MRM.ns01:PNR.(XML.Attribute)ns01:HostBookingReferenceID;
None of these syntaxes work!
Then I tried the suggestion of Kimbert. No success either.
Just to give some more info of what I did :
- create a messagesetproject with a messageset (namespace enabled, roottagname blank, doctype disabled)
-imported 4 related xml schema's
- used the msg set in a msg flow, where i first remove some headers in front of the input xml, then do a reset content decriptor to the newly created msgsset and then a trace file.
The trace file looks like this :
(0x01000021):MRM = (
(0x0300000D):@Version = '1.0'
(0x01000015)http://www.klm.com/schema/services/rcs/ViewPNR:PNR = (
(0x0300000D):@HostBookingReferenceID = 'ABCDEF'
(0x0300000D):@HostCarrierCode = 'KL'
(0x0300000D):@PNR_Type = 'N'
(0x0300000D):@CD_Action = 'C'
)
(0x01000015)http://www.klm.com/schema/services/rcs/ViewPNR:TravelerInfo = (
(0x01000015)http://www.klm.com/schema/services/rcs/ViewPNR:AirTraveler = (
(0x0300000D):@SequenceNumber = '1'
(0x0300000D):@Surname = 'XXXX'
(0x0300000D):@GivenName = 'LINDA'
(0x0300000D):@NamePrefix = 'MS'
(0x0300000D):@Quantity = '1'
(0x0300000D):@PassengerTypeCode = 'ADT'
)
(0x01000015)http://www.klm.com/schema/services/rcs/ViewPNR:AirTraveler = (
(0x0300000D):@SequenceNumber = '2'
(0x0300000D):@Surname = 'XXXX'
(0x0300000D):@GivenName = 'PETER'
(0x0300000D):@NamePrefix = 'MR'
(0x0300000D):@Quantity = '1'
(0x0300000D):@PassengerTypeCode = 'ADT'
)
)
(0x01000015)http://www.klm.com/schema/services/rcs/ViewPNR:AirItinerary = (
(0x01000015)http://www.klm.com/schema/services/rcs/ViewPNR:FlightSegment = (
(0x0300000D):@FlightSequenceNumber = '1'
(0x0300000D):@MarketingAirlineCode = 'KL'
(0x0300000D):@MarketingFlightNumber = '838'
(0x0300000D):@DepartureDate = '091206'
(0x0300000D):@DepartureTime = '2320'
(0x0300000D):@ArrivalDate = '101206'
(0x0300000D):@ArrivalTime = '0525'
(0x0300000D):@DepartureAirportCode = 'SIN'
(0x0300000D):@ArrivalAirportCode = 'AMS'
(0x0300000D):@MarketingBookClass = 'T'
(0x0300000D):@Quantity = '2'
(0x0300000D):@ActionCode = 'HK'
(0x0300000D):@E_TicketEligible = 'ET'
)
(0x01000015)http://www.klm.com/schema/services/rcs/ViewPNR:FlightSegment = (
(0x0300000D):@FlightSequenceNumber = '2'
(0x0300000D):@MarketingAirlineCode = 'KL'
(0x0300000D):@MarketingFlightNumber = '1001'
(0x0300000D):@DepartureDate = '101206'
(0x0300000D):@DepartureTime = '0720'
(0x0300000D):@ArrivalDate = '101206'
(0x0300000D):@ArrivalTime = '0740'
(0x0300000D):@DepartureAirportCode = 'AMS'
(0x0300000D):@ArrivalAirportCode = 'LHR'
(0x0300000D):@MarketingBookClass = 'T'
(0x0300000D):@Quantity = '2'
(0x0300000D):@ActionCode = 'HK'
(0x0300000D):@E_TicketEligible = 'ET'
)
Any suggestions?
Xela |
|
Back to top |
|
 |
kimbert |
Posted: Mon Sep 04, 2006 11:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I've told you exactly what the problem is. The message which you are parsing does not match the structure of the message definition. This does not usually happen when the message is created by importing an XSD - the importer usually gets it right. Please stop everything else, and compare the input message with the message model. Start with the name and namespace of the root tag, and check that you have a message definition with a matching name and namespace. If that's not the problem, go down to the first-level children of the root tag and continue the process. ( you should find the problem after that, because your attribute 'version' is a first-level child, and it is self-defining ). Make sure that you do all of this using the actual message that is being parsed in the RCD node ( i.e. the message after the headers have been removed ).
If you still cannot find the problem, post the input message and the schema here. |
|
Back to top |
|
 |
xela |
Posted: Tue Sep 05, 2006 5:11 am Post subject: |
|
|
Newbie
Joined: 01 Sep 2006 Posts: 3
|
Kimbert,
thanks for advice. I checked the input message and found that it contained a wrongly spelled namespace. What I was hoping for, is that the broker would generate an excpetion telling me what is wrong with the input message instead of me manually checking XML.
I could find anything in the documentation telling me how to do that.
Xela |
|
Back to top |
|
 |
kimbert |
Posted: Tue Sep 05, 2006 6:44 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
What I was hoping for, is that the broker would generate an excpetion telling me what is wrong with the input message |
In v6, if you switch on user trace you will get a warning for every self-defining message or field which is encountered, which is a good clue that something is wrong. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 05, 2006 2:27 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
xela wrote: |
Kimbert,
thanks for advice. I checked the input message and found that it contained a wrongly spelled namespace. What I was hoping for, is that the broker would generate an excpetion telling me what is wrong with the input message instead of me manually checking XML.
I could find anything in the documentation telling me how to do that.
Xela |
You can also debug the message and output some variables using references
Set the reference to the last known good position and advance moving it:
move ref first/last child
move ref next/previous sibling...
Declare fname character fieldname(ref);
declare fns character fieldnamespace(ref);
This will quickly tell you if something unexpected is happening in the namespace / fieldnames
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
|