Author |
Message
|
RichA |
Posted: Fri Sep 30, 2005 7:17 am Post subject: MRM Parsing |
|
|
 Centurion
Joined: 14 Mar 2002 Posts: 102
|
I have XML messages similar to these (simplified)
1.
<SYSMSG>
<ELEMENT/>
</SYSMSG>
<SYSDATA>
<DATA1>
<DATA1.1/>
</DATA1>
</SYSDATA>
2.
<SYSMSG>
<ELEMENT/>
</SYSMSG>
<SYSDATA>
<DATA1>
<DATA2/>
</DATA1>
</SYSDATA>
I'm trying to model this in the MRM using a single message set so I have -
two types SYSMSG & SYSDATA which make up the two high level elements. SYSDATA has a DATA1 tag with a wildcard element where the lower level tags are, this will parse fine.
However what I want to do is define two different messages, one with DATA1.1 tag and another with DATA2 tag, then have them parsed (by different message flows of course), is what I'm trying to do possible or should I be approaching this differently?
I have run up against a couple of problems trying to do this, one being I'm trying to have Duplicate XML name for global elements. (The Logical names are different, but it still complains that the physical names are the same.) Another is trying to create a new complex type derived from the existing base type SYSDATA, deriving by extension doesn't allow me to add elements below the root of that type, I'm not sure how the deriving by restriction works. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 30, 2005 7:28 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You can do this as two different messages. I guess I'm not sure why, though.
The DATA1 elements will have to have different names and be different types. This doesn't mean that they have to have different XML Element names, in the physical format.
Alternately, you could do this as a single element where Data1 contains a CHOICE, rather than a wildcard. I don't know how much difference it makes, though (I'm not up to speed on wildcard elements). It might allow you to validate Data1.1 and Data2 better, though. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
RichA |
Posted: Sat Oct 01, 2005 1:18 am Post subject: |
|
|
 Centurion
Joined: 14 Mar 2002 Posts: 102
|
Well the majority of the messages I'm dealing with have this wrapper where only the lower level elements change accoriding to the function that's being called, based on the old best practices redbook each function is coming in on a different queue <system>.<application>.<function>.<sub-function> I would like to think that I can rely on the people writing the application to queue side of things to put the right messages to the right queue, in which case I could just parse based on a choice or a wildcard for the lower level element to do that in this case would successfully parse functions that were sent to incorrect queues and hence would have to be dealt with in code. My preference would be to throw them out. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Oct 01, 2005 3:32 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
That makes sense.
But you could put a simple router pattern in place instead. Then they all write to one queue, and you deal out messages to the right flow based on data.
Maybe your performance requirements prevent this. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
RichA |
Posted: Sat Oct 01, 2005 6:21 am Post subject: |
|
|
 Centurion
Joined: 14 Mar 2002 Posts: 102
|
I did contemplate that, but I am uncertain as to the volume of messages being queued, I am told at least one of the functions is batch and as such is likely to put in excess of 5000 messages on a queue within a very short space of time. Currently we're only in development and as such I have stuck with the 5000 max queue depth, before it goes into production I'll do some performance testing, but that was one of the reasons I have stuck with separate queues per function. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Oct 03, 2005 12:42 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I have run up against a couple of problems trying to do this, one being I'm trying to have Duplicate XML name for global elements. (The Logical names are different, but it still complains that the physical names are the same.) |
Same logical name with different physical names is fine. The other way round is not ( because the parser needs to be able to use the tag to uniquely identify a global element )
Quote: |
Another is trying to create a new complex type derived from the existing base type SYSDATA, deriving by extension doesn't allow me to add elements below the root of that type, I'm not sure how the deriving by restriction works. |
Deriving by extension should allow you to add extra elements to the complex type. Deriving by restriction means that you either remove elements/attributes, or you reduce the number of occurrences of them. Maybe you are getting confused by the way the editor displays extensions. The part within curly braces represents the inherited content, and the other members represent the extended content. |
|
Back to top |
|
 |
RichA |
Posted: Mon Oct 03, 2005 4:59 am Post subject: |
|
|
 Centurion
Joined: 14 Mar 2002 Posts: 102
|
So if I were to derive by extension do I need to add all the parent elements of the element I'm trying to add in? e.g. SYSDATA & DATA1?
I have almost had some success trying to do this, but it fails to parse correctly where it believes the message fails the minOccurs constraint for the element I have tried to extend.
I have tried to change the restraint so the minOccurs is 0 for the element in the parent type, but I still end up with the same exception.
<edit>
Curiously I have noticed it's not quite working as expected. It's actually telling me 78^<element name> has 0 instances on the logical tree, if I send a message with two of that element it then complains <element name> has 2 instances which of course doesn't fit the maxOccurs constrraint. I wonder where the "78^" is coming from? Any ideas anyone? |
|
Back to top |
|
 |
kimbert |
Posted: Mon Oct 03, 2005 6:53 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
So if I were to derive by extension do I need to add all the parent elements of the element I'm trying to add in? |
No - you only need to add the extended content.
Quote: |
I have almost had some success trying to do this |
You just got lucky - don't rely on it...
Quote: |
but it fails to parse correctly |
...as I was saying!
The errors regarding minOccurs and maxOccurs are caused by your type extension mistake. You have two instances of the same element within the same structure [the inherited one, and the one you incorrectly added again], and the MRM parser cannot decide how to assign the elements in the input message to the elements in the model.
Quote: |
I wonder where the "78^" is coming from? |
This is a quirk of the MRM diagnostic messages. All local elements have a unique integer prepended to their name, in case they have the same name as other local elements. You should ignore everything up to the '^'. |
|
Back to top |
|
 |
RichA |
Posted: Mon Oct 03, 2005 7:30 am Post subject: |
|
|
 Centurion
Joined: 14 Mar 2002 Posts: 102
|
How does it know where in the XML to parse the extended element then as it only seems possible to add extended elements at the highest level of the extended part of the message. Adding elements to anywhere below that level also adds them to the message type and thus negates my reasons for doing this.
Okay, I was being temporarily stupid and now I think I understand. Apologies and thanks for all your help. I had the wrong element as being extensible, I didn't realise I needed to create an empty type to use as the root of the changeable part of the message.
No, now I'm even more confused, if I add the type as an extendible type to the lower element of my message then I try to create a new message based using this type then I try to add to the extendible element it also adds to the type, what's the point of that? |
|
Back to top |
|
 |
|