cfgParams.getValue(sCfgPfx+".response.mimeType"));
String sContentDisposition = Val.chkStr(
cfgParams.getValue(sCfgPfx+".response.contentDisposition"));
if ((keys.length > 0) && (sXsltPath.length() > 0)) {
XsltTemplate template = this.getCompiledTemplate(sXsltPath);
ServletOutputStream out = response.getOutputStream();
if (sProperties.length() == 0) {
sProperties = "catalog.cart.*";
}
if (sMimeType.length() == 0) {
sMimeType = "text/plain";
}
response.setContentType(sMimeType+";charset=UTF-8");
if (sContentDisposition.length() > 0) {
response.addHeader("Content-Disposition",sContentDisposition);
}
String nl = "\r\n";
try {
StringBuilder sbXmls = new StringBuilder();
for (String sKey: keys) {
String sXml = Val.chkStr(this.readXml(request,context,sKey));
if (sXml.startsWith("<?xml ")) {
sXml = Val.chkStr(sXml.substring(sXml.indexOf("?>") + 2));
}
if (sXml.length() > 0) {
sbXmls.append(nl).append(sXml);
}
}
if (sbXmls.length() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("<collection>");
// append client properties
sb.append(nl).append("<client");
appendXmlAttribute(sb,"session-id",request.getSession(true).getId());
appendXmlAttribute(sb,"session-rid",request.getRequestedSessionId());
appendXmlAttribute(sb,"remote-ip",request.getRemoteAddr());
appendXmlAttribute(sb,"remote-host",request.getRemoteHost());
appendXmlAttribute(sb,"remote-user",context.getUser().getName());
appendXmlAttribute(sb,"user-agent",request.getHeader("User-Agent"));
sb.append("/>");
// append configuration properties
sb.append(nl).append("<properties>");
this.appendPropertyElement(cfgParams,sb,nl,sProperties);
sb.append(nl).append("</properties>");
// append the XML records
sb.append(nl).append("<records>");
sb.append(sbXmls);
sb.append(nl).append("</records>");
sb.append(nl).append("</collection>");
// transform then return the response
boolean bTransform = true;
if (bTransform) {
String sResult = Val.chkStr(template.transform(sb.toString()));
if (sResult.length() > 0) {
byte[] bytes = sResult.getBytes("UTF-8");
out.write(bytes);
out.flush();
}