serialize with SerialMethod.XML
Hi, I am currently learning how to use BaseX with Java in embedded mode. When I use the following code with SerialMethod.BASEX every thing is fine however if I replace it with SerialMethod.XML I obtain an empty file without any error message. Could you please tell me what I am doing wrong in the second case (with SerialMethod.XML) ? ====================== public static void serialize(String query, String outputFileUri) { try { QueryProcessor processor = new QueryProcessor(query, context); File outputFile = FileProc.newFile(outputFileUri); SerializerOptions so = new SerializerOptions(); so.set(SerializerOptions.ENCODING, "UTF-8"); so.set(SerializerOptions.METHOD, SerialMethod.BASEX); // so.set(SerializerOptions.METHOD, SerialMethod.XML); so.set(SerializerOptions.OMIT_XML_DECLARATION, YesNo.NO); Serializer serializer = Serializer.get(new FileOutputStream(outputFile), so); Item item = processor.iter().next(); serializer.serialize(item); processor.close(); } catch (QueryException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } ====================== BaseX 9.3.3 from github Java 8 Windows 10 Regards -- Jean-François MAUREL PIMECA http://www.pimeca.com
participants (1)
-
jfrm.maurel@gmail.com