I receive an XML file through Websphere Message Broker, but when I process it with Java it gives me a non formatted file in the output.
the XML input file :
<?xml version="1.0" encoding="UTF-8"?>
<article href="http://www.ensa-agadir.ac.ma/arti234">
<titre>application de web sémantique</titre>
<nombrePages>12</nombrePages>
<auteur rond="principale">
<nom>Hassani</nom>
<prenom>Jamal</prenom>
<etablissement>Ensa-Agadir</etablissement>
</auteur>
</article>
Java compute (for processing message) :
MbMessage outMessage = new MbMessage();
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly, outMessage);
MbElement omroot = outMessage.getRootElement();
MbElement xmlnsc = omroot.createElementAsLastChild ("XMLNSC");
MbElement valueEl = xmlnsc.createElementAsFirstChild(MbElement.TYPE_VALUE, "VALUE",
new String ((byte[])message.getRootElement ().getFirstElementByPath("/BLOB/BLOB").getValue()));
out.propagate(outAssembly);
the XML output file :
like it's not recognizing any utf-8 characters like : quotes or < and > etc... so I think that converting the incoming file to text will solve the problem. But I don't know how to do it, or if it's the best solution.
Do you have any idea about this ? Thank you :)
Edit : the message shouldn't just be escaped, it should be converted and well encoded to the output.