Author |
Message
|
venugp |
Posted: Fri Sep 13, 2002 1:24 pm Post subject: How do i validate the DTD against the incoming message |
|
|
Apprentice
Joined: 03 Sep 2002 Posts: 31
|
Hi,
I have a scenario where i have to validate the XML structure for incoming message in to the message flow how the broker validates that and is there any way we can see in developement process.
If i define a message set with one structure in MRM, if the incoming message doesn't have all the XML segemnts matching to DTD which i added for structure validation in MRM what would happen?
Is there any way i can refer to the fields in compute node , the input message doesn't have those fileds by defining importing the DTD in to the message set and adding it to broker.
Please help me some body so that i can save lot of time with respect to my task.
Thanks,
venu. |
|
Back to top |
|
 |
ernest-ter.kuile |
Posted: Tue Sep 17, 2002 3:25 am Post subject: |
|
|
 Apprentice
Joined: 13 May 2002 Posts: 49 Location: KLM Holland
|
As far as I know there is no way (yet) in the broker to check an incomming xml message against a dtd.
You can always repars it using an MRM as you can import an DTD to produce a MRM. But using the MRM parser is quite time consuming (per message), the XML parser seems to be much faster (at least on z/OS).
Quote: |
If i define a message set with one structure in MRM, if the incoming message doesn't have all the XML segemnts matching to DTD which i added for structure validation in MRM what would happen? |
As xml allows optional elements, and so does MRM, I expect the MRM parser will, just as expected, mark them as such and not complain.
As to check for the existence or absence of an optional XML elements (or attributes), wel you can alway check in a compute or filter node if they are not NULL before accessing them :
Code: |
IF InputRoot.XML.Element1.Element2 IS NOT NULL THEN
handle Element2;
ELSE
handle absence of element2;
END IF; |
If an element should have been there is the first place I will forgo these tests and count on the exception mechanism to pull me out.
hope this helps.  |
|
Back to top |
|
 |
venugp |
Posted: Tue Sep 17, 2002 1:42 pm Post subject: |
|
|
Apprentice
Joined: 03 Sep 2002 Posts: 31
|
I read in the manual we can validate the DTD against incoming message uby defining the in coming structure as message set and assigning it to broker.
Message set domain and message set identifier and message identifier and format needs to be mentioned in input queue.
I am not whether i can validate the incoming message like this or is some other things i have to do.
Any help is appreciated.
Thnaks,
venu. |
|
Back to top |
|
 |
kirani |
Posted: Tue Sep 17, 2002 3:26 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
venugp wrote: |
I read in the manual we can validate the DTD against incoming message uby defining the in coming structure as message set and assigning it to broker.
|
I think you could do this in CSD3. There are some additional attributes defined in MQInput node for message validation. So far I have not used it myself .. so I am not sure about it. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
ernest-ter.kuile |
Posted: Wed Sep 18, 2002 12:38 am Post subject: |
|
|
 Apprentice
Joined: 13 May 2002 Posts: 49 Location: KLM Holland
|
venugp wrote: |
I read in the manual we can validate the DTD against incoming message by defining the in coming structure as message set and assigning it to broker.
Message set domain and message set identifier and message identifier and format needs to be mentioned in input queue.
I am not whether i can validate the incoming message like this or is some other things i have to do. |
Yep, this is what I meant when I said you could import a DTD to make a MRM out of it, and this isn't something new from CSD3, by the way.
What you cannot do is have the xml parser do it. And beside, the resulting MRM is not a complete image of the DTD. The process only works with simple DTDs and some of the possible elements from the DTD are not known to the MRM parser. Ordering inside the xml message becomes fixed, and default values are not added to the MRM tree view if absent from the xml message.
I still believe this isn't really necessary, I have to admit I'm a strong believer the incomming message should be correct in the first place. And beside, by accessing/handling your xml message you will at the same time check it for consistancy. The XML parser will check your message really is XML, and access to the necessary elements (or attributs) will generate an exception if they are absent.
Of course this is specifically our problem, as I said the MRM parser isn't really a speed daemon, the system needs to handle a lot of messages and z/OS is payed by the CPU tick.
I do recommend (and I expect you already did this) you check this out your self by importing your DTD in the system and testing the result.
Ernest. |
|
Back to top |
|
 |
aks |
Posted: Wed Sep 18, 2002 10:45 pm Post subject: |
|
|
Voyager
Joined: 19 Jul 2002 Posts: 84
|
With CSD03, I turned validation on in a compute node that receives an XML message and it validates nicely against the DTD that I imported into a message set. However, I had to use MRM xml and not self-defining xml in my ESQL transform statements.
What I can't get to work is validating the xml after it has been transformed from a commarea. The trace says it can't find an element that I know is there. When I turn off validation off, no problem.
Alan |
|
Back to top |
|
 |
AlexeiSkate |
Posted: Mon Dec 16, 2002 2:05 pm Post subject: |
|
|
Centurion
Joined: 10 Apr 2002 Posts: 123
|
Can someone tell me what CSD stands for. Thanks. |
|
Back to top |
|
 |
kirani |
Posted: Mon Dec 16, 2002 9:02 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
CSD stands for Cumulative Service Distribution. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
kwelch |
Posted: Wed Aug 20, 2003 10:00 am Post subject: |
|
|
 Master
Joined: 16 May 2001 Posts: 255
|
Ernest,
I tend to agree with you but we have some customers that are insisting we validate the dtd. We have explained to them we can do that in the code by checking for the presence of required fields but because we are getting the XML from outside of our company they are concerned that changes will be made to the format of the message and we won't pick them up. They will then be passed on to their application and bomb. So....we are attempting the validate with little success either on the input or compute. They want us to validate incoming and outgoing. Can you explain what you mean by simple DTD's. What would be an example of something that is too complex to validate? Thanks!
Karen |
|
Back to top |
|
 |
|