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