I have a requirement to receive a XML string and convert that to a COBOL structure using Cobol Enterprise. I am using XML PARSE statement, but getting XML-CODE -201 when program reaches a structure with "xsi:type". Part of my input is a string like the example below:
<debito tipo="Unica" xsi:type="Unica">
Does cobol enterprise interpret XML tags with "xsi:type"? What is the XML-EVENT related. I have searched for the topic in Cobol Enterprise Programming Guide, but there is nothing related to this issue.
This topic has been locked.
3 replies Latest Post - 2012-05-10T11:17:59Z by SystemAdmin
Pinned topic XML to Cobol conversion - How to handle xsi:type
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-05-10T11:17:59Z at 2012-05-10T11:17:59Z by SystemAdmin
Re: XML to Cobol conversion - How to handle xsi:type2011-10-11T17:55:13Z in response to SystemAdminWhen I parse the XML you provided, I see the following events from the COBOL XML parser.
|START-OF-DOCUMENT | |<debitos><debito tipo= "Unica"xsi:type= "Unica"><vencimento>2010-03-19</vencimento></debito></debitos> | |START-OF-ELEMENT | |debitos| |START-OF-ELEMENT | |debito| |ATTRIBUTE-NAME | |tipo| |ATTRIBUTE-CHARACTERS | |Unica| |ATTRIBUTE-NAME | |xsi:type| |ATTRIBUTE-CHARACTERS | |Unica| |START-OF-ELEMENT | |vencimento| |CONTENT-CHARACTERS | |2010-03-19| |END-OF-ELEMENT | |vencimento| |END-OF-ELEMENT | |debito| |END-OF-ELEMENT | |debitos| |END-OF-DOCUMENT | ||
The output above was produced from a COBOL program compiled with Enterprise COBOL 3.4.1. No exceptions occurred in the processing of the XML.
I find it helpful to have the following statement in the PROCESSING PROCEDURE of my XML PARSE statement...
DISPLAY '|' XML-EVENT '| |' XML-TEXT '|'
...so I can see what events are being processed when I'm debugging.
When I tried parsing the XML you provided using the same program compiled with Enterprise COBOL 4.2 and the XMLPARSE(XMLSS) option, I received an exception. The return code was XRC_NOT_WELL_FORMED and the reason code was XRSN_NS_ATTR_PREFIX_NOT_DECL.
The documentation for that reason code says...
Namespace prefix on attribute not declared.
Action: Change the document to correct the error and retry.
...I'm afraid I can't help much more than that, I think the parser is complaining about the "xsi:" and that it isn't declared elsewhere in the XML document.
mazogi 0100003E8F30 PostsACCEPTED ANSWER
Re: XML to Cobol conversion - How to handle xsi:type2011-10-11T18:40:02Z in response to SystemAdminFor a namespace-aware parse, the xsi prefix has to be bound to a namespace as in the example from the XSD Primer:
<debitos xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"> ....