summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar snowdrop2004-06-02 15:35:04 +0000
committerGravatar snowdrop2004-06-02 15:35:04 +0000
commitcd3a4d82e8e1dddd6470fc564c7d54580912f739 (patch)
treeab06a6c38690f12979f7562e265999a4237558f1
parenta26c02b7222c99a5ebfa87eed5469c467e484e24 (diff)
downloadcsoap-cd3a4d82e8e1dddd6470fc564c7d54580912f739.tar.gz
csoap-cd3a4d82e8e1dddd6470fc564c7d54580912f739.tar.bz2
integrate wsdl2c and xsd2c projects
-rwxr-xr-xwsdl2c/wsdl2c.c63
-rw-r--r--xsd2c/xsd2c.c50
2 files changed, 83 insertions, 30 deletions
diff --git a/wsdl2c/wsdl2c.c b/wsdl2c/wsdl2c.c
index 85daa23..43d0a3c 100755
--- a/wsdl2c/wsdl2c.c
+++ b/wsdl2c/wsdl2c.c
@@ -1,8 +1,9 @@
#include <libxml/xpath.h>
#include <xsd2c/xsd2c.h>
#include <xsd2c/util.h> /* parseNS */
-
-
+#include <xsd2c/formatter.h> /* formatter sax serializer */
+#include <xsd2c/obj.h> /* formatter sax serializer */
+#include <string.h>
xmlXPathObjectPtr xpath_eval(xmlDocPtr doc, const char *xpath)
{
@@ -423,25 +424,58 @@ void wsdlParse(xmlDocPtr doc)
}
+
+static
+void usage(const char* execname);
+
int main(int argc, char *argv[])
{
xmlDocPtr doc;
xmlNodePtr cur;
xmlNodePtr node;
+ xmlNodePtr xsdRoot;
xmlNsPtr default_ns;
+ int i;
+ char outDir[1054];
+ char fname[255];
if (argc < 2) {
- fprintf(stderr, "usage: %s <wsdl file>\n", argv[0]);
+ usage(argv[0]);
return 1;
}
- doc = xmlParseFile(argv[1]);
- if (doc == NULL ) {
- fprintf(stderr,"Document not parsed successfully. \n");
- return 1;
+
+ strcpy(outDir, ".");
+
+ for (i=1;i<argc;i++)
+ {
+ if (!strcmp(argv[i], "-d"))
+ if (i==argc-1) usage(argv[0]);
+ else strcpy(outDir, argv[++i]);
+ else if (!strcmp(argv[i], "-S"))
+ formatter_generate_sax_serializer = 1;
+ else strcpy(fname, argv[i]);
}
+
+ xsdRoot = wsdlLoadFile(fname);
+
+ if (xsdRoot == NULL )
+ {
+ fprintf(stderr,"No Schema data found\n");
+ doc = xmlParseFile(fname);
+ if (doc == NULL)
+ {
+ fprintf(stderr,"Can not parse document\n");
+ return 1;
+ }
+ }
+ else
+ {
+ doc = xsdRoot->doc;
+ }
+
node = xmlDocGetRootElement(doc);
if (node == NULL) {
@@ -458,9 +492,24 @@ int main(int argc, char *argv[])
}
+ if (xsdEngineRun(xsdRoot, outDir)) {
+ fprintf(stderr, "xsd2c engine error\n");
+ return 1;
+ }
+
wsdlParse(doc);
+ trFreeModule();
+ objFreeModule();
+
xmlFreeDoc(doc);
return 0;
}
+
+
+static
+void usage(const char* execname)
+{
+ fprintf(stderr, "usage: %s -d dest <wsdl file>\n", execname);
+} \ No newline at end of file
diff --git a/xsd2c/xsd2c.c b/xsd2c/xsd2c.c
index 37b3497..80660c3 100644
--- a/xsd2c/xsd2c.c
+++ b/xsd2c/xsd2c.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: xsd2c.c,v 1.2 2004/06/02 14:57:23 snowdrop Exp $
+ * $Id: xsd2c.c,v 1.3 2004/06/02 15:35:07 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -628,32 +628,36 @@ int writeSource(HCOMPLEXTYPE ct)
int xsdInitTrModule(xmlNodePtr xsdNode)
{
- xmlNsPtr ns;
-
- ns = xmlSearchNsByHref(xsdNode->doc, xsdNode, "http://www.w3.org/2001/XMLSchema");
- if (ns == NULL) {
- fprintf(stderr, "XML Schema namespace not found!\n");
- return 0;
- }
-
- if (ns->prefix == NULL) {
- fprintf(stderr, "XML Schema namespace not found!\n");
- return 0;
+ xmlNsPtr ns = NULL;
+
+ if (xsdNode != NULL) {
+ ns = xmlSearchNsByHref(xsdNode->doc, xsdNode, "http://www.w3.org/2001/XMLSchema");
+ if (ns == NULL) {
+ fprintf(stderr, "XML Schema namespace not found!\n");
+ return 0;
+ }
+
+ if (ns->prefix == NULL) {
+ fprintf(stderr, "XML Schema namespace not found!\n");
+ return 0;
+ }
+ fprintf(stdout, "XMLSchema namespace prefix: '%s'\n", ns->prefix);
+ trInitModule(ns->prefix);
+ } else {
+ trInitModule("ts");
}
- fprintf(stdout, "XMLSchema namespace prefix: '%s'\n", ns->prefix);
- trInitModule(ns->prefix);
-
return 1;
}
int xsdInitObjModule(xmlNodePtr xsdNode)
{
- xmlChar *tns;
+ xmlChar *tns = NULL;
xmlNsPtr ns;
- tns = xmlGetProp(xsdNode, (const xmlChar*)"targetNamespace");
+ if (xsdNode != NULL)
+ tns = xmlGetProp(xsdNode, (const xmlChar*)"targetNamespace");
if (tns == NULL) {
@@ -695,13 +699,13 @@ int xsdEngineRun(xmlNodePtr xsdNode, const char* destDir)
mkdir(destDir, S_IRUSR|S_IWUSR|S_IXUSR |
S_IRGRP|S_IWGRP|S_IXGRP |
S_IROTH|S_IXOTH );
-
- runGenerator(xsdNode);
- objRegistryEnumComplexType(declareStructs);
- objRegistryEnumComplexType(writeSource);
- trFreeModule();
- objFreeModule();
+ if (xsdNode != NULL) {
+ runGenerator(xsdNode);
+ objRegistryEnumComplexType(declareStructs);
+ objRegistryEnumComplexType(writeSource);
+ }
+
return 0;
}