diff --git a/compiler2/makefile.c b/compiler2/makefile.c index 3a4358af0a651a420b1bfae15304db6f487ee3fd..3b2c510d244db33676c7122c765cae39c7be5258 100644 --- a/compiler2/makefile.c +++ b/compiler2/makefile.c @@ -4556,7 +4556,7 @@ static void generate_makefile(size_t n_arguments, char *arguments[], if (makefile.ets_name == NULL) makefile.ets_name = mcopystr(makefile.ASN1Modules[0].module_name); } else if (makefile.nXSDModules >= 1) { - WARNING("No TTCN-3 or ASN.1 or XSD module was given for the Makefile."); + WARNING("No TTCN-3 or ASN.1 was given for the Makefile."); if (makefile.ets_name == NULL) makefile.ets_name = mcopystr(makefile.XSDModules[0].module_name); } else if (makefile.nUserFiles > 0) { diff --git a/usrguide/referenceguide.doc b/usrguide/referenceguide.doc index 51752b91fb522c85e489a9c3321629659ffde80c..034462f3ca0ea6aa904a5b2c53084a98ad7ab030 100644 Binary files a/usrguide/referenceguide.doc and b/usrguide/referenceguide.doc differ diff --git a/xsdconvert/XMLParser.cc b/xsdconvert/XMLParser.cc index eefab2090447d0688000b91806f4789184b3767a..9544034054c818d15f145f21ad9aff4991020b7c 100644 --- a/xsdconvert/XMLParser.cc +++ b/xsdconvert/XMLParser.cc @@ -34,6 +34,7 @@ #define LLONG_MAX 9223372036854775807LL #endif +extern bool n_flag_used; extern bool V_flag_used; extern bool w_flag_used; extern bool x_flag_used; @@ -63,6 +64,9 @@ XMLParser::XMLParser(const char * a_filename) parserCheckingXML->initialized = XML_SAX2_MAGIC; parserCheckingXML->warning = warningHandler; parserCheckingXML->error = errorHandler; + if (n_flag_used) { + parserCheckingXML->startElementNs = (startElementNsSAX2Func) wrapper_to_call_startelement_when_xsd_read_h; + } contextCheckingXML = xmlCreateFileParserCtxt(a_filename); if (!contextCheckingXML) { fprintf(stderr, @@ -72,6 +76,9 @@ XMLParser::XMLParser(const char * a_filename) return; } contextCheckingXML->sax = parserCheckingXML; + if (n_flag_used) { + contextCheckingXML->userData = this; + } if (!x_flag_used) { contextCheckingXSD = xmlSchemaNewParserCtxt(a_filename); @@ -127,7 +134,7 @@ void XMLParser::checkSyntax() { } void XMLParser::validate() { - if (!x_flag_used) { + if (!x_flag_used && !n_flag_used) { xmlSchemaPtr schema = xmlSchemaParse(contextCheckingXSD); if (schema) { xmlSchemaValidCtxtPtr validator = xmlSchemaNewValidCtxt(schema); @@ -171,6 +178,11 @@ void XMLParser::wrapper_to_call_characterdata_h(XMLParser *self, const xmlChar * self->characterdataHandler(ch, len); } +void XMLParser::wrapper_to_call_startelement_when_xsd_read_h(XMLParser *self, const xmlChar * localname, const xmlChar *, const xmlChar *, + int nb_namespaces, const xmlChar ** namespaces, const int nb_attributes, int, const xmlChar ** attributes) { + self->startelementHandlerWhenXSDRead(localname, nb_namespaces, namespaces, nb_attributes, attributes); +} + void XMLParser::warningHandler(void *, const char *, ...) { if (w_flag_used) { return; @@ -260,6 +272,10 @@ void XMLParser::startelementHandler(const xmlChar * localname, module->loadValuesFromSchemaTag(actualTagAttributes.targetNamespace, declaredNamespaces, actualTagAttributes.elementFormDefault, actualTagAttributes.attributeFormDefault, actualTagAttributes.blockDefault); + // Only need the targetNamespace. Stop. + if (n_flag_used) { + xmlStopParser(context); + } break; } default: @@ -333,6 +349,14 @@ void XMLParser::startelementHandler(const xmlChar * localname, } } +void XMLParser::startelementHandlerWhenXSDRead(const xmlChar * localname, + int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, const xmlChar ** attributes) { + if (strcmp((const char*)localname, "schema") == 0) { + // Don't parse beyond the schema tag. + xmlStopParser(contextCheckingXML); + } +} + void XMLParser::endelementHandler(const xmlChar * localname) { fillUpActualTagName((const char *) localname, endElement); @@ -480,11 +504,6 @@ void XMLParser::fillUpActualTagName(const char * localname, const tagMode mode) } } else if (name_s == "fractionDigits") { actualTagName = n_fractionDigits; - if (mode == startElement) { - printWarning(filename, xmlSAX2GetLineNumber(context), - Mstring("The 'fractionDigits' tag is currently not supported.")); - ++num_warnings; - } } else if (name_s == "group") actualTagName = n_group; else if (name_s == "import") diff --git a/xsdconvert/XMLParser.hh b/xsdconvert/XMLParser.hh index fa7f4887d029a5840bfb709b951a5da732f26e47..1c7a331935b9ec4c25b938734ba68c595fbe7784 100644 --- a/xsdconvert/XMLParser.hh +++ b/xsdconvert/XMLParser.hh @@ -192,12 +192,16 @@ private: void endelementHandler(const xmlChar * localname); void characterdataHandler(const xmlChar * text, const int length); void commentHandler(const xmlChar * text); + void startelementHandlerWhenXSDRead(const xmlChar * localname, const int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, const xmlChar ** attributes); /** Callbacks cannot be member functions, use these static members as wrappers */ static void wrapper_to_call_startelement_h(XMLParser *self, const xmlChar * localname, const xmlChar * prefix, const xmlChar * URI, int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, int nb_defaulted, const xmlChar ** attributes); static void wrapper_to_call_endelement_h(XMLParser *self, const xmlChar * localname, const xmlChar * prefix, const xmlChar * URI); static void wrapper_to_call_characterdata_h(XMLParser *self, const xmlChar * ch, int len); static void wrapper_to_call_comment_h(XMLParser *self, const xmlChar * value); + + /** Callback for start element handler when we read the namespace of the xsd files only, */ + static void wrapper_to_call_startelement_when_xsd_read_h(XMLParser *self, const xmlChar * localname, const xmlChar * prefix, const xmlChar * URI, int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, int nb_defaulted, const xmlChar ** attributes); static void warningHandler(void * ctx, const char * msg, ...); static void errorHandler(void * ctx, const char * msg, ...);