View previous topic :: View next topic
|
Author |
Message |
marianambot
New User
Joined: 22 Sep 2015 Posts: 4 Location: United States
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
marianambot
New User
Joined: 22 Sep 2015 Posts: 4 Location: United States
|
|
|
|
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 |
|
|
marianambot
New User
Joined: 22 Sep 2015 Posts: 4 Location: United States
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
marianambot
New User
Joined: 22 Sep 2015 Posts: 4 Location: United States
|
|
|
|
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 |
|
|
|