Re: how to parse XML documents?
Sayed Hashimi <[email protected]> Sat, 27 Aug 2005 16:12:25 -0400
| Newsgroups | gmane.comp.java.jxta.user |
|---|---|
| Message-ID | <[email protected]> |
Well that would be an important factor. To my knowledge the answer to that is no, but maybe others know better than I do. So what I would suggest in that case is to examine what kind of data you have, can you use something like a properties file? Or do you actually need some of the goodies that come with XML? If so then you should use it. If you're not sure what could happen in the future then you may want to use XML anywayz. But either way if you decide to use XML you'll most likey want to go with some third party tool to do that parsing for Java that can be JAXB, Digerster and I've heard that Castor is good but never used it myself. Not sure what you're options are for C but I'm sure they are not pretty :) But about the edge peers what kind of machines are they running on? Is using the JXTA-Jxme out of the question? Sayed On 8/27/05, John D. Blair <[email protected]> wrote: > That makes a lot of sense. I have one concern: > > The system I am writing in Java is very much a proof-of-concept. I > expect that I will have to write a version (that will have less > functionality, but also a much smaller footprint) in C, using JXTA-C, > to meet some future hardware requirements. See, some peers are "edge > peers" and won't be doing much local processing, while other peers will > be quite sophisticated and will remain implemented in Java. > > So, my question is: will my data be able to interoperate between the C > JXTA implementation and the Java JXTA implementation if I use the > technique you suggest? > > thanks! > -john. > > On Aug 27, 2005, at 12:56 PM, Sayed Hashimi wrote: > > > Hi, > > What I would suggest doing is this: > > Write a class that encapsulates all the data/methods that you need. > > Make sure that all sender/receivers have this class, and also make > > sure that it is serializable. Then when its time to create a message, > > all you need to do is to add and element to the Jxta message, and > > inside of that serialize that object to a byte array. On the receiver > > side you'll need to reconstruct that object from the byte array. This > > has many advantages over the XML technique you described. Because it > > is easier to implement and you send much less data over the wire. And > > the LiteXMLDocument is in the impl package so its could change, you > > don't want to write your code against something tha can change like > > that. You should try to avoid anywayz :) > > Even though the Jxta uses XML messages, you should avoid doing so, you > > simply send too much data over the wire. If you'd like to save these > > documents to an XML file then all you have to do is create a method > > that will handle writing to a file and initalizing from file (or > > stream). To do that I would suggest using either JAXB > > (http://java.sun.com/xml/jaxb/) if you have an XSD that will not > > change and the XML file is complicated. If the file is likely to > > change and pretty simple I'd suggest you to use Digester > > (http://jakarta.apache.org/commons/digester/). > > > > Hope that helps, > > Sayed > > > > On 8/27/05, John D. Blair <[email protected]> wrote: > >> I have been experimenting with JXTA and, while the learning curve has > >> been steep, I am quite impressed. > >> > >> However, I am having trouble working with XML documents. I have > >> created a document structure using the LiteXMLDocument which > >> represents > >> the data I want my peers to communicate with each other. However, I > >> cannot figure out how to parse these documents back into into > >> LiteXMLDocuments. I have been poring over the documentation, and as > >> far as I can tell, there is no facility for doing this. > >> > >> I have explored using the javax.xml.parsers object which comes in the > >> Java library, but there still seems no way to get an XML document back > >> into a LiteXMLDocument. > >> > >> So, to be clear, my question is: > >> Is there an existing way to parse an XML document and use it to > >> populate a LiteXMLDocument (or a DOMXMLDocument)? > >> > >> Am I missing something obvious? Or is this by design? > >> > >> Aside: I realize that it would be possible for me to construct my data > >> structure using JXTA Message objects. However, since the data has a > >> life of its own outside of the JXTA context, I would like to keep the > >> data encapsulated in a single format for its whole lifetime. > >> > >> Please help! Thanks. > >> > >> -john. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >