Author |
Message
|
dominik.schweers |
Posted: Thu Dec 17, 2009 10:52 pm Post subject: XMLNSC losing Attributes when passing reference to function |
|
|
Novice
Joined: 23 Oct 2008 Posts: 17
|
Hi all!
I found a lot of threads about XMLNSC and attributes, but none of them could help me.
I have a very complex mapping of XML data. There are some points where I pass references to subtrees to a different ESQL function. In general this works out very nice.
Code: |
<Headquarter>
<CountryHeadquarter PrimaryHeadquarter="false">
<Country _Id="DEU">Germany</Country>
<ContactInformation>
<AddressLine1>BLA</AddressLine1>
<Country _Id="DEU">Germany</Country>
<Phone>123</Phone>
<Homepage>BLUB</Homepage>
<City>X</City>
<PostalCode>12345</PostalCode>
</ContactInformation>
</CountryHeadquarter>
<CountryHeadquarter PrimaryHeadquarter="false">
<Country _Id="ESP">Spain</Country>
<ContactInformation>
.....
</CountryHeadquarter>
</Headquarter> |
When passing this subtree as a reference to a function the attribute "_Id" seems to be gone?! It can not see it while debugging and accessing it with ESQL always returns NULL. I tried to access with
Code: |
...CountryHeadquarter.Country."_Id"
|
Any suggestions?
Thanks in advance! |
|
Back to top |
|
 |
mgk |
Posted: Fri Dec 18, 2009 1:07 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Look at the message you are creating in a trace node and make sure that the target tree belongs to a parser (XMLNSC in this case). _________________ 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 |
|
 |
dominik.schweers |
Posted: Fri Dec 18, 2009 2:55 am Post subject: |
|
|
Novice
Joined: 23 Oct 2008 Posts: 17
|
Hi MGK!
I am not creating a message. I am doing a INSERT into DB2 with data from incoming XML message.
I tried to do a USER TRACE but mqsiformatlog fails with BIP5004E. My colleague is going to open a PMR for this.
But without a trace I'm not able to help myself :/ |
|
Back to top |
|
 |
kimbert |
Posted: Fri Dec 18, 2009 3:37 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I am not creating a message |
But you are creating a message tree in your flow. That message tree either contains the 'Id' attribute or it doesn't. A Trace node will tell you one way or the other.
btw, you can still collect Trace node output even if mqsiformatlog is broken - just set the Destination to 'File' instead of 'User Trace'. |
|
Back to top |
|
 |
dominik.schweers |
Posted: Fri Dec 18, 2009 5:00 am Post subject: |
|
|
Novice
Joined: 23 Oct 2008 Posts: 17
|
Done! Here is the Result:
Code: |
(0x01000000:Folder ):Headquarter = (
(0x01000000:Folder):CountryHeadquarter = (
(0x03000100:Attribute ):PrimaryHeadquarter = 'false' (CHARACTER)
(0x03000000:PCDataField):Country = 'France' (CHARACTER)
(
(0x03000100:Attribute):_Id = 'FRA' (CHARACTER)
)
(0x01000000:Folder ):ContactInformation = (
(0x03000000:PCDataField):AddressLine1 = 'xxxxxxxxxxxxxx' (CHARACTER)
(0x03000000:PCDataField):Country = 'France' (CHARACTER)
(
(0x03000100:Attribute):_Id = 'FRA' (CHARACTER)
)
(0x03000000:PCDataField):Phone = '+33(0) XXXXXXXX' (CHARACTER)
(0x03000000:PCDataField):Homepage = 'xxxxxxxxxxxxxx' (CHARACTER)
(0x03000000:PCDataField):City = 'Paris' (CHARACTER)
(0x03000000:PCDataField):PostalCode = 'xxxxxxxxx' (CHARACTER)
)
)
(0x01000000:Folder):CountryHeadquarter = (
(0x03000100:Attribute ):PrimaryHeadquarter = 'false' (CHARACTER)
(0x03000000:PCDataField):Country = 'Italy' (CHARACTER)
(
(0x03000100:Attribute):_Id = 'ITA' (CHARACTER)
)
(0x01000000:Folder ):ContactInformation = (
(0x03000000:PCDataField):AddressLine1 = 'xxxxxxxxxxxx' (CHARACTER)
(0x03000000:PCDataField):Country = 'Italy' (CHARACTER)
(
(0x03000100:Attribute):_Id = 'ITA' (CHARACTER)
) |
In Trace there are "_Id" Attributes. In debugger in FUNCTION Main() I can see the "_Id" attributes. After passing a reference to an other function the attributes are no longer seen in debugger.
Very strange... |
|
Back to top |
|
 |
kimbert |
Posted: Fri Dec 18, 2009 5:37 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
After passing a reference to an other function the attributes are no longer seen in debugger. |
Normally I would recommend user trace, but that broken for you. You could try this:
- At the start of the function, copy the passed-in reference into the LocalEnvironment tree
- Add a Trace node after the Compute node and set its pattern to trace the LocalEnvironment.
That should show you whether the field has made it into the function. |
|
Back to top |
|
 |
dominik.schweers |
Posted: Fri Dec 18, 2009 6:00 am Post subject: |
|
|
Novice
Joined: 23 Oct 2008 Posts: 17
|
Nice idea! Thank you very much!
Tried
Code: |
SET Environment.TEST.TEST = ref_hq; |
inside my function. Result in trace is
Code: |
(0x01000000:Name):TEST = (
(0x01000000:Name):TEST = (
(0x01000000:Name):CountryHeadquarter = (
(0x03000000:NameValue):PrimaryHeadquarter = 'false' (CHARACTER)
(0x03000000:NameValue):Country = 'France' (CHARACTER)
(0x01000000:Name ):ContactInformation = (
(0x03000000:NameValue):AddressLine1 = 'xxxxxxxxx' (CHARACTER)
(0x03000000:NameValue):Country = 'France' (CHARACTER)
(0x03000000:NameValue):Phone = 'xxxxxxxxxxxxxxxx' (CHARACTER)
(0x03000000:NameValue):Homepage = 'xxxxxxxxxxxxxxxx' (CHARACTER)
(0x03000000:NameValue):City = 'Paris' (CHARACTER)
(0x03000000:NameValue):PostalCode = 'xxxxxxxxx' (CHARACTER)
)
)
(0x01000000:Name):CountryHeadquarter = (
(0x03000000:NameValue):PrimaryHeadquarter = 'false' (CHARACTER)
(0x03000000:NameValue):Country = 'Italy' (CHARACTER)
(0x01000000:Name ):ContactInformation = (
(0x03000000:NameValue):AddressLine1 = 'xxxxxxxxxxx' (CHARACTER)
(0x03000000:NameValue):Country = 'Italy' (CHARACTER)
(0x03000000:NameValue):Phone = 'xxxxxxxxxx' (CHARACTER)
(0x03000000:NameValue):EmailAddress = 'xxxxxxxxxxxx' (CHARACTER)
(0x03000000:NameValue):Homepage = 'xxxxxxxxxxxxx' (CHARACTER)
(0x03000000:NameValue):City = 'Milano' (CHARACTER)
(0x03000000:NameValue):Province = 'MI' (CHARACTER)
(0x03000000:NameValue):PostalCode = 'xxxxxxxxx' (CHARACTER)
)
) |
_Ids are gone...  |
|
Back to top |
|
 |
kimbert |
Posted: Fri Dec 18, 2009 6:17 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Now change your code to this:
Code: |
CREATE FIRSTCHILD OF Environment.TEST DOMAIN "XMLNSC" Name "TEST";
SET Environment.TEST.TEST = ref_hq;
|
...and repeat the experiment. I suspect that you will find the Id attribute there. |
|
Back to top |
|
 |
sirsi |
Posted: Fri Dec 18, 2009 6:20 am Post subject: |
|
|
Disciple
Joined: 11 Mar 2005 Posts: 177
|
just copying xmlnsc tree reference to Env variable wont suffice. Create an element in Env tree using xmlnsc domain, then only you can see desired behaviour.
dont rely on debugger, it wont show attributes properly, hopefully its fixed in v7 |
|
Back to top |
|
 |
dominik.schweers |
Posted: Wed Dec 30, 2009 6:17 am Post subject: |
|
|
Novice
Joined: 23 Oct 2008 Posts: 17
|
sirsi wrote: |
dont rely on debugger, it wont show attributes properly, hopefully its fixed in v7 |
You are right! The debugger AND the trace nodes fooled me
The attributes are there and can be accessed via ESQL select function. There was a bug in my processing at a later point.
Debugger and trace nodes do not handle attributes correctly in deep nested XML structures, especially when parts of the message tree are passed to a function using references.
This is a bug isnt it? |
|
Back to top |
|
 |
kimbert |
Posted: Mon Jan 04, 2010 2:44 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
This surprised me:
Quote: |
Debugger and trace nodes do not handle attributes correctly in deep nested XML structures, especially when parts of the message tree are passed to a function using references. |
1. I don't think it depends on how deeply nested the attributes are.
2. I don't (yet) believe you about the references/functions.
The most common reason for attributes turning into elements is user error - the tree gets copied to an environment subtree which is not owned by the same parser ( usually XMLNSC these days ).
If you really believe that this is a defect, please can you supply more details. |
|
Back to top |
|
 |
|