Author |
Message
|
henrybaez |
Posted: Wed Sep 21, 2005 8:33 am Post subject: Navigate and create a new Tree changing the tags names |
|
|
 Newbie
Joined: 21 Sep 2005 Posts: 2
|
I need create a generic code to generate a mesaga, the input message is:
Code: |
<Datos>
<Field name="CodigoCliente">001</Field>
<Field name="NombreCliente">John J Rivera</Field>
<Field name="Contactos">
<Field name="Contacto">
<Field name="IdContacto">id01</Field>
<Field name="Nombre">Alexandra</Field>
</Field>
<Field name="Contacto">
<Field name="IdContacto">id02</Field>
<Field name="Nombre">maria</Field>
</Field>
</Field>
</Datos> |
the Out Message is the same tree but the name attribute is now the tag name:
Code: |
<Datos>
<CodigoCliente>001</CodigoCliente>
<NombreClienteJohn J Rivera</NombreCliente>
<Contactos>
<Contacto>
<IdContacto>id01</IdContacto>
<Nombre>Alexandra</Nombre>
</Contacto>
<Contacto>
<IdContacto>id02</IdContacto>
<Nombre>maria</Nombre>
</Contacto>
</Contactos>
</Datos> |
I Do a recursive PROCEDURE but not found, I used a REFERENCE datatypes but dont work. i think my code is to bad! cause the XML tags <Contantos> and their CHILDS are losting in the Out message.
how i do this?
this is my code, but don't work
Code: |
CREATE PROCEDURE navigate (IN root REFERENCE, IN root2 CHAR)
BEGIN
--SET answer = answer || 'Reached Field... Type:' || CAST(FIELDTYPE(root) AS CHARACTER)||
--': Name:' || FIELDNAME(root) || ': Value :' || root || ': ';
DECLARE cursor REFERENCE TO root;
MOVE cursor FIRSTCHILD;
DECLARE tagNombre CHAR;
DECLARE tagValue CHAR;
IF LASTMOVE(cursor) THEN
IF FIELDVALUE( root.(XML.Attribute)name) IS NOT NULL THEN
SET tagNombre = FIELDVALUE( root.(XML.Attribute)name);
SET tagValue = root;
SET Environment."root2".{tagNombre } = tagValue ;
END IF;
--SET answer = answer || 'Field has children... drilling down ';
ELSE
--SET answer = answer || 'Listing siblings... ';
END IF;
WHILE LASTMOVE(cursor) DO
CALL navigate(cursor, root2);
MOVE cursor NEXTSIBLING;
END WHILE;
--SET answer = answer || 'Finished siblings... Popping up ';
END; |
I hope de Output XML in the root2 parameter or in the Environment tree.
thansk for your help![/quote] _________________ Henry Baez |
|
Back to top |
|
 |
javaforvivek |
Posted: Wed Sep 21, 2005 9:50 pm Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Can you please post the entire code. Especially, how you are making a call to your procedure 'navigate'. What actual parameters are you passing through this?
What is your message definition? _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 22, 2005 12:42 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
The MRM XML parser can do this automatically - no ESQL is required.
Here's how:
- Create a message set describing the logical structure of your message
- Add two XML physical formats - InputXML and OutputXML
In the InputXML properties for each element,
- set 'Render' to 'XMLElementAttrId'
- set 'XML Name' to 'Field'
- set ' ID Attribute Name' to 'name'
In the OutputXML properties for each element
- set 'XML Render' to 'XML Element' ( XMLElement is the default )
- set 'XML Name' to the tag name you want to see in the output |
|
Back to top |
|
 |
javaforvivek |
Posted: Thu Sep 22, 2005 12:55 am Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Kimbert,
What do you mean by:
Quote: |
The MRM XML parser can do this automatically - no ESQL is required. |
I know that you can either use XML parser or MRM parser, but what is 'MRM XML' parser? Do you mean to say that, create a message set with two XML physical formats. and set parser to MRM in MQInput Node? what should be the complete settings of MQInput Node? I'm just asking this out of curiosity.. _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 22, 2005 1:47 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
MRM is a technology for message modelling - it is presently implemented as a set of individual parsers. One of those parsers is the MRM XML parser. The others are MRM TDS parser and MRM CWF parser. But that's just internal detail - I should have just said 'MRM'.
Quote: |
Do you mean to say that, create a message set with two XML physical formats. and set parser to MRM in MQInput Node? |
Yes, exactly that.
Quote: |
what should be the complete settings of MQInput Node? I'm just asking this out of curiosity.. |
The same as for any other MRM scenario. Parser is 'MRM'. 'Message Set', 'Message Domain' and 'Message Type' can either be set in the MQInput node or supplied in the message properties (perhaps via an MQRFH2 header). |
|
Back to top |
|
 |
javaforvivek |
Posted: Thu Sep 22, 2005 3:07 am Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Kimbert,
may i know how would be my message flow? I am trying this thing.
1. I have created two message set prjs (one for input and one for output) and I created msg definitions in each of them.
2. I set MQInput as you have said. Then I applied RCD which changed the Message to the output msg set.
3. Then I connected an MQoutput node
It gives me output same as input.
Where have I gone wrong? _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Sep 22, 2005 6:47 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Where have I gone wrong? |
Question (sorry but I have to ask): Did you set the XML properties to be different in the two XML physical formats, in the way I described in my previous post?
Assuming that the answer is 'yes', I would put a trace node before and after the RCD node and trace '$Root'. That way, you can check that the parsing happened as you expected. |
|
Back to top |
|
 |
|