C struct to XML, XML Schema conversion

Discussion in 'C Programming' started by Estevao Rohr, Jun 30, 2007.

  1. Estevao Rohr

    Estevao Rohr Guest

    Hello,

    I have the following problem: a have a lot of C structs and I'd like
    to:

    - generate a XML Schema from de structs definitions
    - generate a XML with the content of a group os this structs loaded
    with values

    Does anyone know some library which does this?

    Thank you in advance,
    Estevao Rohr.
    Estevao Rohr, Jun 30, 2007
    #1
    1. Advertising

  2. Estevao Rohr

    Rui Maciel Guest

    Estevao Rohr wrote:

    > I have the following problem: a have a lot of C structs and I'd like
    > to:
    >
    > - generate a XML Schema from de structs definitions
    > - generate a XML with the content of a group os this structs loaded
    > with values
    >
    > Does anyone know some library which does this?


    I presume your intention is to write a program which does that at runtime
    from it's data and not parse source code files and extract that information
    directly from them.

    In that case, if you simply want to output the content of your structs
    described through XML and you do need to read that information from any XML
    document then you really don't need any 3rd party library at all. Simply
    output both markup and data to the standard output with the help of
    standard functions like printf and you are good to go.


    Rui Maciel
    Rui Maciel, Jun 30, 2007
    #2
    1. Advertising

  3. Estevao Rohr

    Rui Maciel Guest

    Estevao Rohr wrote:

    > I have the following problem: a have a lot of C structs and I'd like
    > to:
    >
    > - generate a XML Schema from de structs definitions
    > - generate a XML with the content of a group os this structs loaded
    > with values
    >
    > Does anyone know some library which does this?


    I presume your intention is to write a program which does that at runtime
    from it's data and not parse source code files and extract that information
    directly from them.

    In that case, if you simply want to output the content of your structs
    described through XML and you do need to read that information from any XML
    document then you really don't need any 3rd party library at all. Simply
    output both markup and data to the standard output with the help of
    standard functions like printf and you are good to go.


    Rui Maciel
    Rui Maciel, Jun 30, 2007
    #3
  4. "Estevao Rohr" <> wrote in message
    news:...
    > Hello,
    >
    > I have the following problem: a have a lot of C structs and I'd like
    > to:
    >
    > - generate a XML Schema from de structs definitions
    > - generate a XML with the content of a group os this structs loaded
    > with values
    >
    > Does anyone know some library which does this?
    >

    Inherently is is difficult if not impossible to generate a generic

    savestruct(FILE *fp, &mystruct, struct mystructure)

    in C. You might like to think of ways of extending the language to support
    this.

    However saving is normally a lot easier than reading. Simply write a tag
    containing the structure type, then a tag for each field, its contents, and
    a close tag, the close the structure tag.
    If you've got variable-length arrays it is only marginally more difficult.

    --
    Free games and programming goodies.
    http://www.personal.leeds.ac.uk/~bgy1mm
    Malcolm McLean, Jun 30, 2007
    #4
  5. Estevao Rohr

    SM Ryan Guest

    Estevao Rohr <> wrote:
    # Hello,
    #
    # I have the following problem: a have a lot of C structs and I'd like
    # to:
    #
    # - generate a XML Schema from de structs definitions
    # - generate a XML with the content of a group os this structs loaded
    # with values

    Have you tried XML RPC or XML SOAP? They're concerned with turning
    program structures and calls into XML and transmitting to a remote
    execution.

    --
    SM Ryan http://www.rawbw.com/~wyrmwif/
    You hate people.
    But I love gatherings. Isn't it ironic.
    SM Ryan, Jul 1, 2007
    #5
  6. Estevao Rohr

    Estevao Rohr Guest

    On Jun 30, 5:35 am, Rui Maciel <> wrote:
    > EstevaoRohrwrote:
    > > I have the following problem: a have a lot of C structs and I'd like
    > > to:

    >
    > > - generate a XML Schema from de structs definitions
    > > - generate a XML with the content of a group os this structs loaded
    > > with values

    >
    > > Does anyone know some library which does this?

    >
    > I presume your intention is to write a program which does that at runtime
    > from it's data and not parse source code files and extract that information
    > directly from them.
    >


    Actually, in the first item (XML Schema), either way is fine, parsing
    source code files or at runtime.

    Thanks to all that answered,
    Estevao Rohr.
    Estevao Rohr, Jul 2, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,528
    Markus
    Nov 23, 2005
  2. Hari Om
    Replies:
    1
    Views:
    461
    Martin SChukrazy
    Mar 2, 2004
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,248
    Stanimir Stamenkov
    Apr 25, 2005
  4. Chris Fogelklou
    Replies:
    36
    Views:
    1,372
    Chris Fogelklou
    Apr 20, 2004
  5. Replies:
    3
    Views:
    2,831
Loading...

Share This Page