Hi Jason
I'm trying to feed an application which only takes XML but I only
receive data as protocol buffers.
Would it be possible for you to share the proto-to-xml routine that
you made?
Thanks,

Kartik

On Oct 13, 4:35 pm, Jason Smith <jasonfsmi...@gmail.com> wrote:
> I wrote a genericproto-to-xmlroutine (using TinyXML) that'll convert
> any Message* intoXML.  Thanks to the reflection interface and
> TextFormat, it was pretty straightforward.  (if there's interest in
> seeing it let me know... I'll clear it with my boss and post to this
> forum).
>
> Now I'm trying to do the reverse, and I'm having issues with repeated
> fields that are themselves messages.  When parsing theXMLit finds a
> repeated message, but I can't figure out what method to call in order
> to automagically create a new object of the correct derived Message
> type for this repeated field.  The goal is to call
> Reflection::AddMessage(), then recursively call my XmlToProto()
> routine on this new object, parsing any children in theXMLtree.
>
> I was looking for a method in either the Descriptor or Reflection
> interfaces to allocate a new object of the right Message-derived type
> (obviously it would have to then return it a a Message*, which is
> fine), but didn't see anything.  Can someone point me in the right
> direction?
>
> Thanks in advance,
> -Jason
>
> On Sep 29, 6:06 am, sim <simon.we...@gmail.com> wrote:
>
> > Cool. New syntax I didn't know about!  I think this would be useful
> > for converting the other way around (Proto-to-XML).
>
> > On Sep 28, 6:05 pm, Kenton Varda <ken...@google.com> wrote:
>
> > > Interesting.
>
> > > Another way to do this would be to write code based on protobuf reflection
> > > and custom options, so you could have aprotolike:
> > >   message Foo {
> > >     optional int32 i = 1 [(xml_disposition) = ATTRIBUTE];
> > >     optional Bar bar = 2 [(xml_disposition) = ELEMENT];
> > >   }
>
> > > On Mon, Sep 28, 2009 at 6:14 AM, sim <simon.we...@gmail.com> wrote:
>
> > > > Hi all. Would anybody be interested in anXMLto Protocol Buffers
> > > > converter if it were opened up to the community?  I have anXML
> > > > stylesheet that transforms an annotated XSD set into a Java class that
> > > > uses JAXB and the Protocol Buffers Java API to convertXMLdocuments
> > > > into either text or binary mode Protocol Buffers messages.  The XSD
> > > > annotations define the mappings from XSD elements toProtomessages
> > > > (although at present staying close to a 1:1 mapping is probably
> > > > safest). Some fancy XSD features are not yet supported but the usual
> > > > complexTypes, simpleTypes, elements, and enumerations work.
>
> > > > Simon Weeks

--

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.


Reply via email to