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

Any example of XML GENERATE nested statements?


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

New User


Joined: 22 Sep 2015
Posts: 4
Location: United States

PostPosted: Tue Sep 22, 2015 7:48 pm
Reply with quote

Hi everyone,

I want to generate an XML message with two namespaces such as:

Code:

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
    <tns:RequestData version="1.0"   
xmlns:tns="urn:firstNamespace"
xmlns:tns2="urn:secondNamespace">
        <tns2:GetRequest>
            <tns2:Id>contents</tns2:Id>
           <tns2:validityPeriod>1</tns2:validityPeriod>
       </tns2:GetRequest>
     </tns:RequestData>
  </soapenv:Body>
</soapenv:Envelope>


In the Enterprise COBOL for z/OS, V4.1, Language Reference -> XML GENERATE statement -> Nested XML GENERATE or XML PARSE statements section, it's stated that we can perform these type of nested instructions, although I haven't found any example of it.
In my opinion, this would be the way, by nesting XML GENERATE instructions, to get to generate an XML message with two namespaces.

Any advice on how to get to work this scenario?
Thank you.
Mariana.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 22, 2015 8:06 pm
Reply with quote

Well, you've got three namespaces, not two.

You can't specify multiple namespaces on one XML GENERATE.

You'll have to do multiple XML GENERATEs, two or more, and put the data together. Or post-process the output of one XML GENERATE.

What is the purpose of the tns2 namespace? You don't have any duplicate names in what you have shown.
Back to top
View user's profile Send private message
marianambot

New User


Joined: 22 Sep 2015
Posts: 4
Location: United States

PostPosted: Tue Sep 22, 2015 9:45 pm
Reply with quote

Bill Woodger wrote:
Well, you've got three namespaces, not two.

You can't specify multiple namespaces on one XML GENERATE.

You'll have to do multiple XML GENERATEs, two or more, and put the data together. Or post-process the output of one XML GENERATE.

What is the purpose of the tns2 namespace? You don't have any duplicate names in what you have shown.


Hi Bill,

I assume that by multiple XML GENERATEs, you are referring to 'Nested XML GENERATE' statements as indicated by IBM, and I would love to see a concrete example as a reference to base what I want to perform.

The example I gave seems out of purpose, but it's a simple one of what I want to achieve, just more than one namespace being specified in the body of the XML message. The application will have a more complex structure than this one, but I would like to have clear how to generate what I have mentioned.

Thanks for your quick reply.
Mariana.
Back to top
View user's profile Send private message
marianambot

New User


Joined: 22 Sep 2015
Posts: 4
Location: United States

PostPosted: Tue Sep 22, 2015 10:21 pm
Reply with quote

Forgot to include the working storage definition:

Code:

01  XML-OUTPUT1                       PIC X(1000) VALUE QUOTES.
01  XML-OUTPUT2                       PIC X(1000) VALUE QUOTES.
01  XML-CHAR-COUNT1               COMP PIC 999.
01  XML-CHAR-COUNT2               COMP PIC 999.
01  NAME-SPACE1                       PIC X(18)
      VALUE 'urn:firstNamespace'.
01  NAME-SPACE2                       PIC X(19)
      VALUE 'urn:secondNamespace'.
01  NS-PREFIX1                           PIC X(5)    VALUE 'tns'.
01  NS-PREFIX2                           PIC X(5)    VALUE 'tns2'.
01  RequestData.
  05  GetRequest.
    10  Id                                      PIC X(6)  VALUE 'contents'.
    10  validityPeriod                     PIC X(1)  VALUE '1'.


Thanks.
Mariana.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 22, 2015 11:33 pm
Reply with quote

That just documents that you can have an XML GENERATE/XML PARSE on the ON EXCEPTION/NOT ON EXCEPTION, and how the END-XMLs match in that case.

I don't think it gives you any particular "xml structure" benefit.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 23, 2015 1:59 am
Reply with quote

So to clarify, no, I didn't mean nested XML statements. I meant multiple.


XML GENERATE ...

XML GENERATE ...
Do anything else necessary.

That would get you two pieces of output, which can then have different namespaces, and you can stick them together.

If it is convenient, use three.

Don't get stuck to the idea that the output has to look like your COBOL 01, so your have to use that COBOL 01.
Back to top
View user's profile Send private message
marianambot

New User


Joined: 22 Sep 2015
Posts: 4
Location: United States

PostPosted: Wed Sep 23, 2015 7:08 pm
Reply with quote

Bill Woodger wrote:
So to clarify, no, I didn't mean nested XML statements. I meant multiple.


XML GENERATE ...

XML GENERATE ...
Do anything else necessary.

That would get you two pieces of output, which can then have different namespaces, and you can stick them together.

If it is convenient, use three.

Don't get stuck to the idea that the output has to look like your COBOL 01, so your have to use that COBOL 01.


Thanks Bill, we'll try your suggestion and will post it for this example when is working.
Mariana.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts JSON Generate COBOL Programming 2
Search our Forums:

Back to Top