Author |
Message
|
a.murphy |
Posted: Fri Oct 04, 2013 2:46 am Post subject: how to check namespace declaration in message |
|
|
Newbie
Joined: 15 Jul 2013 Posts: 5
|
Hello
So i need to perform a check on a message to see if a namespace exists or not. So if it doesnt exist, add it, if it does exist do nothing.
So the code I have at the min is:
IF OutputRoot.XMLNSC.cst:Customer.(XMLNSC.NamespaceDecl)xmlns:loc IS NULL OR
OutputRoot.XMLNSC.cst:Customer.(XMLNSC.NamespaceDecl)xmlns:loc = NULL THEN
SET OutputRoot.XMLNSC.cst:Customer.(XMLNSC.NamespaceDecl)xmlns:loc = loc;
END IF;
So Im checking whether it is null but regardless if its there or not, it still jumps into the if statement and sets the namespace.
Can anyone please advise me where I am going wrong |
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri Oct 04, 2013 3:41 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Mods please move to WMB forum.
Why mess with an IF statement? As my favorite tee vee oven host says, "just set it and forget it."
Don't forget to treat InputRoot as immutable (read-only). This implies that you build your own OutputRoot. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Oct 04, 2013 4:32 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You're writing an If Statement that asks if there is a NAMESPACE DECLARATION.
This is not the same thing as asking if an element BELONGS TO A NAMESPACE.
You need to make sure all your elements belong to the right namespaces. You don't need to declare your namespaces all over the place. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Oct 04, 2013 10:19 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Check out the namespace sample - it contains some code that allows you to recursively walk a message tree and add/remove namespaces. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
dogorsy |
Posted: Sat Oct 05, 2013 12:39 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
kimbert wrote: |
Check out the namespace sample - it contains some code that allows you to recursively walk a message tree and add/remove namespaces. |
Interesting sample, but there is an esql example that I like a lot better ( it is a recursive function ) and navigates the whole tree, the starting point is decided on the 1st call to it. Needs some changing to alter/add/remove namespaces, but nothing to complicated
The function is Navigate, can be found under CREATE PROCEDURE statement, esql example 2 |
|
Back to top |
|
 |
mqceries |
Posted: Mon Oct 07, 2013 6:40 am Post subject: |
|
|
 Acolyte
Joined: 02 Dec 2011 Posts: 70
|
sorry to jump in, seems like a interesting topic. If you have solved the issue kindly please leave us a snippet so that it will help us in the future.
thanks. |
|
Back to top |
|
 |
kimbert |
Posted: Mon Oct 07, 2013 6:50 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I agree with dogorsy - the recursive tree walk in the namespaces sample is not particuarly elegant. The one in the other topic looks a lot better, but the usual advice applies here : don't just copy and paste the code. Read it, understand how it works, and only then trust it to do the job. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
dogorsy |
Posted: Mon Oct 07, 2013 7:28 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
mqceries wrote: |
sorry to jump in, seems like a interesting topic. If you have solved the issue kindly please leave us a snippet so that it will help us in the future.
thanks. |
if you read the comments you will find where to find the sample code. As kimbert says in the previous post, you will need to read the code , understand it and modify it to your needs. Code in the IBM documentation is normally tested and if it does not work you can raise a doc PMR, whilst code given in this forum is not guaranteed. |
|
Back to top |
|
 |
|