Permalink
Browse files

Fix issue #86, use ByteArray instead of String to convert XdmNodes to…

… InputSources.
  • Loading branch information...
ndw committed Mar 8, 2013
1 parent 563a186 commit 18f91cfaecd78e2677fc430da3dbbae4db8fb8a0
Showing with 6 additions and 11 deletions.
  1. +6 −11 src/com/xmlcalabash/util/S9apiUtils.java
@@ -48,12 +48,13 @@
import net.sf.saxon.event.PipelineConfiguration;
import net.sf.saxon.Configuration;
import com.xmlcalabash.core.XProcRuntime;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Iterator;
import java.util.Vector;
import java.util.HashSet;
import java.net.URI;
import java.io.StringWriter;
import java.io.StringReader;
import net.sf.saxon.tree.util.NamespaceIterator;
import org.xml.sax.InputSource;
@@ -193,17 +194,11 @@ public static boolean xpathEqual(Processor proc, XdmItem a, XdmItem b) {
// FIXME: THIS METHOD IS A GROTESQUE HACK!
public static InputSource xdmToInputSource(XProcRuntime runtime, XdmNode node) throws SaxonApiException {
StringWriter sw = new StringWriter();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Serializer serializer = new Serializer();
serializer.setOutputWriter(sw);
serializer.setOutputStream(out);
serialize(runtime, node, serializer);
String serxml = sw.toString();
StringReader sr = new StringReader(serxml);
InputSource isource = new InputSource(sr);
isource.setSystemId(node.getBaseURI().toASCIIString());
return isource;
return new InputSource(new ByteArrayInputStream(out.toByteArray()));
}
public static HashSet<String> excludeInlinePrefixes(XdmNode node, String prefixList) {

0 comments on commit 18f91cf

Please sign in to comment.