@@ -474,7 +474,7 @@ public void doGet(final DBBroker broker, final Txn transaction, final HttpServle
474474 }
475475 // return a listing of the collection contents
476476 try {
477- writeCollection (response , encoding , broker , collection );
477+ writeCollection (response , encoding , broker , wrap , collection );
478478 return ;
479479 } catch (final LockException le ) {
480480 if (MimeType .XML_TYPE .getName ().equals (mimeType )) {
@@ -2023,14 +2023,15 @@ private void writeXUpdateResult(final HttpServletResponse response,
20232023 * @param response the http response to write the result to
20242024 * @param encoding the character encoding
20252025 * @param broker the database broker
2026+ * @param wrap true if the result should be wrapped in a exist:result element, false otherwise
20262027 * @param collection the collection to write
20272028 *
20282029 * @throws IOException if an I/O error occurs
20292030 * @throws PermissionDeniedException if there are insufficient privildged for the caller
20302031 * @throws LockException if a lock error occurs
20312032 */
20322033 protected void writeCollection (final HttpServletResponse response ,
2033- final String encoding , final DBBroker broker , final Collection collection )
2034+ final String encoding , final DBBroker broker , final boolean wrap , final Collection collection )
20342035 throws IOException , PermissionDeniedException , LockException {
20352036
20362037 response .setContentType (MimeType .XML_TYPE .getName () + "; charset=" + encoding );
@@ -2046,13 +2047,15 @@ protected void writeCollection(final HttpServletResponse response,
20462047 serializer = (SAXSerializer ) SerializerPool .getInstance ().borrowObject (SAXSerializer .class );
20472048
20482049 serializer .setOutput (writer , defaultProperties );
2049- final AttributesImpl attrs = new AttributesImpl ();
20502050
20512051 serializer .startDocument ();
20522052 serializer .startPrefixMapping ("exist" , Namespaces .EXIST_NS );
2053- serializer .startElement (Namespaces .EXIST_NS , "result" ,
2054- "exist:result" , attrs );
20552053
2054+ if (wrap ) {
2055+ serializer .startElement (Namespaces .EXIST_NS , "result" , "exist:result" , null );
2056+ }
2057+
2058+ final AttributesImpl attrs = new AttributesImpl ();
20562059 attrs .addAttribute ("" , "name" , "name" , "CDATA" , collection .getURI ()
20572060 .toString ());
20582061 // add an attribute for the creation date as an xs:dateTime
@@ -2137,7 +2140,10 @@ protected void writeCollection(final HttpServletResponse response,
21372140 }
21382141
21392142 serializer .endElement (Namespaces .EXIST_NS , "collection" , "exist:collection" );
2140- serializer .endElement (Namespaces .EXIST_NS , "result" , "exist:result" );
2143+
2144+ if (wrap ) {
2145+ serializer .endElement (Namespaces .EXIST_NS , "result" , "exist:result" );
2146+ }
21412147
21422148 serializer .endDocument ();
21432149
0 commit comments