You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2011/02/28 01:50:10 UTC

svn commit: r1075192 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/ solr/example/solr/conf/xslt/ solr/src/java/org/apache/solr/response/ solr/src/solrj/org/apache/solr/client/solrj/util/ solr/src/webapp/web/admin/

Author: uschindler
Date: Mon Feb 28 00:50:09 2011
New Revision: 1075192

URL: http://svn.apache.org/viewvc?rev=1075192&view=rev
Log:
SOLR-2391: Replace remaining occurences of text/xml mime types to application/xml & further cleanups in XSLTResponseWriter

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example.xsl
    lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_atom.xsl
    lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_rss.xsl
    lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/luke.xsl
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/QueryResponseWriter.java
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XMLWriter.java
    lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XSLTResponseWriter.java
    lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.java
    lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/analysis.xsl
    lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/meta.xsl
    lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/ping.xsl
    lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/registry.xsl
    lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/stats.xsl
    lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/tabular.xsl
    lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/threaddump.xsl

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example.xsl Mon Feb 28 00:50:09 2011
@@ -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)')"/>
   

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_atom.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_atom.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_atom.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_atom.xsl Mon Feb 28 00:50:09 2011
@@ -27,7 +27,7 @@
   <xsl:output
        method="xml"
        encoding="utf-8"
-       media-type="text/xml; charset=UTF-8"
+       media-type="application/xml"
   />
 
   <xsl:template match='/'>

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_rss.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_rss.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_rss.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/example_rss.xsl Mon Feb 28 00:50:09 2011
@@ -27,7 +27,7 @@
   <xsl:output
        method="xml"
        encoding="utf-8"
-       media-type="text/xml; charset=UTF-8"
+       media-type="application/xml"
   />
   <xsl:template match='/'>
     <rss version="2.0">

Modified: lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/luke.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/luke.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/luke.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/example/solr/conf/xslt/luke.xsl Mon Feb 28 00:50:09 2011
@@ -28,7 +28,7 @@
     <xsl:output
         method="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"
     />

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/QueryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/QueryResponseWriter.java?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/QueryResponseWriter.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/QueryResponseWriter.java Mon Feb 28 00:50:09 2011
@@ -43,7 +43,7 @@ import org.apache.solr.util.plugin.Named
  * @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";
 

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XMLWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XMLWriter.java?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XMLWriter.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XMLWriter.java Mon Feb 28 00:50:09 2011
@@ -49,8 +49,8 @@ final public class XMLWriter {
   //
   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=(
   "<response xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
@@ -70,7 +70,7 @@ final public class XMLWriter {
     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);
     }
 

Modified: lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XSLTResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XSLTResponseWriter.java?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XSLTResponseWriter.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/java/org/apache/solr/response/XSLTResponseWriter.java Mon Feb 28 00:50:09 2011
@@ -44,7 +44,7 @@ import org.apache.solr.util.xslt.Transfo
  */
 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 implemen
       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 {

Modified: lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.java?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/util/ClientUtils.java Mon Feb 28 00:50:09 2011
@@ -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 ContentStream

Modified: lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/analysis.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/analysis.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/analysis.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/analysis.xsl Mon Feb 28 00:50:09 2011
@@ -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" />
 

Modified: lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/meta.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/meta.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/meta.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/meta.xsl Mon Feb 28 00:50:09 2011
@@ -21,7 +21,7 @@
   <xsl:output
     method="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" />

Modified: lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/ping.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/ping.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/ping.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/ping.xsl Mon Feb 28 00:50:09 2011
@@ -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" />
 

Modified: lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/registry.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/registry.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/registry.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/registry.xsl Mon Feb 28 00:50:09 2011
@@ -26,7 +26,7 @@
   <xsl:output
     method="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" />

Modified: lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/stats.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/stats.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/stats.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/stats.xsl Mon Feb 28 00:50:09 2011
@@ -26,7 +26,7 @@
   <xsl:output
     method="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" />

Modified: lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/tabular.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/tabular.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/tabular.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/tabular.xsl Mon Feb 28 00:50:09 2011
@@ -27,7 +27,7 @@
   <xsl:output
     method="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" />

Modified: lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/threaddump.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/threaddump.xsl?rev=1075192&r1=1075191&r2=1075192&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/threaddump.xsl (original)
+++ lucene/dev/branches/branch_3x/solr/src/webapp/web/admin/threaddump.xsl Mon Feb 28 00:50:09 2011
@@ -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" />