| Author |
Message
|
| eai_guy |
Posted: Tue Feb 09, 2010 11:10 pm Post subject: |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
Hi
I tried making use of FILEDNAMESPACE function to get namespace of below XML Message
| Code: |
<?xml version="1.0" encoding="UTF-8"?>
<TenantOrgMsg xmlns="http://abc.xyz.com/TenantOrigMsgSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://abc.xyz.com/TenantOrigMsgSchema TenantOrgMsg.xsd ">
<L1Element1>L1Element1</L1Element1>
<L1Element2 L1attr="121">
<L2Element1>L2Element1</L2Element1>
</L1Element2>
</TenantOrgMsg>
|
ESQL Code - It does not store anything in X , X is always empty
| Code: |
DECLARE X CHARACTER;
SET X = FIELDNAMESPACE(InputRoot.xmlnsc.TenantOrgMsg )
|
Wildcard will be as below ?
| Code: |
SET X = FIELDNAMESPACE(InputRoot.xmlnsc.*);
|
Am I missing something ? |
|
| Back to top |
|
 |
| kimbert |
Posted: Wed Feb 10, 2010 1:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5543 Location: Southampton
|
That code is not doing what you think it's doing. Time to debug your code.
I suggest a user trace. It will tell you *why* it is going wrong ( the debugger will only show you that it is going wrong ). |
|
| Back to top |
|
 |
| eai_guy |
Posted: Wed Feb 10, 2010 12:17 pm Post subject: |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
I m not able to run a user trace as I have dependency on Admin
Trace node is not giving much information........
For below message to get the namespace of TenantOrgMsg. I tried accessing the InputRoot in multilpe ways Please see below ESQLs. Have anyone used FIELDNAMSPACE, FIELDNAME functions here ?
| Code: |
<?xml version="1.0" encoding="UTF-8"?>
<TenantOrgMsg xmlns="http://abc.xyz.com/TenantOrigMsgSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://abc.xyz.com/TenantOrigMsgSchema TenantOrgMsg.xsd ">
<L1Element1>L1Element1</L1Element1>
<L1Element2 L1attr="121">
<L2Element1>L2Element1</L2Element1>
</L1Element2>
</TenantOrgMsg>
|
1. SET X = FIELDNAMESPACE(InputRoot.XMLNSC.TenantOrgMsg.xmlns);
2. SET X = FIELDNAMESPACE(InputRoot.xmlnsc.TenantOrgMsg) ;
3. SET X = FIELDNAMESPACE(InputRoot.xmlnsc.*);
[code]
Can anyone please throw some light on this ? |
|
| Back to top |
|
 |
| mgk |
Posted: Wed Feb 10, 2010 12:37 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1647
|
use *:* as the wildcard _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
| Back to top |
|
 |
| eai_guy |
Posted: Wed Feb 10, 2010 2:30 pm Post subject: |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
Thanks Everyone
Below solved it . This will always fetch namespace of root element and then I can attach new xml element to this root.
| Code: |
FIELDNAMESPACE(InputRoot.*[3].*[2]);
|
|
|
| Back to top |
|
 |
| kimbert |
Posted: Wed Feb 10, 2010 2:41 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5543 Location: Southampton
|
| Quote: |
| This will always fetch namespace of root element... |
That looks fragile. You are assuming that
a) InputRoot.XMLNSC is always the third child of InputRoot.
b) The document root element will always be the second child of InputRoot.XMLNSC.
Neither of those assumptions should be hardcoded into your flow. What if someone supplies a message with an extra header ( e.g. an RFH2 )? What if the input message does not always have an XML declaration at the start?
I suggest this (not tested):
| Code: |
| SET rootNamespace = FIELDNAMESPACE(InputRoot.XMLNSC.(XMLNSC.Folder)*:*); |
It will return the namespace of the first element child ( i.e. the root element ) under the message body. |
|
| Back to top |
|
 |
| eai_guy |
Posted: Wed Feb 10, 2010 4:51 pm Post subject: |
|
|
Voyager
Joined: 18 Oct 2007 Posts: 90
|
Hey,
Thanks a lot.
That worked...........
Regards  |
|
| Back to top |
|
 |
|
|