You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/02/21 16:55:44 UTC
svn commit: r510066 -
/lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java
Author: andreas
Date: Wed Feb 21 07:55:43 2007
New Revision: 510066
URL: http://svn.apache.org/viewvc?view=rev&rev=510066
Log:
Fixed DocumentHelper.readDocument(String), added encoding parameter
Modified:
lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java
Modified: lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java?view=diff&rev=510066&r1=510065&r2=510066
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java Wed Feb 21 07:55:43 2007
@@ -18,6 +18,7 @@
package org.apache.lenya.xml;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -151,14 +152,17 @@
* Reads a document from a string.
* @return A document.
* @param string The string to load the document from.
+ * @param encoding The encoding which is used by the string.
* @throws ParserConfigurationException if an error occurs
* @throws SAXException if an error occurs
* @throws IOException if an error occurs
*/
- public static Document readDocument(String string) throws ParserConfigurationException,
+ public static Document readDocument(String string, String encoding) throws ParserConfigurationException,
SAXException, IOException {
DocumentBuilder builder = createBuilder();
- return builder.parse(string);
+ byte bytes[] = string.getBytes(encoding);
+ ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+ return builder.parse(stream);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org