1

First of all I am using a client-server architecture, android for the client and node.js for the server, they are connected through Socket.io library, so, they are using websockets.

The doubt that I have is that I am generating a XML string with XMLSerializer from Java, I want to encode it to EXI and send it to a server, thus, is it possible doing the encode XML-EXI without using files? directly from string to string? because all examples I see assume that my XML is in a file and I want the output into another file. Another doubt is, can I just send the EXI as string? because I have already established the communication between the client and the server, but they just send strings, I don not if I can sent whole files, in that case, would be any diference on the amount of data sent?

Javi
  • 139
  • 1
  • 2
  • 12
  • 1
    Can't you use any `InputStream` or `OutputStream` descendant? `ByteArrayOutputStream` comes to mind to keep everything in memory. – 323go Jan 30 '13 at 15:20
  • I will try and post here the results – Javi Jan 31 '13 at 09:10
  • care to share what you had to do to get openexi running in android? I'm getting: java.lang.RuntimeException: javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found. – spy Oct 03 '14 at 00:37
  • I ended up refactoring xmlapi, xml resolver, the open exi library and xerces to not use any of the banned javax.xml packages – spy Oct 05 '14 at 22:48

1 Answers1

1

Finally I have solved it, for people with the same problem, the solution is:

String input = methodGivingXMLString();
byte inputBytes[] = input.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(inputBytes);
transmogrifier.encode(new InputSource(in));

For the input, and for the output:

 ByteArrayOutputStream result = new ByteArrayOutputStream();
 transmogrifier.setOutputStream(result);

note 1: I am using OpenExi library

note 2: The output stream has to be set before calling the encode() method.

Javi
  • 139
  • 1
  • 2
  • 12