ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MRM XML doesn't differ between empty & nonexistant tags?

Post new topic  Reply to topic
 MRM XML doesn't differ between empty & nonexistant tags? « View previous topic :: View next topic » 
Author Message
moogoo
PostPosted: Thu Jul 20, 2006 6:42 am    Post subject: MRM XML doesn't differ between empty & nonexistant tags? Reply with quote

Acolyte

Joined: 20 Sep 2002
Posts: 54
Location: US

Hi,

I've imported an XML Schema into a message set in order to perform validation on incoming msgs. Since there are a few mandatory fields that were pulled in from the Schema (minoccurs=1, maxoccurs=1), I assumed that the MRM would not distinguish the case where the element is coming in either as an empty tag (<ABC/> or <ABC></ABC) or a tag that is completely absent in the incoming message. For what I'm trying to model, both should constitute the element as being NULL and should throw an exception. Currently, when playing test messages in, only the absense of the tags throws the exception.

Is there a way in the message set to actually distinguish these two cases? If something is mandatory, it needs to have a value between the elements, else it should fail regardless if the actual tags are there or not.

Any help would be greatly appreciated.

Thanks,

MG
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jul 20, 2006 6:47 am    Post subject: Re: MRM XML doesn't differ between empty & nonexistant t Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

moogoo wrote:
If something is mandatory, it needs to have a value between the elements


Is that actually the case? My understanding (and I stress it's only an understanding) is that that schema construction defines the existence or not of the tag rather than the contents. Hence in this example the condition is met as the tag exists. Enforcing the content of a tag is something else isn't?

Or have I got this entirely wrong?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Jul 20, 2006 6:55 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Vitor is correct. The MRM validation logic is doing what any validating XML parser would do. Depending on your actual requirements, you can almost certainly do what you want. I can't be more specific without knowing what you are expecting to find between the tags. If the element is a simple value ( i.e. there are no child elements) then you can put Value Constraints ( i.e. schema facets ) on the simple type of the element. MinLength=1 would work, but you could be a lot more specific than that if you wanted to.
Back to top
View user's profile Send private message
moogoo
PostPosted: Thu Jul 20, 2006 7:11 am    Post subject: Reply with quote

Acolyte

Joined: 20 Sep 2002
Posts: 54
Location: US

Ok, thanks!

The values would be on strings. Can this length check be implemented directly in the message set properties for that element? I've looked high and low for it and haven't come across it. Or is that something that needs to be done in the schema definition?

MG
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jul 20, 2006 7:18 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

You can do it in a schema using xs:length and/or xs:pattern, but easier (as kimbert says) to do it in the message set if it's an element with no children.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Jul 20, 2006 7:25 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Can this length check be implemented directly in the message set properties for that element?
No - read my last post again! XML Schema describes simple data values using simple types. Facets like minLength are applied to simple types not to simple elements.
Same in the broker tooling, but they're called Value Constraints, and you find them in the Logical properties of a simple type. So find the simple type on which your element is based, and add one or more Value Constraints to it.
Back to top
View user's profile Send private message
moogoo
PostPosted: Thu Jul 20, 2006 8:14 am    Post subject: Reply with quote

Acolyte

Joined: 20 Sep 2002
Posts: 54
Location: US

Ok, I think I'm starting to get it. There's a property upon creation of a simple type that allows for value constraints to be specified whether it be in the schema itself or in the message set in WMB. So, since everything in the schema currently is of type "string", I would need to create a new simple type say "MandatoryString" that's still a string type underneath, and then apply my value constraints on that. Then I would go about and update all my childless elements from plain old string to "MandatoryString" should the length validation need to take place.

Am I on the right track here?

Thanks,

MG
Back to top
View user's profile Send private message
moogoo
PostPosted: Thu Jul 20, 2006 11:54 am    Post subject: Reply with quote

Acolyte

Joined: 20 Sep 2002
Posts: 54
Location: US

Hmmm...curious. I created a Simple Type Restriction element and put the minimum length of 1. I then updated the type of the element in question to the new simple type and deployed the message set to the broker. Passed in a msg with an empty tag <ABC/>, but no exceptions are being generated. Its quite possible that I forgot to do something but it seems like it should be a relatively straightforward operation.

Can anyone spot if I neglected to do something here? I'm actually surprised that it didn't work.

MG
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jul 20, 2006 1:40 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

For it to work you can apply 2 things to it:
a) element is mandatory (need the tag)
b) element is not nillable (tag cannot be empty)

That should take care of the null string problem but would potentially allow an empty string. ("")

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Thu Jul 20, 2006 11:49 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Have you enabled validation on the appropriate node ( probably MQInput ) in your message flow?
Back to top
View user's profile Send private message
moogoo
PostPosted: Fri Jul 21, 2006 7:16 am    Post subject: Reply with quote

Acolyte

Joined: 20 Sep 2002
Posts: 54
Location: US

Yup, validation is enabled on the Input node. In fact, when I was playing with the length constraints, I specified a fixed length for the new simple type and then entered data that was larger than it and it failed as expected. So that seems to be working so I wasn't doing anything silly like forgetting to deploy the msg set or using a different data element on my input msg. But that darn minLength still doesn't seem to be working...

I'm going to keep playing with it and see if I can find out anything.

Thanks!

MG
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MRM XML doesn't differ between empty & nonexistant tags?
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.