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 2012/07/07 22:55:08 UTC
svn commit: r1358638 -
/lucene/dev/branches/lucene4199/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java
Author: uschindler
Date: Sat Jul 7 20:55:08 2012
New Revision: 1358638
URL: http://svn.apache.org/viewvc?rev=1358638&view=rev
Log:
LUCENE-4199: Fix XML QueryParser XML handling (don't use ByteArrayOutputStream). But it should still suppress xml header with encoding when transformed to string... (TODO)
Modified:
lucene/dev/branches/lucene4199/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java
Modified: lucene/dev/branches/lucene4199/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4199/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java?rev=1358638&r1=1358637&r2=1358638&view=diff
==============================================================================
--- lucene/dev/branches/lucene4199/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java (original)
+++ lucene/dev/branches/lucene4199/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java Sat Jul 7 20:55:08 2012
@@ -11,7 +11,7 @@ import javax.xml.transform.*;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
@@ -98,10 +98,11 @@ public class QueryTemplateManager {
*/
public static String getQueryAsXmlString(Properties formProperties, Templates template)
throws ParserConfigurationException, TransformerException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- StreamResult result = new StreamResult(baos);
+ // TODO: Suppress XML header with encoding (as Strings have no encoding)
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
transformCriteria(formProperties, template, result);
- return baos.toString();
+ return writer.toString();
}
/**
@@ -109,10 +110,11 @@ public class QueryTemplateManager {
*/
public static String getQueryAsXmlString(Properties formProperties, InputStream xslIs)
throws SAXException, IOException, ParserConfigurationException, TransformerException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- StreamResult result = new StreamResult(baos);
+ // TODO: Suppress XML header with encoding (as Strings have no encoding)
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
transformCriteria(formProperties, xslIs, result);
- return baos.toString();
+ return writer.toString();
}