Hi, the idea of the XPath expression is to select an element/node/ atrtribute which contains all necessary information for the mapping. In case of Bus.PickUpPointOptions you have to select a list of <Option> elements:
public class Bus { public interface BusReader extends XmlReader<Bus> {} public static final BusReader XML = GWT.create(BusReader.class); @XmlField String Type; @XmlField("//Options") List<Option> PickUpPointOptions; @XmlField String Fare; } - Harald On Sep 2, 6:16 am, Deepak Singh <deepaksingh...@gmail.com> wrote: > Hi Harald, > > I am stuck with the problem defined below. can you pls help on that. > > Regards > Deepak > > On Sun, Aug 29, 2010 at 12:25 AM, Deepak Singh > <deepaksingh...@gmail.com>wrote: > > > > > > > > > Hi Harald, > > > While running in development mode, It works fine in IE7 but again gives the > > same exception in chrome. > > Any solution ? > > > Could u pls let me know the concept of writing XPath with XMLfield. i mean > > wat would be XPath for a particular xmlfield according to xml ? > > > As for example : > > > <Buses> > > <Bus> > > <Type>BusType</Type> > > <PickUpPointOptions> > > <Option> > > <Sequence>pickupSequence </Sequence> > > <Desc>pickupPoint</Desc> > > </Option> > > .. > > .. > > </PickUpPointOptions> > > <Fare>fare</Fare> > > </Bus> > > <Bus> > > ----- > > </Bus> > > </Buses> > > For the above xml, I have > > > * > > > public > > **class* Buses { > > > *public* *interface* BusesReader *extends* XmlReader<Buses> {} > > > *public* *static* *final* BusesReader *XML* = GWT.*create*(BusesReader.* > > class*); > > > @XmlField("//Bus") List<Bus> listOfBus; > > > } > > public class Bus { > > > public interface BusReader extends XmlReader<Bus> {} > > public static final BusReader XML = GWT.create(BusReader.class); > > �...@xmlfield String Type; > > �...@xmlfield("//PickUpPointOptions") List<Option> PickUpPointOptions; > > �...@xmlfield String Fare; > > > } > > > public class Option { > > > public interface OptionReader extends XmlReader<Option> {} > > public static final OptionReader XML = GWT.create(OptionReader.class); > > > �...@xmlfield int Sequence; > > �...@xmlfield String Desc; > > } > > > Am i providing the correct XPath at proper places ? > > > Using this, I am able to get the list<Bus> and from this Bus object i get > > List<Option> properly but i am not able to read values from Option class. It > > always gives null for Desc and 0 for Sequence. > > > Pls suggest. > > > Thanks > > Deepak > > > On Sat, Aug 28, 2010 at 12:21 AM, Deepak Singh > > <deepaksingh...@gmail.com>wrote: > > >> Hi Harald, > > >> Thank you very much. > >> It worked fine. I am using piriti in my large project so if in future i > >> get stuck sometime, i will ask again. > > >> Thanks > >> Deepak > > >> On Thu, Aug 26, 2010 at 5:39 PM, Harald Pehl <.p...@googlemail.com>wrote: > > >>> Hi Deepak > > >>> I finally managed to take a closer look to your issues. I created a > >>> playground project with some simple gwt tests. These tests parse the > >>> XML you supplied and map the results to StationDetails and Station > >>> class. > > >>> I found out that your code / mapping annotations needed some minor > >>> adjustments: > >>> public class Station { > >>> ... > >>> �...@xmlfield int id; // lowercase! > >>> �...@xmlfield String name; // lowercase! > >>> } > > >>> public class StationDetails { > >>> ... > >>> �...@xmlfield("//Station") // XPath expression to find all <Station> > >>> elements > >>> List<Station> listOfStations; > >>> } > > >>> Making those changes the tests run successfully. You can find the code > >>> in the SVN repository of Piriti. To test by yourself, please export > >>> the code and start building: > > >>> svn checkouthttp://piriti.googlecode.com/svn/trunk/piriti > >>> cd piriti/core > >>> mvn -DskipTests clean install > >>> cd ../playground > >>> mvn eclipse:eclipse clean install > > >>> - Harald > > >>> On 19 Aug., 21:18, Deepak Singh <deepaksingh...@gmail.com> wrote: > >>> > Hi Harald, > > >>> > Apart from this exception mentioned in last post. i am describing my > >>> > original issue as > > >>> > I have xml as > >>> > <StationDetails> > >>> > <Station> > >>> > <id>12</id> > >>> > <name>asd</name> > >>> > </Station> > >>> > <Station> > >>> > <id>12</id> > >>> > <name>asd</name> > >>> > </Station> > >>> > <Station> > >>> > <id>12</id> > >>> > <name>asd</name> > >>> > </Station> > >>> > ........ > >>> > </StationDetails> > > >>> > Now i am mapping this as follows > > >>> > Station.java > > >>> > public class Station { > >>> > public interface StationReader extends XmlReader<Station> {} > >>> > public static final StationReader XML = > >>> GWT.create(StationReader.class); > >>> > �...@xmlfield int Id; > >>> > @XmlField String Name; > > >>> > } > > >>> > public class StationDetails { > >>> > public interface StationDetailsReader extends > >>> XmlReader<StationDetails> {} > >>> > public static final StationDetailsReader XML = > >>> > GWT.create(StationDetailsReader.class); > >>> > �...@xmlfield List<Station> listOfStations; > > >>> > } > > >>> > Now i am reading this as follows: > > >>> > Document doc = new XmlParser().parse(strResponse); > >>> > List<Station> listOfStations = Station.XML.readList(doc); ---- Error > >>> while > >>> > executing this line > > >>> > and the error is as follows.. > > >>> > 00:50:00.077 [ERROR] [ctshub] Uncaught exception escaped > >>> > name.pehl.totoe.client.XPathException: (Error): TypeError: Object #<an > >>> > Element> has no method 'selectNodes' > >>> > stack: Error: TypeError: Object #<an Element> has no method > >>> 'selectNodes' > >>> > at [object Object].<anonymous> (unknown source) > >>> > at __gwt_jsInvoke ( > >>>http://127.0.0.1:8888/ctshub/hosted.html?ctshub:76:35 > >>> > ) > >>> > at eval at <anonymous> ( > >>>http://127.0.0.1:8888/ctshub/hosted.html?ctshub:54:12) > >>> > at XMLHttpRequest.<anonymous> (unknown source) > >>> > at unknown source > >>> > at __gwt_jsInvoke ( > >>>http://127.0.0.1:8888/ctshub/hosted.html?ctshub:76:35 > >>> > ) > >>> > at eval at <anonymous> ( > >>>http://127.0.0.1:8888/ctshub/hosted.html?ctshub:54:12) > >>> > at XMLHttpRequest.onreadystatechange (unknown source) > >>> > __gwt_ObjectId: 1471 > >>> > at > >>> > name.pehl.totoe.client.internal.NodeImpl.selectNodes(NodeImpl.java:200) > >>> > at > > >>> com.ctshub.bus.client.ticketgoose.StationDetails_StationDetailsReaderImpl.r > >>> eadIds(StationDetails_StationDetailsReaderImpl.java:81) > >>> > at > > >>> com.ctshub.bus.client.ticketgoose.StationDetails_StationDetailsReaderImpl.i > >>> nternalReadList(StationDetails_StationDetailsReaderImpl.java:60) > >>> > at > > >>> com.ctshub.bus.client.ticketgoose.StationDetails_StationDetailsReaderImpl.r > >>> eadList(StationDetails_StationDetailsReaderImpl.java:38) > >>> > at > > >>> com.ctshub.bus.client.ticketgoose.TicketgooseStaticWsCall$1.onResponseRecei > >>> ved(TicketgooseStaticWsCall.java:78) > >>> > at > > >>> com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) > >>> > at > > >>> com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuild > >>> er.java:395) > >>> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > > >>> > I am really frustrated with the error and have wasted two days but no > >>> > luck... > > >>> > Kindly suggest solution or some other way to read the document object. > > >>> > Thanks > >>> > Deepak > > >>> > On Thu, Aug 19, 2010 at 11:36 PM, Deepak Singh < > >>> deepaksingh...@gmail.com>wrote: > > >>> > > Hi Harald, > >>> > > I am using 0.4.1 for piriti and 0.1 for totoe. Still i have the same > >>> issue. > >>> > > When i run it on chrome , i get > > >>> > > Following plugin has crashed .GWT DMP plugin > > >>> > > and on the console > > >>> > > Exception in thread "Code server for ctshub from Mozilla/5.0 > >>> (Windows; U; > >>> > > Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) > >>> > > Chrome/5.0.375.126 Safari/533.4 on > >>> > >http://127.0.0.1:8888/Ctshub.html?gwt.codesvr=127.0.0.1:9997@ > >>> > > x]1_/c_;>6F8"F/q" > >>> com.google.gwt.dev.shell.BrowserChannel$RemoteDeathError: > >>> > > Remote connection lost > >>> > > at > > >>> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChan > >>> nelServer.java:531) > >>> > > at > > >>> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java > >>> :362) > >>> > > at java.lang.Thread.run(Unknown Source) > >>> > > Caused by: java.net.SocketException: Connection reset by peer: socket > >>> write > >>> > > error > >>> > > at java.net.SocketOutputStream.socketWrite0(Native Method) > >>> > > at java.net.SocketOutputStream.socketWrite(Unknown Source) > >>> > > at java.net.SocketOutputStream.write(Unknown Source) > >>> > > at java.io.BufferedOutputStream.flushBuffer(Unknown Source) > >>> > > at java.io.BufferedOutputStream.flush(Unknown Source) > >>> > > at java.io.DataOutputStream.flush(Unknown Source) > >>> > > at > > >>> com.google.gwt.dev.shell.BrowserChannel$ReturnMessage.send(BrowserChannel.j > >>> ava:1310) > >>> > > at > > >>> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChan > >>> nelServer.java:528) > >>> > > ... 2 more > > >>> > > On Thu, Aug 19, 2010 at 3:52 PM, Harald Pehl < > >>> harald.p...@googlemail.com>wrote: > > >>> > >> Could you please update to Piriti 0.4.1 and make sure that you use > >>> the > >>> > >> latest version of Totoe (http://code.google.com/p/totoe/). Even if > >>> you > >>> > >> already use version 0.1, please download again as I there are some > >>> > >> small bugfixes which didn't increase the version number (compare the > >>> > >> file size of your version with the latest download). > > >>> > >> Also check your mapping using Totoes test application. Follow the > >>> > >> documentation underhttp:// > >>> code.google.com/p/totoe/wiki/TestApplication. > > >>> > >> - HTH Harald > > >>> > >> On 19 Aug., 11:41, Deepak Singh <deepaksingh...@gmail.com> wrote: > >>> > >> > Hi Harald, > > >>> > >> > I am using 0.4 version. > >>> > >> > Browser is IE7 and chrome, tested on both > >>> > >> > It happened in development and production bothe modes. > > >>> > >> > Regards > >>> > >> > Deepak > > >>> > >> > On Thu, Aug 19, 2010 at 2:46 PM, Harald Pehl < > >>> > >> harald.p...@googlemail.com>wrote: > > >>> > >> > > Could you please provide more information: > >>> > >> > > - Which version of Piriti are you using? > >>> > >> > > - Which browser > > ... > > read more » -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.