View previous topic :: View next topic |
Author |
Message |
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Tue Dec 21, 2021 11:54 am Post subject: XML Generate and attributes |
|
|
Let's start off with what I would like to generate (note that the formatting is just to make it more readable)
Quote: |
<Amt>
<InstdAmt Ccy="SEK">123.00</InstdAmt>
</Amt>
|
I thjnk I have tried almost every example of the definitions and the XML generate variations there are. Here is the nearest I can get to it
Code: |
01 Amt-1.
05 InstdAmt-1.
10 Ccy-1 pic x(3).
|
and (the commented lines just show my various attempts that didn't work)
Code: |
move ' ' to doc
move 123 to InstdAmt-1
move 'SEK' to CCY-1
XML Generate Doc from amt-1
* with attributes
type ccy-1 is attribute
* type InstdAmt-1 is content
end-xml
|
The result of this generate gives
Quote: |
<Amt-1><InstdAmt-1 Ccy-1="SEK"></InstdAmt-1>
</Amt-1>
|
So I'm getting the ccy-1 attribute generated correctly,
but what I can't achieve is to get the value 123 "imbedded" into the InstdAmt-1 tag.
Any suggestions ? _________________ Michael |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Tue Dec 21, 2021 7:08 pm Post subject: Re: XML Generate and attributes |
|
|
misi01 wrote: |
So I'm getting the ccy-1 attribute generated correctly,
but what I can't achieve is to get the value 123 "imbedded" into the InstdAmt-1 tag.
Any suggestions ? |
misi01,
Is this a trick question? InstdAmt-1 is defined as a Group item with Ccy-1 as the ONLY element in it.
And you moved 123 to group item InstdAmt-1 which is pretty much moving '123' to CCY-1. And then again you moved 'sek1' to CCY-1 which over writes the previous move.
Did you really mean InstdAmt-1 to be a group item? _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Wed Dec 22, 2021 3:46 am Post subject: |
|
|
No, it's not a trick question, though I can understand why you ask.
It's like I've said before in this forum, when something doesn't work, is it because I'm doing it wrong, or because it simply will never work.
After even more experimentation, this was what did the trick
Code: |
*
01 Amt.
05 InstdAmt.
10 InstdAmt-content pic 999.
10 Ccy pic x(3).
*
|
and
Code: |
move ' ' to doc
move 111 to InstdAmt-content
move 'SEK' to CCY
*
XML Generate Doc from amt
type ccy is attribute
InstdAmt-content is content
end-xml
|
The end result was what I wanted
Quote: | <Amt><InstdAmt Ccy="SEK">111</InstdAmt></Amt> |
It's all about the W-S definitions and the TYPE usage in the XML generate. _________________ Michael |
|
Back to top |
|
|
|
|