C struct to XML, XML Schema conversion

E

Estevao Rohr

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.
 
R

Rui Maciel

Estevao said:
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
 
R

Rui Maciel

Estevao said:
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
 
M

Malcolm McLean

Estevao Rohr said:
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.
 
S

SM Ryan

# 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.
 
E

Estevao Rohr

EstevaoRohrwrote:



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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top