In my java-xml application, the request( xmlfile.in) and response(xmlfile.out) are xml files.
When I send in an invalid xml request, the xerces parser throws the exception (eg. SAXException) expectedly. This exception message is included inside <ErrorMsg> element that exists in my XML response file(xmlfile.out). But this exception message includes the xml mark up ( special characters) which is causing the response xml to become invalid and not wellformed. But I am required to send back the exception message as much as possible, but still retain the XML response file to be valid and well-formed. ******************** Problem description in detail follows ************************************************************* ----------------- Example request XML file (xmlfile.in)---------------- 1.<?xml version="1.0" encoding="UTF-8"?> 2. <!DOCTYPE ChapterWordSearchRequest SYSTEM "ChapterWordSearchRequest.dtd"> 3. <ChapterWordSearchRequest> 4. <GTeHRequest> 7. <RequestData> 8. <CommodityKeyword>Wool</CommodityKeywo 9. </RequestData> 10. </GTeHRequest> 11. </ChapterWordSearchRequest> -------------------------------------------------------------- Note : In the above xmlfile.in, line number 8 contains incomplete closing tag for <CommodityKeyword> which makes it be not to be a well-formed xml. ---------------- XML response file (xmlfile.out) ----------------- 1.<?xml version="1.0" encoding="UTF-8"?> 2. <!DOCTYPE ChapterWordSearchReply SYSTEM "ChapterWordSearchReply.dtd"> 3. <ChapterWordSearchReply> 4. <GTeHReply> 5. <Error> 6. <ErrorCode>11111</ErrorCode> 7. <ErrorMsg> 8. [ 9. INVALID XML REQUEST: 10. SAXException occured while parsing xml request. 11. Possible Reasons :INVALID XML REQUEST : NON-RECOVERABLE ERROR : 12. Message: The element type "CommodityKeyword" must be terminated by the matching end-tag "</CommodityKeyword> 13 </CommodityKeyword>". 14. Column: 308 15. Line: 1 16. Public ID: null 17. System ID: null 18. ] 19. </ErrorMsg> 20. 21. </Error> 22. </GTeHReply> 23. </ChapterWordSearchReply> ------------------------------------------------------------- Problem : In the above file(xmlfile.out) lines 12 and 13(containing tag </CommodityKeyword> ) cause it not to become a well formed xml. I think the problem is because of the tags(shown below) introduced in the parser's exception message that appears in xmlfile.out is casuing it(xmlfile.out) not to be a well-formed and valid xml document . Message: The element type "CommodityKeyword" must be terminated by the matching end-tag "</CommodityKeyword> </CommodityKeyword>". Hint: If I delete "</CommodityKeyword> </CommodityKeyword>" portion of xmlfile.out, it becomes a well-formed and valid XML I am using xerces 1.4. May I know how to be able to send the exception message in </ErrorMsg> tag and still retain the well-formedness and validity of the xml response(xmlfile.out). Thank you, Andrew FedEx IT Services
BEGIN:VCARD VERSION:2.1 N:Andrew;Anand;K;Systems Programmer FN:Anand K Andrew NICKNAME:Andy ORG:FedEx Services;Distributed Computing Technology TITLE:Systems Programmer TEL;WORK;VOICE:901-263-8565 TEL;HOME;VOICE:901-854-9995 TEL;WORK;FAX:901-263-9971 ADR;WORK:;FedEx Services;10 FedEx Pkwy;Collierville;TN;38017;USA LABEL;WORK;ENCODING=QUOTED-PRINTABLE:FedEx Services=0D=0A10 FedEx Pkwy=0D=0ACollierville, TN 38017=0D=0AUSA ADR;HOME;ENCODING=QUOTED-PRINTABLE:;;999 Melbury Road=0D=0A=0D=0A;Collierville;TN;38017;USA LABEL;HOME;ENCODING=QUOTED-PRINTABLE:999 Melbury Road=0D=0A=0D=0A=0D=0ACollierville, TN 38017=0D=0AUSA EMAIL;PREF;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] REV:20010321T171645Z END:VCARD
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]