This (way down at the botton) would explain what I'm seeing on output. 

I'm so horribly confused. What I'm trying to do is serialize a Java Bean
into XML, place that serialization inside a string property of another bean,
then serialize the second. The reason it has to be done it two steps is that
the Bean holding the first serialization doesn't know what it's holding.
There are reasons for this design. Rather than justifying it, I'd like to
press on.

Several months ago, the version of xml4j I was using did not do the entity
reference replacement so I changed the text nodes to CDATA nodes. This
worked until I had to run through the serializer twice - as described above.
CDATA nodes can't be nested.

Today I switched to text nodes, and voila, my output was correct (I had
assumed it wouldn't work when I wrote the first message - sorry for not
checking).

Now my problem is on the other side: when I re-create the outer bean, the
inner bean turns into a single '<'. Here's the serialized stream (I added
the whitespace to make it more-or-less readable) and the code that parses it
(stripped of all error handling).

<Batch count="2">
<com.cybercrop.eai.core.QueueItem>
  <properties>
    <payloadProcessor>LOAD</payloadProcessor>
    <payloadBean>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;com.cybercrop.eai.publish.eaiLoad&gt;&lt;
properties&gt;&lt;origState&gt;PA&lt;/origState&gt;&lt;quantity&gt;null&lt;/
quantity&gt;&lt;origCity
&gt;ARNOLD
&lt;/origCity&gt;&lt;weight&gt;null&lt;/weight&gt;&lt;branchPhone&gt;null&lt
;/branchPhone&gt;&lt;destCity&gt;JASPER
&lt;/destCity&gt;&lt;shipperKey&gt;047333&lt;/shipperKey&gt;&lt;action&gt;AD
D&lt;/action&gt;&lt;commodity&gt;null&lt;/commodity&gt;&lt;branchName&gt;nul
l&lt;/branchName&gt;&lt;equipmentCode&gt;F
&lt;/equipmentCode&gt;&lt;destState&gt;AL&lt;/destState&gt;&lt;
rate&gt;null&lt;/rate&gt;&lt;/properties&gt;&lt;/com.cybercrop.eai.publish.e
aiLoad&gt; 
    </payloadBean>
    <payloadID>047333</payloadID>
    <transactionID>0</transactionID>
  </properties>
</com.cybercrop.eai.core.QueueItem>
<com.cybercrop.eai.core.QueueItem>
  <properties>
    <payloadProcessor>LOAD</payloadProcessor>
    <payloadBean>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;com.cybercrop.eai.publish.eaiLoad&gt;&lt;properties&gt;&lt;origState&gt;
&lt;/origState&gt;&lt;quantity&gt;null&lt;/quantity&gt;&lt;origCity&gt;&lt;/
origCity&gt;&lt;weight&gt;null&lt;/weight&gt;&lt;branchPhone&gt;null&lt;/bra
nchPhone&gt;&lt;destCity&gt;&lt;/destCity&gt;&lt;shipperKey&gt;&lt;/shipperK
ey&gt;&lt;action&gt;BE&lt;/action&gt;&lt;commodity&gt;null&lt;/commodity&gt;
&lt;branchName&gt;null&lt;/branchName&gt;&lt;equipmentCode&gt;&lt;
/equipmentCode&gt;&lt;destState&gt;&lt;/destState&gt;&lt;rate&gt;null&lt;/ra
te&gt;&lt;/properties&gt;&lt;/com.cybercrop.eai.publish.eaiLoad&gt; 
    </payloadBean>
    <payloadID></payloadID>
    <transactionID>1</transactionID>
  </properties>
</com.cybercrop.eai.core.QueueItem>
</Batch>

DOMParser parser = new DOMParser();
parser.parse(new org.xml.sax.InputSource(new StringReader(requestXML)));
Document documentEntireBatch = parser.getDocument();
Element elementRoot = documentEntireBatch.getDocumentElement();
NodeList nlReceivedQIs = elementRoot.getElementsByTagName
                                        (QueueItem.class.getName());

for ( int item=0; item < nlReceivedQIs.getLength(); item++ )
{
  Element qiElement = (Element)nlReceivedQIs.item(item);
  qiInElement = (QueueItem)XMLBeanReader.readXMLBean(elementToProcess);
}

qiInElement.payloadBean is a single '<'.

the readXMLBean method checks calls the getData method (and it does check
for text nodes and cast to them - I thought that might help)
      if ( n instanceof Text )
      {
        scalarValue = ((Text) n).getData();
      }

Sorry for being such a pain on my first day on the list. I promise I'll keep
reading and respond when I can be helpful.

- Mark

-----Original Message-----
From: Arnaud Le Hors [mailto:[EMAIL PROTECTED]
Sent: Monday, March 19, 2001 3:51 PM
To: [EMAIL PROTECTED]
Subject: Re: entity reference help, please!


The DOM doesn't have to deal with any of those. This is purely a
serialization issue. Basically the serializer must scan all text nodes
and replace those characters with the relevant character entity
references.
-- 
Arnaud  Le Hors - IBM Cupertino, XML Strategy Group

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to