简体   繁体   中英

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.

在此处输入图像描述

Thanks Yatan

If your input document is literally what you have shown above, you'll need to remove all the whitespace before the xml declaration. The can be nothing before the declaration.

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)*?)\">", "");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM