• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML message is not created properly

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the .xsd files provided to me, I created XMLBeans using the schema project in weblogic 8.1 sp2. (I am using "xbean.jar" of BEA)

These XMLBeans are used to create a XML document in my Weblogic Integration process. The values in the xml document are retrieved from a database (which cannot administered/viewed by me). XML document was formed perfectly. But recently when I tried running the application again, I found that the xml is not created properly.

When I tried to print the xml message, it displays the xml message with the first letter changed from '<' to '&1t;'.

eg.
<batch_document>
.....
...
</batch_document> is displayed as

&1t;batch_document>
...
..
</batch_document>


What may be the reason behind this change. Is it possible because of some invalid data from the backend? If so, what could be the data?
Is there any special characters which when inserted between the elements makes the document like this?

I would be grateful even if I am answered with any of these questions.

Thanks in advance.
[ March 14, 2006: Message edited by: Elango SV ]
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elango SV:
XML document was formed perfectly. But recently when I tried running the application again, I found that the xml is not created properly.



Well, what has changed? (if anything).
I believe you are seeing '&lt;' not '&1t;' (a lowercase L rather than a �one� ; i.e. the less-than entity).

Because of the special meaning of <, > , and & in XML, these characters cannot be used in the content portion of an XML element. So whenever <, >, & are used in text they need to be replaced by &lt; , &gt; and &amp; respectively.

You may have to encode the strings before your put them into your object representation of the XML document. Fortunately BEA has already provided that functionality in a library method - XMLUtils.encodeXML(String,boolean). That also means that you will have to run XMLUtils.decodeXML(String) on any text coming from the object representation or the XML document.

Alternately one of your development, editing or printing tools may have inadvertently changed the '<' to a '&lt;'.
[ March 14, 2006: Message edited by: Peer Reynders ]
 
Elango Valluvan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your reply.

I very well know that the special characters when used in content portion will be converted to its equivalent entity references.

I think you have misunderstood my question. The change from '<' to '&1t;' is not happening in the data portion (or content portion). It is happening at the element tag (i.e. at <batch_document> tag). Strange...right??

The '<' character in the start element tag is converted to '&1t;' making the whole xml document completely invalid.

I am using weblogic workshop for development. The code that creates the xml document goes like this ...

BatchDocumentDocument bDoc= BatchDocumentDocument.Factory.newInstance();
BatchDocument bd= bDoc.addNewBatchDocument();
...
..

System.out.println(bDoc.toString());

The print statement prints the xml message as

&1t;batch_document> ----> change happens here in the element tag
....
..
</batch_document>

Note: I have used 1 instead of l in the text 'lt;' because the forum displays it as '<'.


[ March 15, 2006: Message edited by: Elango SV ]
[ March 15, 2006: Message edited by: Elango SV ]
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Elango SV:
I think you have misunderstood my question. The change from '<' to '&1t;' is not happening in the data portion (or content portion). It is happening at the element tag (i.e. at <batch_document> tag). Strange...right??



No, I didn't misunderstand. However none of us know the exact logic in that document object. They may allow XML fragments as content that become part of the document upon serialization without further encoding. If that is the case then the serialization logic may get confused if there are <, >, & characters in your normal text content. The text preceding 'batch_document' may contain a '<' which it interprets to be the beginning of an opening tag so the real opening angle bracket is rendered as an '&lt;'
(Still haven't figured out how to get '&lt;' and using '&1t;' instead?)
 
reply
    Bookmark Topic Watch Topic
  • New Topic