From 40b70f1eb2063b1ce39a0096d2531900a63873a5 Mon Sep 17 00:00:00 2001 From: Conal Tuohy Date: Thu, 25 Jul 2019 12:00:35 +1000 Subject: [PATCH] emit XML decl, BOM, only for first serialized result node --- src/com/conaltuohy/xprocz/XProcZServlet.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/conaltuohy/xprocz/XProcZServlet.java b/src/com/conaltuohy/xprocz/XProcZServlet.java index d25df60..58ccb1b 100644 --- a/src/com/conaltuohy/xprocz/XProcZServlet.java +++ b/src/com/conaltuohy/xprocz/XProcZServlet.java @@ -478,10 +478,15 @@ private void respond(Processor processor, HttpServletResponse resp, XdmNode outp } else { serializer.setOutputProperty(Serializer.Property.METHOD, "text"); } + // Serialize the nodes XdmSequenceIterator content = bodyElement.axisIterator(Axis.CHILD); while (content.hasNext()) { XdmNode contentNode = (XdmNode) content.next(); serializer.serializeNode(contentNode); + // NB since there may be multiple child items (e.g. comments, white space, pi, etc) + // we refrain from emitting these markers after the first child has been serialized + serializer.setOutputProperty(Serializer.Property.BYTE_ORDER_MARK, "no"); + serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes"); } serializer.close(); }