From cd3a4d82e8e1dddd6470fc564c7d54580912f739 Mon Sep 17 00:00:00 2001 From: snowdrop Date: Wed, 2 Jun 2004 15:35:04 +0000 Subject: integrate wsdl2c and xsd2c projects --- xsd2c/xsd2c.c | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'xsd2c') 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; } -- cgit v1.1-32-gdbae