Menu

#172 Pretty Print not supported in 2.1-beta1

None
closed-fixed
nobody
None
5
2013-02-04
2013-02-01
James Agnew
No

Filing this bug which was submitted by email by Steffan Rachner

I am using the HL7 API 2.1 Beta (from today):

I am using the DefaultXmlParser to encode a Message Object to a XML String.
Doing so will call following method of ca.uhn.hl7v2.util.XMLUtils:

public static String serialize(Document document) {
DOMImplementationLS impl = getDOMImpl();
LSSerializer serializer = impl.createLSSerializer();
// document.normalizeDocument();
DOMConfiguration config = serializer.getDomConfig();
config.setParameter("xml-declaration", true);
config.setParameter("format-pretty-print", true);
LSOutput output = impl.createLSOutput();
output.setEncoding("UTF-8");
Writer writer = new StringWriter();
output.setCharacterStream(writer);
serializer.write(document, output);
return writer.toString();
}

The yellow marked line (config.setParameter("format-pretty-print", true);) will raise a DOMException:
org.w3c.dom.DOMException: FEATURE_NOT_SUPPORTED: The parameter format-pretty-print is recognized but the requested value cannot be set.

Discussion

  • James Agnew

    James Agnew - 2013-02-01

    Will inquire about JDK version in use

     
  • Christian Ohr

    Christian Ohr - 2013-02-01

    Java 6 or Xerces 2.8.0 or newer is required. Sometimes there are more than one XML parser libs in the classpath due to transitive dependencies. Try to get rid of them.

    I will add some checks to XmlUtils to fail fast in case of old parser libs.

     

    Last edit: Christian Ohr 2013-02-01
  • James Agnew

    James Agnew - 2013-02-01

    A bit of research shows that pretty print isn't supported in JDK5. It's easy to check if it's supported though, so will add that. Also adding a config flag to disable pretty printing if desired.

     
  • James Agnew

    James Agnew - 2013-02-01

    Oops.. Hadn't refreshed and missed your comment Christian. :)

     
  • James Agnew

    James Agnew - 2013-02-04
    • status: open --> closed-fixed
    • milestone: -->
     
  • James Agnew

    James Agnew - 2013-02-04

    Closing per Christian's fix

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.