This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Problem with xml , xmlbeans 2.3.0 and outputs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem with xml , xmlbeans 2.3.0 and outputs" Watch "Problem with xml , xmlbeans 2.3.0 and outputs" New topic
Author

Problem with xml , xmlbeans 2.3.0 and outputs

Alex Florentino
Ranch Hand

Joined: Dec 12, 2006
Posts: 48
Hi all,
I am begin work with xml, and I have a problem, I have the xml(Schema) :



and then I use xmlbeans for create the binding, and then I populate my java object, but when I transform the java object for xml format, I have some problem because some xml elements from MessageContent have xml entity for "<", ">".

and this is serious problem, because I need send this xml for third-part company, and them aren't be able handler this xml !

the full sample project(eclipse) can be found at : http://www.alexflorentino.com/help_xml.zip


any suggestion ?

very thanks,

Alex
[ March 13, 2008: Message edited by: Alex Florentino ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Can you tell us how you are doing that? Some code would be useful. And an example of the output you want versus the output you have would be useful too. Asking people to download and install an entire Eclipse project is far too much.

Note that the forum unescapes escaped characters, so you will have to be careful as escaping appears to be part of your problem. Already I doubt that your post says what you wanted to say. If you want a "&" character, you have to type "&amp;" in your post. So if you want to put "&lt;" to distinguish it from "<" then you have to type "&amp;lt;".
[ March 13, 2008: Message edited by: Paul Clapham ]
Alex Florentino
Ranch Hand

Joined: Dec 12, 2006
Posts: 48
ok,

I will try explain better , I need the output :



but I get it :

http://www.alexflorentino.com/Screenshot.png

here my code :

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

So, this part:
<supertag><coisa>onlytest</coisa></supertag>
was the contents of a string variable somewhere in your Java code. But you don't want it to be treated as text (which is what happened there), you want it to be treated as markup.

If you do that I don't think your document will validate against your schema any more, because the <MessageContent> element has the type xs:string. So perhaps you really want your text to be treated as text. Does the document that you produced cause a problem in whatever system you pass it to?
Alex Florentino
Ranch Hand

Joined: Dec 12, 2006
Posts: 48
yes, I already test my xml document and when the content is markup the system is able handler my document, but when is text the third-part system ignore my document.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't know anything about XMLBeans, but if it's generating XML based on the schema you posted, then that's what you're going to get. I could be wrong, but I doubt that you could do anything to affect that.

This really seems like a design failure to me, or at least a bad choice of tools. But if I were stuck with that design and I had to change that element's content from text to markup, I would do it with XSLT. I would start with the identity transform, and then add a template that copied the contents of that element using disable-output-escaping="yes".
Alex Florentino
Ranch Hand

Joined: Dec 12, 2006
Posts: 48
ok thanks,
The xml schema that I used for generate the binding was http://www.opentravel.org/ and the software that I was integrate says be compatible with this standard... but I have this issue, anyway I make ugly quick fix, and now I will take next step this integration.

thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with xml , xmlbeans 2.3.0 and outputs