From 09d5768a1979a70a1069509aa1d55f9db100a285 Mon Sep 17 00:00:00 2001 From: snowdrop Date: Wed, 2 Jun 2004 11:20:48 +0000 Subject: initalial import --- examples/xsd2c/ex1/Makefile | 38 ++++++++++++++++++++++++++++ examples/xsd2c/ex1/README | 40 +++++++++++++++++++++++++++++ examples/xsd2c/ex1/ex1.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ examples/xsd2c/ex1/ex1.xsd | 13 ++++++++++ 4 files changed, 152 insertions(+) create mode 100644 examples/xsd2c/ex1/Makefile create mode 100644 examples/xsd2c/ex1/README create mode 100644 examples/xsd2c/ex1/ex1.c create mode 100644 examples/xsd2c/ex1/ex1.xsd (limited to 'examples/xsd2c/ex1') diff --git a/examples/xsd2c/ex1/Makefile b/examples/xsd2c/ex1/Makefile new file mode 100644 index 0000000..1b09ac4 --- /dev/null +++ b/examples/xsd2c/ex1/Makefile @@ -0,0 +1,38 @@ +######################################################### +# +# XSD2C Examles Makefile +# +######################################################### + +SHELL = bash +CC = gcc + + +VPATH = . ../ + +EXECNAME= ex1.exe +XSDFILE = ex1.xsd +EXSRC = ex1.c utils.c +GENSRC = Person_xsd.c + +EXOBJ = $(addsuffix .o, $(basename $(EXSRC))) +GENOBJ = $(addsuffix .o, $(basename $(GENSRC))) +OBJECTS = $(EXOBJ) $(GENOBJ) +XSD2C = ../../xsd2c + +CFLAGS = `xml2-config --cflags` +CLIBS = `xml2-config --libs` + +$(EXECNAME): stubs $(GENSRC) $(OBJECTS) + $(CC) -g $(CFLAGS) -o $@ $(OBJECTS) $(CLIBS) + + +stubs: + $(XSD2C) -S $(XSDFILE) + +clean: + -@rm -f *.o + -@rm -f *_xsd.h + -@rm -f *_xsd.c + -@rm -f *~ + -@rm -f $(EXECNAME) diff --git a/examples/xsd2c/ex1/README b/examples/xsd2c/ex1/README new file mode 100644 index 0000000..82a6ff9 --- /dev/null +++ b/examples/xsd2c/ex1/README @@ -0,0 +1,40 @@ +################################################## +# +# PROJECT: xsd2c examples +# CREATED: 30.03.2003 +# WRITTEN BY: Ferhat Ayaz +# +################################################## + + +DESCRIPTION: + + This example uses a simple comlexType (Person) + to show you how to: + + + create + + set simple variables + + sax serialize + + free + + a xsd object in c + + +FILES: + + ex1.c : Main program code + ex1.xsd : XML Schema + Makefile : The makefile + README : This file + + + After you make the program with + + $>make + + the following c files will be generated: + + + Person_xsd.h + + Person_xsd.c + + diff --git a/examples/xsd2c/ex1/ex1.c b/examples/xsd2c/ex1/ex1.c new file mode 100644 index 0000000..296155e --- /dev/null +++ b/examples/xsd2c/ex1/ex1.c @@ -0,0 +1,61 @@ +/****************************************************************** + * $Id: ex1.c,v 1.1 2004/06/02 11:20:48 snowdrop Exp $ + * + * CSOAP Project: A SOAP client/server library in C + * Copyright (C) 2003 Ferhat Ayaz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Email: ayaz@jprogrammet.net + ******************************************************************/ + +/* This header will be generated by xsd2c */ +#include "Person_xsd.h" + + /* For stdout writers */ +#include "../utils.h" + + + +int main(int argc, char *argv[]) +{ + struct Person* person; /* object created by xsd2c */ + + /* Create function for Person */ + person = Person_Create(); + + /* Set some entries */ + Person_Set_attr_id(person, "id0001"); + Person_Set_Name(person, "John"); + Person_Set_Lastname(person, "Smith"); + Person_Set_Degree(person, 34); + Person_Add_Project(person, "csoap"); + Person_Add_Project(person, "xsd2c"); + + /* Serialize the Person object. + The 3 sax callback functions + will just print the data to stdout + */ + Person_Sax_Serialize(person, "Employee", + Writer_StartElement, + Writer_Characters, + Writer_EndElement, 0); + + /* Free the Person */ + Person_Free(person); + + return 0; +} diff --git a/examples/xsd2c/ex1/ex1.xsd b/examples/xsd2c/ex1/ex1.xsd new file mode 100644 index 0000000..42ab46f --- /dev/null +++ b/examples/xsd2c/ex1/ex1.xsd @@ -0,0 +1,13 @@ + + + + + + + + + + + + + -- cgit v1.1-32-gdbae