Author |
Message
|
madi |
Posted: Tue Feb 21, 2006 8:31 am Post subject: Validation of XML |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Hi All
I have a flow which has to deal with like 5 or 6 different messages.
I want to validate the messages before I process them.I have seperate schemas for all the different messages.
So what I would need to do is have a common schema having all the message schemas in it.
Is there a way to create this schema without manually writing it out?
Also, how would the broker know which message type it has to associate the incoming msg to?
What do I give in the MessageType field in the input node?
Plz help
madi |
|
Back to top |
|
 |
vk |
Posted: Tue Feb 21, 2006 9:20 am Post subject: |
|
|
Partisan
Joined: 20 Sep 2005 Posts: 302 Location: Houston
|
You can either send the messages to the input queue for the message flow with an MQRFH2 header. The mcd folder in the MQRFH2 header can identify all the properties we define in the Input node such as Message Domain, Format, Type.
If it is not possible to send messages with MQRFH2 header, define the messge domain as BLOB in the MQInput node. Later on, you can use a compute node to go through the message body and determine the type of message.
Regards,
VK. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Feb 21, 2006 10:25 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Actually, for XML, the MRM will match the root tag against messages in the message set. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
madi |
Posted: Tue Feb 21, 2006 12:19 pm Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Exactly, so what do I do if all the messages have the same root tag??
--madi |
|
Back to top |
|
 |
vk |
Posted: Tue Feb 21, 2006 3:10 pm Post subject: |
|
|
Partisan
Joined: 20 Sep 2005 Posts: 302 Location: Houston
|
Do you have any way to differentiate 1 message from the other? Some field in the message body or some value for a particular field?
If you have, then you can go ahead with the BLOB option which I suggested earlier.
Regards,
VK. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Feb 21, 2006 3:31 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It would probably be easier to initially use XMLNS, so that the XML be parsed as a self-defining structure, instead of using BLOB.
Then madi can determine what kind of message it is, and then copy the data to a message tree modeled in the MRM and then cause the message to be validated. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
madi |
Posted: Tue Feb 21, 2006 5:02 pm Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
I am differentiating the message and sending it to different nodes for further transformation.
So you suggest that I validate after i determine what message it is?
What i want to do is when the message comes in, i want to validate it and then do the RouteTolabel logic.
I know it is possible but am not able to figure out how to get a schema that includes all the message types in it.
And once I have this schema, i dont know how the broker will know which part of the schema it has to validate the file against. i know this is done using the message type field in the MQInput node but just dont know how to.
thanks
madi |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Feb 21, 2006 11:07 pm Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi guys,
Can the use of a Choice be made here...
Add all the possible schemas under this choice and the appropriate one is recognized by the broker ??
Regards. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Feb 22, 2006 1:50 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I think elvis_gn may have a good point. It sounds as if you have a single message type which can take several forms. In XML Schema terminology, that is either a choice or a substitution group. I recommend looking at creating a single schema with a choice.
If you want more specific help. you'll neeed to give more details about exactly how your messages types differ from one another. |
|
Back to top |
|
 |
shanson |
Posted: Wed Feb 22, 2006 5:36 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
If you have several different XML documents that have the same root tag, you have created a name collision. The mechanism provided by XML to resolve this is XML Namespaces. If the schema are under your control, I suggest you give each a unique namespace.
This is the approach adopted by SWIFT XML where all their XML documents are called Document, the individual SWIFT messages being identified by a unique namespace.
What parser are you intending to use? Do you want to perform your validation against the actual XML Schema? With that information we can answer your validation question.
Note: If you solve the problem using namespaces, you will still have to use a separate message set to contain each schema. This is due to a restriction in the Message Brokers Toolkit, which does not allow mesages of the same name to exist in the same message set, even if distinguished by namespace. |
|
Back to top |
|
 |
madi |
Posted: Wed Feb 22, 2006 7:01 am Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Ok Here are the messages:
The DTDs are not in my control except for a very few of the messages. So I wont be able to change anything in the message itself, just use the message as is and do something about it!!
Both have same DOCTYPE and Root tag.
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Transaction SYSTEM "ProductResponse.dtd">
<Transaction>
<UserID>tarl</UserID>
<Password>targl01</Password>
<MerchantID>Tarom</MerchantID>
<TransactionReferenceNumber>999999</TransactionReferenceNumber>
<TransactionType>ProductResponse</TransactionType>
<EventDate>2006.02.08 09:40:03 EST</EventDate>
<Products>
<Product>
<ProductID>TC1A</ProductID>
<Log TIMESTAMP="2006.02.08 09:40:01 EST">
<User>targetxml</User>
<Application>BatchProduct $Revision: 52 $ TransactionType-BatchProduct</Application>
<Message>Missing non-NULL fields.</Message>
<Exception>
<InnotracMessage>
<MessageNumber>00018</MessageNumber>
<Argument>**Product ID**</Argument>
</InnotracMessage>
</Exception>
</Log>
</Product>
</Products>
</Transaction>
|
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Transaction SYSTEM "ProductUpdateNotification.dtd">
<Transaction>
<UserID>txml</UserID>
<Password>ta01</Password>
<MerchantID>Targm</MerchantID>
<TransactionType>Product</TransactionType>
<Product>
<ProductID>111111111111</ProductID>
<InternalProductID></InternalProductID>
<UPC></UPC>
<AlternateBarcode>
<Barcode></Barcode>
<Type></Type>
<Status></Status>
</AlternateBarcode>
<ActiveEnum></ActiveEnum>
<EffectiveDate></EffectiveDate>
<ExpirationDate></ExpirationDate>
<MustShipLTL></MustShipLTL>
<LastChangedBy></LastChangedBy>
<LastChangedDate></LastChangedDate>
<InnotracReferenceNumber></InnotracReferenceNumber>
<EventDate>2006.02.02 11:58:07 AM EST</EventDate>
</Product>
</Transaction>
|
plz help
madi |
|
Back to top |
|
 |
shanson |
Posted: Wed Feb 22, 2006 8:42 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
What version of broker are you using? |
|
Back to top |
|
 |
dilse |
Posted: Wed Feb 22, 2006 9:43 am Post subject: |
|
|
 Master
Joined: 24 Jun 2004 Posts: 270
|
I think the best way to resolve this situation would be to make the incoming message as BLOB and then in the compute node decide whether the message belongs to "ProductResponse.dtd" or "ProductUpdateNotification.dtd".
After we get the BLOB convert it to string and look for a tag which is present in one of the dtd but not in the other etc. and then do a PARSE to a particular dtd. |
|
Back to top |
|
 |
madi |
Posted: Wed Feb 22, 2006 9:55 am Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Im using 5.0.
I dont want to go that route, taking it in as BLOB and then then parsing it to whatever dtd but may be thats the only option I have !!
But still i would need a different message set for each message coz it wont allow common elements, right?
thanks
madi |
|
Back to top |
|
 |
shanson |
Posted: Wed Feb 22, 2006 10:33 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
If you don't wan't to use BLOB domain. you could try the following.
1) Look at all the 'real' DTDs
2) Create a 'common' model (DTD or Schema) that models just enough of each of the 'real' DTDs to enable you to decide which of the 'real' DTDs you need to use to parse and validate the XML message. I suggest you create a Schema and use xsd:choice to do this.
3) Your input node specifies the domain/set/type/format of the 'common' model
4) Your next node is a Compute node that tests the branches of the choice to see which 'real' DTD the message conforms to, then sets up the destination list for a RouteToLabel node. You can test the branches by moving to the first child then testing the FIELDNAME.
5) You have a message flow branch for each 'real' DTD. The Label node for each branch hands on to an RCD that specifies the 'real' domain/set/type/format for the message.
You will need a separate message set for each 'real' DTD because the names clash.
If you want to use MRM validation to validate each message then in V5 I don't think you can specify validation options on the RCD node? You can in V6 You would have to do this using ESQL CREATE LAST CHILD ... PARSE with OPTIONS, in a subsequent node, or instead of each branch having an RCD node, MQOutput to a branch-specific queue then use an MQInput node to set the validation options. |
|
Back to top |
|
 |
|