Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Any example of XML GENERATE nested statements?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Any example of XML GENERATE nested statements?
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Sep 22, 2015 8:06 pm    Post subject: Reply to: Any example of XML GENERATE nested statements?
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    Post subject: Re: Reply to: Any example of XML GENERATE nested statements?
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Sep 22, 2015 11:33 pm    Post subject: Reply to: Any example of XML GENERATE nested statements?
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Sep 23, 2015 1:59 am    Post subject: Reply to: Any example of XML GENERATE nested statements?
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    Post subject: Re: Reply to: Any example of XML GENERATE nested statements?
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts PLI %IF statements Pedro PL/I & Assembler 1 Tue Sep 19, 2017 12:06 am
No new posts Generate public-private key in batch ... vasanthz All Other Mainframe Topics 3 Fri Sep 15, 2017 9:20 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us