Author |
Message
|
Harshalw |
Posted: Wed Sep 26, 2012 2:32 am Post subject: WMB MQ input node to handle two different XML's |
|
|
Voyager
Joined: 23 Jul 2008 Posts: 77
|
I Have a WMB job , receiving a XML in MQ Input node , processing the XML entries into compute node and updating the database. Now there is an requirement that there would be different XML format will be received and it will have its own XSD. I am checking here for a way , so that my application would process both the formats and parse against respective XSD. I am using WMB parser here and have created a Message set where in OLD XML will get parsed as soon as comes into Mq input node.
The Format difference is
1. Once New XML tag is added
2. Two of the XML tag has its name changed.
Though not much difference in new XML format , but application would be able to parse the old format as it comes. Please guide me . |
|
Back to top |
|
 |
whydieanut |
Posted: Wed Sep 26, 2012 2:41 am Post subject: |
|
|
 Disciple
Joined: 02 Apr 2010 Posts: 186
|
Is there any element that will let you distinguish the 2 XMLS?
Is the newly added tag always present in the new XML?
You could use such an indicator to route the message to separate branches in your flow and validate them there instead of at the Input node. |
|
Back to top |
|
 |
Harshalw |
Posted: Wed Sep 26, 2012 2:46 am Post subject: |
|
|
Voyager
Joined: 23 Jul 2008 Posts: 77
|
Yes Newly added tag will always be present .
There are two TAGS which are renamed in NEW tag
for ex - <abcd> will be named as <Varabcd> |
|
Back to top |
|
 |
whydieanut |
Posted: Wed Sep 26, 2012 2:50 am Post subject: |
|
|
 Disciple
Joined: 02 Apr 2010 Posts: 186
|
If there are no other indicators, you could check for the existence of this new tag and then route the message using the Filter or the Route to Label nodes and validate each type of message separately against separate XSDs. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 26, 2012 2:58 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
XML Schema is flexible enough to deal with both formats using one XSD. I would do this:
- add an optional ( minOccurs = 0 ) element for the new tag
- use a substitution group to handle the renamed tag. That's pretty much what substitution groups were invented for.
The only potential downside is that the flexible schema would tolerate a slightly larger range of documents than you are expecting ( mixtures of the two styles ). |
|
Back to top |
|
 |
Harshalw |
Posted: Wed Sep 26, 2012 3:33 am Post subject: |
|
|
Voyager
Joined: 23 Jul 2008 Posts: 77
|
Jedi , can you please suggest a way to add substitution group .
I have Message SET created in my WMB job . This message set is called when ever XML arrives on MQ input node and parses the XML.
THis message set name is provided in MQinput node properties section
I am using - XMLNSC - Parser from WMB tool. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 26, 2012 3:47 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
See http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/ad06100_.htm
You don't need to explicitly create the substitution groups. A group is created when one global element points at another global element via its 'substitution group' property. Here's what you need to do:
The new tags must be global elements. The old tags that they are replacing must also be global elements. In each of the new global element declarations, set the 'Substitution Group' property to point at the old version. |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Sep 26, 2012 4:50 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
whydieanut wrote: |
Is there any element that will let you distinguish the 2 XMLS?
Is the newly added tag always present in the new XML?
You could use such an indicator to route the message to separate branches in your flow and validate them there instead of at the Input node. |
That can be achieved with a dispatcher flow which is very common (on the projects that I have been)... though: you will have a couple of queues&flows then.
On the dispatcher-in-queue you don't have a message set: just use XMLNSC and in the dispatcher-flow you (will certainly find) have criteria/elements to make routing (to 2 different out-queues, which will then be the in-queues for the 2 flows with xsds (msgsets created from xsds)).
Though other solutions (as suggested before) are certainly also possible. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 26, 2012 5:01 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
mqsiuser:I think you meant to say
Quote: |
On the dispatcher-in-queue you don't switch on validation. |
...otherwise it sounds as though XMLNSC does not normally use a message set! Also, there are other uses for message sets apart from validation. |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Sep 26, 2012 5:12 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
kimbert wrote: |
On the dispatcher-in-queue you don't switch on validation. |
I just checked this: It is off by default.
kimbert wrote: |
...otherwise it sounds as though XMLNSC does not normally use a message set! |
XML "is already parsed"... meaning it is a tree-structure, basically relieving us from parsing (flat files). I thought XML(NS(C)) strengths are to just parse XML (without schema / msg set).
kimbert wrote: |
Also, there are other uses for message sets apart from validation. |
xsd is for validation ... then msg sets... for XML... and the benefits are ? |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 26, 2012 5:39 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Yes, XML can be parsed without an xsd. So it's easier to process than, say, a COBOL copybook. But please don't confuse the data format called 'XML' with the WMB parsers that handle it. |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Sep 26, 2012 6:25 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
If we create a message set (from an xsd) is the parser then parsing the XMLs faster ? |
|
Back to top |
|
 |
kimbert |
Posted: Wed Sep 26, 2012 6:28 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
No - the speed is roughly the same. May be a little slower if the xsd is a complex one. |
|
Back to top |
|
 |
|