Apache Lucene open-source search software
SOLR-2391: Replace remaining occurences of text/xml mime types to application/xml & further cleanups in XSLTResponseWriter
Uwe Schindleraaad623e64f9
diff --git a/solr/example/solr/conf/xslt/example.xsl b/solr/example/solr/conf/xslt/example.xslindex 6832a1d4cb3..b8992700828 100644--- a/solr/example/solr/conf/xslt/example.xsl+++ b/solr/example/solr/conf/xslt/example.xsl@@ -24,7 +24,7 @@xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>- <xsl:output media-type="text/html; charset=UTF-8" encoding="UTF-8"/>+ <xsl:output media-type="text/html" encoding="UTF-8"/><xsl:variable name="title" select="concat('Solr search results (',response/result/@numFound,' documents)')"/>diff --git a/solr/example/solr/conf/xslt/example_atom.xsl b/solr/example/solr/conf/xslt/example_atom.xslindex e1c7d5a2af2..b6c23151dc4 100644--- a/solr/example/solr/conf/xslt/example_atom.xsl+++ b/solr/example/solr/conf/xslt/example_atom.xsl@@ -27,7 +27,7 @@<xsl:outputmethod="xml"encoding="utf-8"- media-type="text/xml; charset=UTF-8"+ media-type="application/xml"/><xsl:template match='/'>diff --git a/solr/example/solr/conf/xslt/example_rss.xsl b/solr/example/solr/conf/xslt/example_rss.xslindex 3e09e654d5f..c1e992e2b19 100644--- a/solr/example/solr/conf/xslt/example_rss.xsl+++ b/solr/example/solr/conf/xslt/example_rss.xsl@@ -27,7 +27,7 @@<xsl:outputmethod="xml"encoding="utf-8"- media-type="text/xml; charset=UTF-8"+ media-type="text/xml"/><xsl:template match='/'><rss version="2.0">diff --git a/solr/example/solr/conf/xslt/luke.xsl b/solr/example/solr/conf/xslt/luke.xslindex 6e9a064d7e0..8553f3c63f7 100644--- a/solr/example/solr/conf/xslt/luke.xsl+++ b/solr/example/solr/conf/xslt/luke.xsl@@ -28,7 +28,7 @@<xsl:outputmethod="html"encoding="UTF-8"- media-type="text/html; charset=UTF-8"+ media-type="text/html"doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>diff --git a/solr/src/java/org/apache/solr/response/QueryResponseWriter.java b/solr/src/java/org/apache/solr/response/QueryResponseWriter.javaindex db500a150e8..eeae6c7c5c1 100644--- a/solr/src/java/org/apache/solr/response/QueryResponseWriter.java+++ b/solr/src/java/org/apache/solr/response/QueryResponseWriter.java@@ -43,7 +43,7 @@ import org.apache.solr.util.plugin.NamedListInitializedPlugin;* @version $Id$*/public interface QueryResponseWriter extends NamedListInitializedPlugin {- public static String CONTENT_TYPE_XML_UTF8="text/xml; charset=UTF-8";+ public static String CONTENT_TYPE_XML_UTF8="application/xml; charset=UTF-8";public static String CONTENT_TYPE_TEXT_UTF8="text/plain; charset=UTF-8";public static String CONTENT_TYPE_TEXT_ASCII="text/plain; charset=US-ASCII";diff --git a/solr/src/java/org/apache/solr/response/XMLWriter.java b/solr/src/java/org/apache/solr/response/XMLWriter.javaindex 062ab413b3f..9a3e17118fd 100644--- a/solr/src/java/org/apache/solr/response/XMLWriter.java+++ b/solr/src/java/org/apache/solr/response/XMLWriter.java@@ -44,8 +44,8 @@ public final class XMLWriter extends TextResponseWriter {private static final char[] XML_START1="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".toCharArray();- private static final char[] XML_STYLESHEET="<?xml-stylesheet type=\"text/xsl\" href=\"/admin/".toCharArray();- private static final char[] XML_STYLESHEET_END=".xsl\"?>\n".toCharArray();+ private static final char[] XML_STYLESHEET="<?xml-stylesheet type=\"text/xsl\" href=\"".toCharArray();+ private static final char[] XML_STYLESHEET_END="\"?>\n".toCharArray();/***private static final char[] XML_START2_SCHEMA=(@@ -89,7 +89,7 @@ public final class XMLWriter extends TextResponseWriter {String stylesheet = req.getParams().get("stylesheet");if (stylesheet != null && stylesheet.length() > 0) {writer.write(XML_STYLESHEET);- writer.write(stylesheet);+ XML.escapeAttributeValue(stylesheet, writer);writer.write(XML_STYLESHEET_END);}diff --git a/solr/src/java/org/apache/solr/response/XSLTResponseWriter.java b/solr/src/java/org/apache/solr/response/XSLTResponseWriter.javaindex 21c62b6aa6a..1164866153d 100644--- a/solr/src/java/org/apache/solr/response/XSLTResponseWriter.java+++ b/solr/src/java/org/apache/solr/response/XSLTResponseWriter.java@@ -44,7 +44,7 @@ import org.apache.solr.util.xslt.TransformerProvider;*/public class XSLTResponseWriter implements QueryResponseWriter {- public static final String DEFAULT_CONTENT_TYPE = "text/xml";+ public static final String DEFAULT_CONTENT_TYPE = "application/xml";public static final String TRANSFORM_PARAM = "tr";public static final String CONTEXT_TRANSFORMER_KEY = "xsltwriter.transformer";@@ -70,14 +70,23 @@ public class XSLTResponseWriter implements QueryResponseWriter {throw new RuntimeException("getTransformer fails in getContentType",e);}- final String mediaTypeFromXslt = t.getOutputProperty("media-type");- if(mediaTypeFromXslt == null || mediaTypeFromXslt.length()==0) {+ String mediaType = t.getOutputProperty("media-type");+ if (mediaType == null || mediaType.length()==0) {// This did not happen in my tests, mediaTypeFromXslt is set to "text/xml"// if the XSLT transform does not contain an xsl:output element. Not sure// if this is standard behavior or if it's just my JVM/libraries- return DEFAULT_CONTENT_TYPE;+ mediaType = DEFAULT_CONTENT_TYPE;}- return mediaTypeFromXslt;++ if (!mediaType.contains("charset")) {+ String encoding = t.getOutputProperty("encoding");+ if (encoding == null || encoding.length()==0) {+ encoding = "UTF-8";+ }+ mediaType = mediaType + "; charset=" + encoding;+ }++ return mediaType;}public void write(Writer writer, SolrQueryRequest request, SolrQueryResponse response) throws IOException {diff --git a/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.java b/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.javaindex 0a5df4397ea..50225340f4a 100644--- a/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.java+++ b/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.java@@ -48,7 +48,7 @@ import org.apache.solr.common.util.*;public class ClientUtils{// Standard Content types- public static final String TEXT_XML = "text/xml; charset=utf-8";+ public static final String TEXT_XML = "application/xml; charset=UTF-8";/*** Take a string and make it an iterable ContentStreamdiff --git a/solr/src/webapp/web/admin/analysis.xsl b/solr/src/webapp/web/admin/analysis.xslindex 518a30d5d7d..78081beba64 100644--- a/solr/src/webapp/web/admin/analysis.xsl+++ b/solr/src/webapp/web/admin/analysis.xsl@@ -26,7 +26,7 @@method="html"indent="yes"encoding="utf-8"- media-type="text/html; charset=UTF-8"+ media-type="text/html"doctype-public="-//W3C//DTD HTML 4.01//EN"doctype-system="http://www.w3.org/TR/html4/strict.dtd" />diff --git a/solr/src/webapp/web/admin/meta.xsl b/solr/src/webapp/web/admin/meta.xslindex 6f6c114bb04..197491b4782 100644--- a/solr/src/webapp/web/admin/meta.xsl+++ b/solr/src/webapp/web/admin/meta.xsl@@ -21,7 +21,7 @@<xsl:outputmethod="html"encoding="utf-8"- media-type="text/html; charset=UTF-8"+ media-type="text/html"indent="yes"doctype-public="-//W3C//DTD HTML 4.01//EN"doctype-system="http://www.w3.org/TR/html4/strict.dtd" />diff --git a/solr/src/webapp/web/admin/registry.xsl b/solr/src/webapp/web/admin/registry.xslindex 7b207c2d927..75cac3857fe 100644--- a/solr/src/webapp/web/admin/registry.xsl+++ b/solr/src/webapp/web/admin/registry.xsl@@ -26,7 +26,7 @@<xsl:outputmethod="html"encoding="utf-8"- media-type="text/html; charset=UTF-8"+ media-type="text/html"indent="yes"doctype-public="-//W3C//DTD HTML 4.01//EN"doctype-system="http://www.w3.org/TR/html4/strict.dtd" />diff --git a/solr/src/webapp/web/admin/stats.xsl b/solr/src/webapp/web/admin/stats.xslindex 7c972168b1c..631b9395d12 100644--- a/solr/src/webapp/web/admin/stats.xsl+++ b/solr/src/webapp/web/admin/stats.xsl@@ -26,7 +26,7 @@<xsl:outputmethod="html"encoding="utf-8"- media-type="text/html; charset=UTF-8"+ media-type="text/html"indent="yes"doctype-public="-//W3C//DTD HTML 4.01//EN"doctype-system="http://www.w3.org/TR/html4/strict.dtd" />diff --git a/solr/src/webapp/web/admin/tabular.xsl b/solr/src/webapp/web/admin/tabular.xslindex a96b0a280f1..1e272cac10d 100644--- a/solr/src/webapp/web/admin/tabular.xsl+++ b/solr/src/webapp/web/admin/tabular.xsl@@ -27,7 +27,7 @@<xsl:outputmethod="html"encoding="utf-8"- media-type="text/html; charset=UTF-8"+ media-type="text/html"indent="yes"doctype-public="-//W3C//DTD HTML 4.01//EN"doctype-system="http://www.w3.org/TR/html4/strict.dtd" />diff --git a/solr/src/webapp/web/admin/threaddump.xsl b/solr/src/webapp/web/admin/threaddump.xslindex 455cc0ece5f..cb8c6bffddb 100644--- a/solr/src/webapp/web/admin/threaddump.xsl+++ b/solr/src/webapp/web/admin/threaddump.xsl@@ -26,7 +26,7 @@method="html"indent="yes"encoding="utf-8"- media-type="text/html; charset=UTF-8"+ media-type="text/html"doctype-public="-//W3C//DTD HTML 4.01//EN"doctype-system="http://www.w3.org/TR/html4/strict.dtd" />