Author |
Message
|
Kjell |
Posted: Thu Sep 01, 2005 9:09 am Post subject: Cast TDS to XML and retain tags? |
|
|
Acolyte
Joined: 26 Feb 2002 Posts: 73
|
Hi, could someone help me out on this one:
I have a message set where I have defined two physical formats, TDS1 and XML1. The message arrives as TDS and it contains of a number of segments, all identified by the first 6 characters of each segment, that is a concatenation of the two fields seg-length and seg-Id.
I have setup the element of each segment to Identify the first 6 characters as a Tag. i.e. if the segment has a length of 55 chars and has ID of '10' the tag would be '005510'.
Now, after a compute node casting it to XML I would like to have these tags as elements in the XML message. How to do this? I'm struggling here,
- if I enclose the seglength and seg-Id as elements in the segments the parser will populate them with the wrong data and I I don't, these fiels will not be there in the XML message.
Anyone? |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Sep 01, 2005 9:17 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You can specify a different element name for fields in the XML physical format properties of each element. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kishoreraju |
Posted: Thu Sep 01, 2005 8:51 pm Post subject: |
|
|
Disciple
Joined: 30 Sep 2004 Posts: 156
|
your Message set working fine but the problem is that your not able to get the get correct Xml format in the target side.
I think in your Message set each segmet is defined with COmplexType or a SimpleType. If that is case then in the Physicval Properties of XML Rename the Simple Type or ComplexType with Corresponding Segment Name.Try like this if you think this will solve your
problem |
|
Back to top |
|
 |
Kjell |
Posted: Fri Sep 02, 2005 12:13 am Post subject: |
|
|
Acolyte
Joined: 26 Feb 2002 Posts: 73
|
The problem is not that the tags appear in the XML with the wrong name. The problem is that they do not appear at all.
I have the following def:
Seg01 occurs 1 time.
--Seg11 occurs 0 - 999 times
--------- SegLength 4 ch ( in this case the value is 0078)
--------- SegNr 2 ch ( in this case the value is 11)
--------- fld 1
--------- fld 2
.
.
--Seg12 occurs 0-999 times
--------- SegLength 4 ch ( in this case the value is 0056)
--------- SegNr 2 ch ( in this case the value is 12)
--------- fld 1
--------- fld 2
.
.
I allocate a type for seg01. There I set "Tagged Fixed Length". Length of tag: 6
I allocate types for Seg11 and Seg12. There I set "Fixed Length".
I allocate Element for Seg11, where I set Tag to 007811
I allocate Element for Seg12, where I set tag to 005612
I now include the Seg11 and Seg12 elements in the type for the Seg01.
I also have in each segment the Segnr and SegLength defined as elements, this implies however that these elements will be populated with the Fld1 and fld2 values and I don't want this.
My problem is thus, that I want to use the Seglength and SegNr as both Tags and elements. Is this possible? |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 02, 2005 3:59 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
This is kind of the same question as http://www.mqseries.net/phpBB2/viewtopic.php?t=24112
You can't use the same values as both tags and elements.
But you usually don't need to. As I said previously, you can set the value of the tag in TDS as the name of the element in XML. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Kjell |
Posted: Fri Sep 02, 2005 4:45 am Post subject: |
|
|
Acolyte
Joined: 26 Feb 2002 Posts: 73
|
Thanks for your efforts in supporting me.
I'm not sure I understand how to do the declaration so that something is a Tag in the TDS but appears as an Element in XML after the cast.
Could you pse detail.
Say the two fields of Seglength and Segnr form the Tag.
Do I specify them as elements in the message on the logical level? If not, exactly where do I setup the specification so that they appear as fields after cast to XML.
Maybe I'm blind now, but .. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 02, 2005 5:01 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Are you modelling your XML?
Or treating it as unmodelled XML?
If the first, then you set the xml name of a particular element in the model in the XML Physical Properties of the element in the model - in the same way that you set the tag in the TDS Physical properties.
If the second, then you name your elements when you create them, using ESQL. If you set the name of your TDS segment groups to be equal to the tags, then you don't even have to do anything complicated - the names will move over jsut fine. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Kjell |
Posted: Wed Sep 07, 2005 6:01 am Post subject: |
|
|
Acolyte
Joined: 26 Feb 2002 Posts: 73
|
I'm modelling my XML.
I cannot have it work.
I have defined an Element called SegLenght and an element called SegNr
. These two ones together form the TDS tag. The value is always '005310' of the tag (i.e. Seglength 53 an SegNr 10). So, under TDS properties for the Element of the Segment I set TAG to '005310'.
What happens now is that the parser recognises the segment but the first element (EegLength)is populated with data meant for the third one, and the second element(SegNr) is populated with data for the forth one. It seems like, since I have defined the first 6 characters as TAG the parser "parses them away" and makes them unavailable to processing. This means also that after cast to XML they are not there.
How to solve this? |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 07, 2005 6:10 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
So, now you're going from XML to TDS?
Then you don't need to worry about populating the tag. The parser should produce the tag properly when the message is written to a bitstream on output.
You just have to ensure that you are creating the right logical structure with the right data - which it sounds like you are not doing.
And it seems clear that the logical structure of your TDS message has to be different than the logical structure of your XML message. In one case, you have two elements that together are treated as an identifier - in the other case you have a single element that has an associated tag value.
So, in a very simple case, your XML might look like
Code: |
<doc>
<SegLength>
<SegNr>data</SegNr>
</SegLength>
</doc> |
This is three elements, one of which contains data.
and the TDS logical structure would look like
Code: |
Doc
SegLengthSegNrElement
data |
This is two logical elements, one of which contains data. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Kjell |
Posted: Mon Sep 12, 2005 1:12 am Post subject: |
|
|
Acolyte
Joined: 26 Feb 2002 Posts: 73
|
No, I am going from TDS to XML, sorry about my blurry description...
The follopwing is happening: I have defined a message set with a Message having TDS and XML physical layers.
The message is structured:
Seg01
- SegLength 4 ch
- SegNo 2 ch
- field 1 x ch
- field 2 y ch
-Group 1 (choice)
---------Seg011 occurs 0 to 4 times
-------------- SegLength 4 ch
-------------- SegNo 2 ch
-------------- field 1 x ch
-------------- field 2 y ch
---------Seg012 occurs 0 to 4 times
-------------- SegLength 4 ch
-------------- SegNo 2 ch
-------------- field 1 x cha
-------------- field 2 y ch
the type for the Message is set to Tagged-fixed-length
the types for the respective segments is set to fixed length.
On the element for the segments I have set the Tag value to the concatenation of the Seglength and Segno for the respective segments.
E.g. Seg01 has tag '005910', Seg011 has tag '004411' and so forth.
Now, what's happening is that when I run the flow debugger I input it as a BLOB and then run it thru an RCD node, where I set it to MRM domain and then reset message type (the one defined above) and Format TDS1.
After that node the debugger shows:
--MRM
------ SegLength = 0059
-- TDS General Error
... and that's it. I then via a compute node cast it to XML1. When I study what arrives at the output queue the parser has manages to extract Seglength and Segno, but no more.
How can I get more information on hat's wrong, than just "TDS general error". I ran the usertrace and it said NOTHING. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Sep 12, 2005 6:06 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
There isn't any more informative information in the log (outside the user trace)?
Usually, with TDS/CWF I end up having to solve problems one field at a time, working from the next one after the last successfully parsed field.
Again, though, you can't use the same message for your TDS data and for your XML data. They have to have two different logical formats.
In particular, you can't model your SegLength and SegNo fields in TDS, if they are going to be used as tags.
As long as you know for a fact that your tags are going to be constants - which they have to be... - then you can do something like
Code: |
If InputRoot.MRM.Seg01.Seg011 is not null then
Set OutputRoot.XML.Seg01.Seg011.SegNo = 01;
Set OutputRoot.XML.Seg01.Seg011=1; |
or whatever the actual hardcoded values are.
Your other choices are to not model this data, and parse it by hand using BLOB, SUBSTRING, POSITITION and etc....
Or to write your own custom parser. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|