Hello,
I'm encountering a small problem with my app that I'm hoping someone can clear up for me. I am doing a two-step marshalling procedure to create an XML file. What happens is all < and > characters from the first marshall step are converted to & lt; and & gt; during the second marshall step. (I've added a space after the escape character)
Here's a little preamble and some examples of the steps involved: I'm using JAXB to unmarshall an XML file into a collection of objects - each object is an input txn. I iterate the collection and process the txns.
Here is an example of one of the input txns:
<inputTxn>
<field1>xxx</field1>
<field2>xxx</field2>
...
</inputTxn>
For each unmarshalled txn (object), we marshall it to
string data. This is done to "preserve" the originating txn in the format as received (XML format). This part works fine, the resulting string data looks like the received XML txn above.
We then go on to build a txResult object, and one of the attributes for this object is the originalTxn (the marshalled-txn as string data). We populate the remaining attributes of the txResult object (transaction Ids, error information etc), and then marshall the txResult object.
So, to clarify, txResult contains an atribute called originalTxn which is a String and has a value of "<inputTxn><field1>xxx</field1>...</inputTxn>"
This is what I'm expecting the marshalled txResult object to look like:
<txResult>
<transactionId>12345</transactionId>
<errors>none</errors>
<originalTxn>
<inputTxn>...</inputTxn>
</originalTxn>
</txResult>
But what I get is:
<txResult>
<transactionId>12345</transactionId>
<errors>none</errors>
<originalTxn>
& lt;inputTxn& gt;...& lt;inputTxn& gt;
</originalTxn>
</txResult>
Why are the < and > characters in the originalTxn attribute converted to & gt; and & lt; during the 2nd marshall phase, and what can I do to prevent that from occurring?
Very sorry for possibly asking an extremely stupid question, but I'm not sure what the cause of this is and it's pretty darn frustrating. Thanks for your time and assistance, always much appreciated....
Steve
[ July 19, 2005: Message edited by: Steve Kritzler ]
[ July 19, 2005: Message edited by: Steve Kritzler ]