Hi Joachim! Thanks for soon response!
Basically I agree with you, changing my schema I will resolve the problem in a easy way, but I was looking for another answer just for education purposes :). So after change my schema and regenerate the code again. I would use xs:sequence just to see what happens. Regarding why I'm translating XML to JSON is beacuse I'm building a n tier web site and I'm using XML document between layers and finally I just convert the answer to JSON to send the response to the client (also the client has the option to receive the response in XML). Thanks again for your help. On Tue, May 20, 2008 at 12:14 AM, Joachim Grüneis <[EMAIL PROTECTED]> wrote: > Hello, > > just to understand your problem correctly... you: > 1) marshal Java objects into XML using Castor > 2) marshal the XML result into JSON > 3) send and receive it somehow > 4) unmarshal from JSON to XML > 5) unmarshal from XML to Java using Castor > so, just 1 & 5 use Castor the rest is some other implementation. > > You had an XSD definition which you used to create the Java classes. > > Now you have the problem that JSON is ignoring element order but in > your XSD definition you used xs:sequence to enforce it... Hmm - why do > you not change the XSD and regenerate the code? Seems to be the > easiest way for your problem. > > Just out of curiosity - why do you convert from XML to JSON? > > 2008/5/19 Gerardo Velez <[EMAIL PROTECTED]>: > > Hi Everybody! > > > > I've been working in a prototype around marshall and unmarshalling to > > generate json documents to send as a response > > in a servlet request, so once I unmarshall the xml file into a java > object I > > just use the json-lib library(json-lib.sourceforge.net/) > > and all works propertly. > > > > So, to test the prototype I developed a client, it request the servlet > and > > receives the json document as a response, then I > > convert the json document into XML, once I did it I just want to > unmarshall > > again to populate my java object. bue I got the following > > error message > > > > > > junit.framework.AssertionFailedError: Error marshalling xml request: > Element > > with name after passed to type MyObject in incorrect order; expected > element > > with name 'before' or any other optional element declared prior to it. > > at > > > edu.jeve.test.http.request.RequestJSONtoXMLTest.convertJSONtoXML(RequestJSONtoXMLTest.java:94) > > at > > > edu.jeve.test.qatool.http.request.RequestJSONtoXMLTest.testJSONResponseToXML(RequestJSONtoXMLTest.java:57) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > at > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > at > > com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > at > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > at > com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) > > > > > > Note: It seems to me that json-lib I'm using just create the json > document > > from my java object passing the fields in alphabetic order > > I mean from A.... to Z and I declare the fields into my schema in the > > following order: before, after > > > > So, basically I just need to change my schema, but is there any other way > to > > avoid this problem without modify the current schema? > > > > > > Thanks in advance! > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > >

