Author |
Message
|
apohorai |
Posted: Wed Mar 15, 2006 3:20 am Post subject: parsing TDS message from ESQL |
|
|
Apprentice
Joined: 15 Mar 2006 Posts: 26 Location: Budapest/Munich
|
Hi,
I have a MRM output, and I try to populate the data from an ESQL node.
WHILE
SET OutputRoot.MRM.whatever.*[i] = 'VALUE';
END WHILE;
My output looks like this:
(0x01000021):MRM = (
(0x01000000):message = (
(0x01000000):whatever = (
(0x02000000): = 'VALUE'
(0x02000000): = 'VALUE'
(0x02000000): = 'VALUE'
(0x02000000): = 'VALUE'
Is it possible somehow, to obtain the field names from the message set?
So, I would like to have something like this:
(0x01000021):MRM = (
(0x01000000):message = (
(0x01000000):whatever = (
(0x02000000):Field1 = 'VALUE'
(0x02000000):Field2 = 'VALUE'
Any help will be greatly appreciated. Thank you in advance. |
|
Back to top |
|
 |
elvis_gn |
Posted: Wed Mar 15, 2006 3:26 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi apohorai,
Please read the manuals ...ESQL.pdf
We can't be teaching you how to code, this is basics....
Search the pdf for FIELDNAME and FIELDVALUE....
Regards. |
|
Back to top |
|
 |
apohorai |
Posted: Wed Mar 15, 2006 3:29 am Post subject: |
|
|
Apprentice
Joined: 15 Mar 2006 Posts: 26 Location: Budapest/Munich
|
FIELDVALUE/NAME cannot be used for output |
|
Back to top |
|
 |
elvis_gn |
Posted: Wed Mar 15, 2006 3:48 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi apohorai,
After reading your reply, for a moment I thought i've lost it
What do you mean by getting the names from the message set ? when you are at your compute node, you already have your message that is in the structure of your message set definition....
Get the name of the field from the message by doing
Set OutputRoot.MRM.whatever.*[i] = FIELDNAME(InputBody.whatever.[i]);
Am i not understanding your question
Regards. |
|
Back to top |
|
 |
apohorai |
Posted: Wed Mar 15, 2006 4:07 am Post subject: |
|
|
Apprentice
Joined: 15 Mar 2006 Posts: 26 Location: Budapest/Munich
|
Hi,
Sorry, I not provided all information.
So, my input and output message format is different.
I receiving my input TDS as single lines separated by <CR><LF> ,and the ESQL codes populating the output based on a different MRM.
my input looks like
aaa,bbb,ccc,ddd
eee,fff,ggg,hhh
My output (what I would like)
block1
field1=aaa
field2=bbb and so on.
But,
As I'm using cardinality for the output, and not exact SET
SET OutputRoot.block1.*[i] = InputRoot + my procedures to get the fields from input[i]
I'm unable to get the name of field from the message set definition,
so my output is :
block1
aaa
bbb
Thanks |
|
Back to top |
|
 |
elvis_gn |
Posted: Wed Mar 15, 2006 4:15 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi apohorai,
Where does the field1, field2 exist....are they defined in the input message set...??
Did you try the code which i gave you, what outptu does it give you....??
Regards. |
|
Back to top |
|
 |
apohorai |
Posted: Wed Mar 15, 2006 4:26 am Post subject: |
|
|
Apprentice
Joined: 15 Mar 2006 Posts: 26 Location: Budapest/Munich
|
Hi,
No, they're not defined. My input just a line. (comma separated+quotes).
So if I use you code, I receive array indexing error, as I using two different message set.
Anyway, I sorted out my problem in a different way, but I'm still interesting in this. |
|
Back to top |
|
 |
elvis_gn |
Posted: Wed Mar 15, 2006 4:35 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi apohorai,
If you are not getting the field names from anywhere, then how do u expect it to generate itself in the code especially when you are not hardcoding it....
I would like to know how you did it, the only logical thing i can think of is, that you CREATE the field using some concat function to generate field1, field2.... and then SET them.....
Regards. |
|
Back to top |
|
 |
vk |
Posted: Wed Mar 15, 2006 5:02 am Post subject: |
|
|
Partisan
Joined: 20 Sep 2005 Posts: 302 Location: Houston
|
Quote: |
I'm unable to get the name of field from the message set definition |
If you have a message set defined, with appropriate field names and the delimited between fields set to ',' and delimiter between records set to <CR> <LF>, then as elvis said, you should be able to retrieve the field names and values using FIELDNAME and FIELDVALUE functions.
Can you post your message set structure. The data you posted and the comments in your post do not match.
I am also interested to know how you did this.
Regards,
VK. |
|
Back to top |
|
 |
apohorai |
Posted: Wed Mar 15, 2006 5:04 am Post subject: |
|
|
Apprentice
Joined: 15 Mar 2006 Posts: 26 Location: Budapest/Munich
|
Ok, maybe easier in this way.
Here's a very simple TDS definition (see below)
Group
field1
field2
and a simple esql:
SET OutputRoot.Properties.MessageSet = 'DUMMY';
SET OutputRoot.Properties.MessageType = 'dummy_message';
SET OutputRoot.Properties.MessageFormat = 'TDS1';
SET OutputRoot.MRM.Group.field1 = 'Field1';
SET OutputRoot.MRM.Group.*[2] = 'Field2';
The output is :
(0x01000021):MRM = (
(0x01000000):Group = (
(0x03000000):field1 = 'Field1'
(0x02000000): = 'Field2'
)
)
My question is: Is it possible to get the name for field2 from somewhere?
Maybe it's not possible at all.
Thanks
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="T_root">
<xsd:annotation>
<xsd:appinfo source="WMQI_APPINFO">
<tdsStructRep dataElementSeparation="AllElementsDelimited" delimiter="<CR><LF>" messageSetDefaultRep="TDS1"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Group" type="T_group"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="dummy_message" type="T_root">
<xsd:annotation>
<xsd:appinfo source="WMQI_APPINFO">
<MRMessage messageDefinition="/0/dummy_message;XSDElementDeclaration$MRObject"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="T_group">
<xsd:annotation>
<xsd:appinfo source="WMQI_APPINFO">
<tdsStructRep dataElementSeparation="AllElementsDelimited" delimiter="," messageSetDefaultRep="TDS1"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="field1" type="xsd:string"/>
<xsd:element minOccurs="1" name="field2" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema> |
|
Back to top |
|
 |
elvis_gn |
Posted: Wed Mar 15, 2006 5:13 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi vk,
I dont think there is an Input message set...there is only a string of data coming....
apohorai:
Yes it is not possible to populate field1 and field2, in a straight forward way, since you dont have it defined in an input message....
If you dont mind having multiple fields named field instead of field1,field2 ....You could simply do a whatever.field[i] = 'VALUE';
OR
You can also try to concat the string field and value of "i" and store it in a variable(it will be field1, field2, field3 etc) and then set this variable as the field name for the outputRoot.whatever.*[i] = FIELDVALUE(variable);
Oh God !! i'm logging off for the day....can't take it anymore..
Regards. |
|
Back to top |
|
 |
apohorai |
Posted: Wed Mar 15, 2006 5:28 am Post subject: |
|
|
Apprentice
Joined: 15 Mar 2006 Posts: 26 Location: Budapest/Munich
|
Thanks for your replies!
elvis_gn wrote: |
If you dont mind having multiple fields named field instead of field1,field2 ....You could simply do a whatever.field[i] = 'VALUE';
OR
You can also try to concat the string field and value of "i" and store it in a variable(it will be field1, field2, field3 etc) and then set this variable as the field name for the outputRoot.whatever.*[i] = FIELDVALUE(variable);
|
Unfortunately,the structure of my message is more complex than this. I just called the fields "field1" "field2" etc. I just posted these to make it easier. The real message contain more than 1000 different fieldnames, so it can be very difficult to maintain them in case of changes.
Thanks,
Regards |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Mar 15, 2006 5:51 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Let me see if I understand this.
You have an input message, that consists of a fixed set of fields that are not labeled in the message, but are delimitied.
You have an output message, that consists of the same set of fields that ARE labeled in the message.
Is this correct? That the input message has a one-to-one relationship with the output message at the field level?
Then you can create two messages - one that parses your input message and one that produces your output. The first one will be using TDS and straight delimited data. The second will use Tagged delimited data, and you will configure your labels as your tags.
Then in your code you can Set OutputRoot=InputRoot and change the properties to indicate that you are using the other message from the message set. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
apohorai |
Posted: Wed Mar 15, 2006 6:04 am Post subject: |
|
|
Apprentice
Joined: 15 Mar 2006 Posts: 26 Location: Budapest/Munich
|
You understan it right!
My original problem is described in topic "Mapping CSV to a TDS Message Set"
Unfortunately I'm unable to parse my input data, because of it's structure.
it's looks like :
"field1","field2","fie,ld3"<CR><LF>
So, there can be a comma, which is the separator between the quotes.
I'm unable to model this as a message set. So I decided to use a dummy input message set, which reading the lines, and from an ESQL node I populating my message, using my own parsing. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Mar 15, 2006 6:08 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It should be possible to parse that message using data patterns - as was suggeted in the other thread.
But the important point I'm making is that you can create the "field=" values from tags on elements in a message set, rather than putting them in your code.
So assuming you can actually parse your input and turn it into a logical message tree using SOME means... then you can copy that message tree to another that has the tags you want and the output parser will build the physical message properly. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|