+ /**\r
+ * Embeds a Pazpar2 (or Pazpar2 client) error response document as a child element of\r
+ * a command response document (like 'search' or 'show').\r
+ * This is the XML that Pazpar2ResponseParser will turn into a CommandError object.\r
+ * \r
+ * \r
+ * @param commandName The name of the command during which's execution the error was encountered\r
+ * @param exceptionName The (possibly loosely defined) name of the exception that was thrown\r
+ * @param pazpar2ErrorXml The error document as created by Pazpar2, or the Service Proxy or \r
+ * by the Pazpar2 client itself. \r
+ * @return\r
+ */\r
+ public static String insertPazpar2ErrorXml (String commandName, String exceptionName, String pazpar2ErrorXml) {\r
+ StringBuilder errorXml = new StringBuilder("");\r
+ errorXml.append("<" + commandName + ">"+nl);\r
+ errorXml.append(" <applicationerror>"+nl);\r
+ errorXml.append(" <commandname>" + commandName + "</commandname>"+nl);\r
+ errorXml.append(" <exception>" + XmlUtils.escape(exceptionName) + "</exception>"+nl); \r
+ errorXml.append(xmlDeclaration.matcher(pazpar2ErrorXml).replaceAll("")+nl); \r
+ errorXml.append(" </applicationerror>"+nl);\r
+ errorXml.append("</" + commandName + ">"+nl);\r
+ return errorXml.toString(); \r
+ \r
+ }\r
+ \r
+ /**\r
+ * Sets the object that should be used to analyze the error\r
+ * \r
+ */\r