Search code examples
xmlxsltdtdcxml

Parse cXML file


As a response I am getting the below cXML, and its not getting parse if I am using XSLT.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML  SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.046/cXML.dtd">
<cXML payloadID="AF7rzg4Yg6dfzOW5Mfp6PFIAz66C"
      timestamp="2020-06-18T20:26:55+00:00"
      version="1.2.046">
  <Response>
    <Status code="201" text="Acknowledged">Acknowledged</Status>
  </Response>
</cXML>

I am getting below error, can you suggest me how we can parse these kind of files.

Unable to generate the XML document using the provided XML/XSL input. org.xml.sax.SAXParseException; systemId: http://xml.cxml.org/schemas/cXML/1.2.046/cXML.dtd; lineNumber: 1; columnNumber: 1; The markup declarations contained or pointed to by the document type declaration must be well-formed.

My requirement is to get a output XML like

<RESULT>
    <Status>Acknowledged</Status>
</RESULT>

can you let me know the XSLT for that.

enter image description here

Thanks Yatan


Solution

  • I was unable to parse this via XSLT, finally used the below expression before using the XSLT to remove it from XML.

    convertedData = body.replaceAll("<!DOCTYPE((.|\n|\r)*?)\">", "");