/** Return a string that has the result set serialized as XML (not RDF) * <p> * This builds the string in memory which can lead to memory exhaustion * for large results. It is generally better to use the * {@link #outputAsXML(OutputStream, boolean)} overload instead * </p> * * @param booleanResult The boolean result to encode * @return string */ public static String asXMLString(boolean booleanResult) { return asXMLString(booleanResult, null) ; }
/** Return a string that has the result set serialized as XML (not RDF) * <p> * This builds the string in memory which can lead to memory exhaustion * for large results. It is generally better to use the * {@link #outputAsXML(OutputStream, ResultSet)} overload instead * </p> * * @param qresults result set * @return string */ public static String asXMLString(ResultSet qresults) { return asXMLString(qresults, null) ; }
public static String _formatXml(ResultSet rs) { return ResultSetFormatter.asXMLString(rs); }
/** * Converts Jena result set to XML. To make a ResultSet rewindable use: * ResultSetRewindable rsRewind = * ResultSetFactory.makeRewindable(resultSet); * * @param resultSet * The result set to transform, must be rewindable to prevent * errors. * @return String xml */ public static String convertResultSetToXMLString(ResultSetRewindable resultSet) { String retVal = ResultSetFormatter.asXMLString(resultSet); resultSet.reset(); return retVal; }
@Test public void test_RS_1_str() { ResultSetRewindable rs1 = new ResultSetMem() ; String x = ResultSetFormatter.asXMLString(rs1) ; rs1.reset() ; InputStream in = new ByteArrayInputStream(StrUtils.asUTF8bytes(x)); ResultSet rs2 = ResultSetFactory.fromXML(in) ; assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ; }
@Test public void test_RS_2_str() { ResultSetRewindable rs1 = makeRewindable("x", org.apache.jena.graph.NodeFactory.createURI("tag:local")) ; String x = ResultSetFormatter.asXMLString(rs1) ; rs1.reset() ; InputStream in = new ByteArrayInputStream(StrUtils.asUTF8bytes(x)); ResultSet rs2 = ResultSetFactory.fromXML(in) ; assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ; }