IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

XML-GENERATE - atomic node with attribute


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 150
Location: brisbane

PostPosted: Thu Nov 06, 2025 11:58 am
Reply with quote

i have a requirement to build some XML with nodes which contain one or more attributes, as well as containing a single value : eg,

<NAME dob="20-05-1988">James</NAME>>


can this be done using XML-GENERATE?
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 150
Location: brisbane

PostPosted: Thu Nov 06, 2025 12:45 pm
Reply with quote

the actual structure i'm working on looks like :

Code:
13 FIELDVALUES.
       15 FIELD.
         20 NAME              PIC X(09) VALUE 'REQUESTID'.
        20 FIELD-VAL          PIC X(30).


every formulation of xml-generate I use gives me the following :

Code:
<FIELDVALUES>
  <FIELD NAME='REQUESTID">
       <FIELD-VAL>ABCDE</FIELD-VAL>
   </FIELD>
</FIELDVALUES>


instead of :

Code:
<FIELDVALUES>
  <FIELD NAME='REQUESTID">
     12345
 </FIELD>
</FIELDVALUES>
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2264
Location: USA

PostPosted: Fri Nov 07, 2025 12:55 am
Reply with quote

Questions.

1. What is the "formulation of xml-generate"?

2. Where the value "ABCDE", as well as "12345" come from?
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 150
Location: brisbane

PostPosted: Fri Nov 07, 2025 1:19 am
Reply with quote

the relevant portion of the XML-GENERATE is :

Code:
XML GENERATE XML-OUTPUT
  FROM OMEGA
  COUNT IN TOTAL-CHAR
  NAME COMMUNICATION1  IS "COMMUNICATION"
       TYP1  IS "TYPE"
       GLOBAL1  IS "GLOBAL"
  TYPE ..
       NAME IS  ATTRIBUTE


following a suggestion I read on a technical forum, I tried making field-val indexed as follows :

Code:
13 FIELDVALUES.
      15 FIELD.
          20 NAME                 PIC X(09).
          20 FIELD-VAL  OCCURS 1  PIC X(40).


this had no effect, other than that I had to index all references to FIELD-VAL
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 150
Location: brisbane

PostPosted: Fri Nov 07, 2025 1:20 am
Reply with quote

2. Where the value "ABCDE", as well as "12345" come from?

- these are just dummy values I used for illustrative purposes. If FIELD-VAL is set to 'ABCDE', then for my output I want to see :


Code:
<FIELDVALUES>
  <FIELD NAME='REQUESTID">
     ABCDE
 </FIELD>
</FIELDVALUES>
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 150
Location: brisbane

PostPosted: Fri Nov 07, 2025 11:58 am
Reply with quote

looked a bit further and found an answer from google AI :

here's the solution:

Code:
13 FIELDVALUES.
      15 FIELD.
           17 NAME                 PIC X(09).
           17 FIELD-VAL            PIC X(40).
           
...         


XML GENERATE XML-OUTPUT
...
  FROM OMEGA
  COUNT IN TOTAL-CHAR
  NAME COMMUNICATION1  IS "COMMUNICATION"
       TYP1  IS "TYPE"
       GLOBAL1  IS "GLOBAL"
  TYPE ...
       NAME OF FIELD  ATTRIBUTE
       FIELD-VAL CONTENT


sample output:

Code:
                  <FIELDVALUES>
                     <FIELD NAME="REQUESTID">P747414120999597251107152521976UFLQB</FIELD>
                  </FIELDVALUES>
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 150
Location: brisbane

PostPosted: Sat Nov 08, 2025 1:42 am
Reply with quote

(it was actually a work colleague that found the answer for me on google AI. )
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Sort card to generate the DSN DFSORT/ICETOOL 17
No new posts XML Generate - suppression of complex... COBOL Programming 0
No new posts XML Generate issue COBOL Programming 0
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
Search our Forums:


Back to Top