From rjl at third-monday.com Thu Dec 2 12:42:35 2010 From: rjl at third-monday.com (Russ Loucks) Date: Thu Dec 2 14:49:04 2010 Subject: [xsd-users] Retrieving namespace map from parsed docs Message-ID: <4CF7DA8B.9050102@third-monday.com> XSD newbie here. I have a goodly-sized XML schema repository and existing set of data all created with Java and XMLBeans. It looks like XSD will work wonderfully to manage that data store in the C++ program I'm creating. 1st question: Can I retrieve the namespace map from the parsed XML documents? I can create the namespace map as I serialize the objects, but can I retrieve the map from my existing XML documents? thanks, r From boris at codesynthesis.com Thu Dec 2 15:04:15 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 2 14:56:43 2010 Subject: [xsd-users] Retrieving namespace map from parsed docs In-Reply-To: <4CF7DA8B.9050102@third-monday.com> References: <4CF7DA8B.9050102@third-monday.com> Message-ID: Hi Russ, Russ Loucks writes: > 1st question: Can I retrieve the namespace map from the parsed XML > documents? You can, but it will require a bit of work. The namespace-prefix (and namespace-schema) mapping is not preserved in the object model. But it is available in the raw DOM representation. So what you can do is break the parsing process into two stages: XML-to-DOM and DOM-to-object model. In between the two stages you can extract the namespace mapping attributes from the DOM document using the Xerces-C++ API. For code that shows how to set up XML-to-DOM parsing, see, for instance, the 'messaging' example. Boris From rjl at third-monday.com Thu Dec 2 15:00:15 2010 From: rjl at third-monday.com (Russ Loucks) Date: Thu Dec 2 15:00:25 2010 Subject: [xsd-users] Retrieving namespace map from parsed docs In-Reply-To: References: <4CF7DA8B.9050102@third-monday.com> Message-ID: <4CF7FACF.4000609@third-monday.com> On 12/02/2010 02:04 PM, Boris Kolpackov wrote: > Hi Russ, > > Russ Loucks writes: > >> 1st question: Can I retrieve the namespace map from the parsed XML >> documents? > You can, but it will require a bit of work. The namespace-prefix > (and namespace-schema) mapping is not preserved in the object > model. But it is available in the raw DOM representation. So > what you can do is break the parsing process into two stages: > XML-to-DOM and DOM-to-object model. In between the two stages > you can extract the namespace mapping attributes from the DOM > document using the Xerces-C++ API. For code that shows how to > set up XML-to-DOM parsing, see, for instance, the 'messaging' > example. > > Boris Thanks much for the quick response. I'll take a look at that. r From bschindler at inf.ethz.ch Wed Dec 15 07:39:46 2010 From: bschindler at inf.ethz.ch (Benjamin Schindler) Date: Wed Dec 15 07:40:59 2010 Subject: [xsd-users] -Wconversion warnings Message-ID: <4D08B712.1020902@inf.ethz.ch> Hi We just turned on -Wconversion warnings in our xsd-using project and it generated a huge numbers of warnings from libxsd, but they are all at the same place. Could they be fixed please? libxsd/xsd/cxx/tree/date-time-ostream.txx:31:13: warning: conversion to ?short int? from ?int? may alter its value libxsd/xsd/cxx/tree/date-time-ostream.txx:32:13: warning: conversion to ?short int? from ?int? may alter its value libxsd/xsd/cxx/tree/serialization/date-time.txx:42:15: warning: conversion to ?short int? from ?int? may alter its value libxsd/xsd/cxx/tree/serialization/date-time.txx:43:15: warning: conversion to ?short int? from ?int? may alter its value libxsd/xsd/cxx/tree/types.txx:571:11: warning: conversion to ?char? from ?int? may alter its value libxsd/xsd/cxx/tree/types.txx:521:39: warning: conversion to ?unsigned char? from ?int? may alter its value parsing/date-time.txx has quite a few more. I agree that these warnings are very pedantic, but I think a template library should be clean of them as it prevents use of these warning switches in other projects Thanks Benjamin From sbalasub at qualcomm.com Wed Dec 15 12:52:14 2010 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Wed Dec 15 12:53:17 2010 Subject: [xsd-users] -Wconversion warnings In-Reply-To: <4D08B712.1020902@inf.ethz.ch> References: <4D08B712.1020902@inf.ethz.ch> Message-ID: <3D33964996B3DC489449E5E4D791375013FEE617F1@NALASEXMB11.na.qualcomm.com> At the least, the pragmas could be used to hide the issues in CS and let other parts of the code be enabled. ________________________________________ From: xsd-users-bounces@codesynthesis.com [xsd-users-bounces@codesynthesis.com] On Behalf Of Benjamin Schindler [bschindler@inf.ethz.ch] Sent: Wednesday, December 15, 2010 4:39 AM To: xsd-users@codesynthesis.com Subject: [xsd-users] -Wconversion warnings Hi We just turned on -Wconversion warnings in our xsd-using project and it generated a huge numbers of warnings from libxsd, but they are all at the same place. Could they be fixed please? libxsd/xsd/cxx/tree/date-time-ostream.txx:31:13: warning: conversion to ?short int? from ?int? may alter its value libxsd/xsd/cxx/tree/date-time-ostream.txx:32:13: warning: conversion to ?short int? from ?int? may alter its value libxsd/xsd/cxx/tree/serialization/date-time.txx:42:15: warning: conversion to ?short int? from ?int? may alter its value libxsd/xsd/cxx/tree/serialization/date-time.txx:43:15: warning: conversion to ?short int? from ?int? may alter its value libxsd/xsd/cxx/tree/types.txx:571:11: warning: conversion to ?char? from ?int? may alter its value libxsd/xsd/cxx/tree/types.txx:521:39: warning: conversion to ?unsigned char? from ?int? may alter its value parsing/date-time.txx has quite a few more. I agree that these warnings are very pedantic, but I think a template library should be clean of them as it prevents use of these warning switches in other projects Thanks Benjamin From adrien.chauve at gmail.com Wed Dec 15 15:42:38 2010 From: adrien.chauve at gmail.com (Adrien Chauve) Date: Wed Dec 15 15:55:25 2010 Subject: [xsd-users] Error while compiling generated code with clang In-Reply-To: References: Message-ID: Hi again, It seems that clang complains for a good reason. I've just got some really interesting answers from the clang mailing list. Here is the thread: http://comments.gmane.org/gmane.comp.compilers.clang.devel/12137 . In fact, intel compiler also complains when compiling the code in strict mode (-strict-ansi option). Some interesting quotation from the standard [temp.dep]: " In the de?nition of a class or class template, if a base class depends on a template-parameter, the base class scope is not examined during unquali?ed name lookup either at the point of de?nition of the class template or member or during an instantiation of the class template or member" Cheers, Adrien On Tue, Nov 30, 2010 at 18:04, Klaim wrote: > Just for information, the stable 2.8 version is more buggy on the C++ side > than the trunk version (it seems). > > > On Tue, Nov 30, 2010 at 17:58, Boris Kolpackov wrote: > >> Hi Adrien, >> >> Adrien Chauve writes: >> >> > I'm going to ask in clang mailing list. >> >> Great, let us know what they say. >> >> >> > Indeed, I am using clang 2.8. >> >> Ok, I've installed 2.8 and I see the same error. Plus there are more >> cases like this in the C++/Parser mapping. >> >> Boris >> >> > From boris at codesynthesis.com Thu Dec 16 03:50:17 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 16 03:42:06 2010 Subject: [xsd-users] -Wconversion warnings In-Reply-To: <4D08B712.1020902@inf.ethz.ch> References: <4D08B712.1020902@inf.ethz.ch> Message-ID: Hi Benjamin, Benjamin Schindler writes: > We just turned on -Wconversion warnings in our xsd-using project and it > generated a huge numbers of warnings from libxsd, but they are all at > the same place. Could they be fixed please? > > libxsd/xsd/cxx/tree/date-time-ostream.txx:31:13: warning: conversion to > ?short int? from ?int? may alter its value Here is the line that this error points to: h = -h; The 'h' variable is declared as short. I am not sure I would like to "fix" this since it will just make the code uglier and less readable. All other places are very similar. Plus, if you turn -Wsign-conversion, you get a lot more of these warnings. Don't you also get a lot of such warnings from other libraries that you use? For example, I get quite a few from the Xerces-C++ headers. I think the best option, at least for XSD, would be to disable these warnings for the generated/libxsd code, as Balasubramanyam suggested. Unfortunately, GCC does not provide the necessary mechanism until version 4.6 (not yet released; adds #pragma GCC diagnostic push/pop). We can cleanly disable the warnings starting from this version but I am not sure whether this will help you. The only other option that I can think of is to install XSD into a separate directory and use the -isystem option instead of -I to specify the libxsd include directory. This will make GCC treat the libxsd headers as system headers and suppress all the warnings in them. Boris From bschindler at inf.ethz.ch Thu Dec 16 05:57:52 2010 From: bschindler at inf.ethz.ch (Benjamin Schindler) Date: Thu Dec 16 05:59:13 2010 Subject: [xsd-users] -Wconversion warnings In-Reply-To: References: <4D08B712.1020902@inf.ethz.ch> Message-ID: <4D09F0B0.7060101@inf.ethz.ch> Hi Boris Actually, we quickly backed away from enabling this warning as it would be too much work to really make it work. There are some useful cases, but most of them are just noise. So I'd suggest you don't waste too much time on it. The pragma does sound like a good solution though! Cheers Benjamin On 12/16/2010 09:50 AM, Boris Kolpackov wrote: > Hi Benjamin, > > Benjamin Schindler writes: > >> We just turned on -Wconversion warnings in our xsd-using project and it >> generated a huge numbers of warnings from libxsd, but they are all at >> the same place. Could they be fixed please? >> >> libxsd/xsd/cxx/tree/date-time-ostream.txx:31:13: warning: conversion to >> ?short int? from ?int? may alter its value > > Here is the line that this error points to: > > h = -h; > > The 'h' variable is declared as short. I am not sure I would like to > "fix" this since it will just make the code uglier and less readable. > All other places are very similar. Plus, if you turn -Wsign-conversion, > you get a lot more of these warnings. > > Don't you also get a lot of such warnings from other libraries that > you use? For example, I get quite a few from the Xerces-C++ headers. > > I think the best option, at least for XSD, would be to disable these > warnings for the generated/libxsd code, as Balasubramanyam suggested. > Unfortunately, GCC does not provide the necessary mechanism until > version 4.6 (not yet released; adds #pragma GCC diagnostic push/pop). > We can cleanly disable the warnings starting from this version but > I am not sure whether this will help you. > > The only other option that I can think of is to install XSD into > a separate directory and use the -isystem option instead of -I > to specify the libxsd include directory. This will make GCC treat > the libxsd headers as system headers and suppress all the warnings > in them. > > Boris From boris at codesynthesis.com Thu Dec 16 08:33:20 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 16 08:25:09 2010 Subject: [xsd-users] Error while compiling generated code with clang In-Reply-To: References: Message-ID: Hi Adrien, Adrien Chauve writes: > It seems that clang complains for a good reason. I've just got some really > interesting answers from the clang mailing list. Thanks for letting us know. Also, what would be really interesting to know is whether this, IMO strange, restriction is preserved in C++-x0. In any case, the fixes should be fairly straightforward and we will implement them before the next release of XSD (cland-2.8 is still not in the Debian repository and the version I installed from Ubuntu is dysfunctional). Boris From adrien.chauve at gmail.com Thu Dec 16 14:12:38 2010 From: adrien.chauve at gmail.com (Adrien Chauve) Date: Thu Dec 16 14:56:32 2010 Subject: [xsd-users] Error while compiling generated code with clang In-Reply-To: References: Message-ID: Hi Boris, On Thu, Dec 16, 2010 at 14:33, Boris Kolpackov wrote: > > > Thanks for letting us know. Also, what would be really interesting to > know is whether this, IMO strange, restriction is preserved in C++-x0. > I suppose it will be preserved, because the latter quotation is still present in the last draft of C++0x (see paper 27/11/2010, n3225). > > In any case, the fixes should be fairly straightforward Yes :) > and we will > implement them before the next release of XSD (cland-2.8 is still not > in the Debian repository and the version I installed from Ubuntu is > dysfunctional). Ok. I also compiled the trunk version of clang and I didn't got any problem so far (also using v2.8). If you don't have a working clang, another solution would be to compile in strict mode with intel C++ (as it also complains). Adrien From rjl at third-monday.com Tue Dec 28 13:11:06 2010 From: rjl at third-monday.com (Russ Loucks) Date: Tue Dec 28 13:11:15 2010 Subject: [xsd-users] Compile and link errors on Windows Message-ID: <4D1A283A.3030203@third-monday.com> I have a small project that works on Linux (2.6.34), Mac (Snow Leopard) and I'm now porting it to Windows (Vista). Since the project is rather portable, I'm using GNU make to build everything, including the XSD structure (schema to source files, source files to object files, then to dynamic library). I know there's some foo defined in the 'Using XSD with MS VS' (Creating a DLL) online page, but I'm still having problems.... Here's a snapshot of what is happening: The xerces-c library I'm using is the 32-bit version. 1) I create a prolog file with the following text (exports.h): #ifdef XSD_EXPORTS #define XSD_SYMBOL_DECL __declspec(dllexport) #else #define XSD_SYMBOL_DECL __declspec(dllimport) #endif 2) I include the contents of this file into the generated .h files, as follows: C:/Programs/xsd-3.3.0/bin/xsd cxx-tree --generate-serialization \ --show-sloc --generate-polymorphic --output-dir src/xsd --hxx-suffix .h \ --cxx-suffix .cpp --generate-ostream --generate-inline \ --extern-xml-schema xmlSchema.h --hxx-prologue-fi le src/xsd/export.h \ resource.xsd/channelListType.xsd resource.xsd/dataElementType.xsd \ resource.xsd/dataSourceType.xsd \ . . . . I verified the .h files do, indeed, include the contents of that prolog file. However, I'm not sure what symbols need to be defined for compiles... 3) Compile line and warnings: g++ -IC:/Programs/xsd-3.3.0/libxsd -IC:/Programs/xerces-c-3.1.1/include \ -DXSD_EXPORTS -c src/xsd/channelListType.cpp -o build/xsd/channelListType.o In file included from C:/Programs/xerces-c-3.1.1/include/xercesc/validators/datatype/DatatypeValidator.hpp:27, from C:/Programs/xerces-c-3.1.1/include/xercesc/framework/XMLAttr.hpp:28, from C:/Programs/xerces-c-3.1.1/include/xercesc/framework/XMLElementDecl.hpp:25, from C:/Programs/xerces-c-3.1.1/include/xercesc/validators/common/Grammar.hpp:27, from C:/Programs/xerces-c-3.1.1/include/xercesc/dom/DOMLSParser.hpp:29, from C:/Programs/xsd-3.3.0/libxsd/xsd/cxx/xml/dom/parsing-source.txx:7, from C:/Programs/xsd-3.3.0/libxsd/xsd/cxx/xml/dom/parsing-source.hxx:136, from src/xsd/channelListType.cpp:43: C:/Programs/xerces-c-3.1.1/include/xercesc/util/KVStringPair.hpp:178: warning: 'void xercesc_3_1::KVStringPair::setKey(c onst XMLCh*, XMLSize_t)' defined locally after being referenced with dllimport linkage C:/Programs/xerces-c-3.1.1/include/xercesc/util/KVStringPair.hpp:192: warning: 'void xercesc_3_1::KVStringPair::setValue (const XMLCh*, XMLSize_t)' defined locally after being referenced with dllimport linkage 4) Linking all of this (command line and errors): g++ -shared -o lib/libxsd.dll -LC:/Programs/xerces-c-3.1.1/lib -lxerces-c_3 \ build/xsd/channelListType.o build/xsd/dataEl ementType.o \ build/xsd/dataSourceType.o . . . . build/xsd/channelListType.o:channelListType.cpp:(.text$_ZN3xsd3cxx3xml3dom5clearIcEEvRN11xercesc_3_110DOMElementE[void x sd::cxx::xml::dom::clear(xercesc_3_1::DOMElement&)]+0x1a2): undefined reference to `__imp___ZN11xercesc_3_16XMLUni 14fgXMLNSURINameE' build/xsd/channelListType.o:channelListType.cpp:(.text$_ZN3xsd3cxx3xml3dom5clearIcEEvRN11xercesc_3_110DOMElementE[void x sd::cxx::xml::dom::clear(xercesc_3_1::DOMElement&)]+0x1bf): undefined reference to `__imp___ZN11xercesc_3_113Schem aSymbols9fgURI_XSIE' build/xsd/channelListType.o:channelListType.cpp:(.text$_ZN3xsd3cxx3xml3dom5clearIcEEvRN11xercesc_3_110DOMElementE[void x sd::cxx::xml::dom::clear(xercesc_3_1::DOMElement&)]+0x1f6): undefined reference to `__imp___ZN11xercesc_3_113Schem aSymbols21fgXSI_SCHEMALOCACTIONE' . . . . Is this a 32-bit vs. 64 bit issue? Thanks for you help. r -- Russ Loucks From erik.sjolund at gmail.com Thu Dec 30 09:22:04 2010 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Thu Dec 30 09:22:06 2010 Subject: [xsd-users] how to combine --generate-polymorphic with a dynamically loaded plugin? Message-ID: Hi, Is it possible to combine --generate-polymorphic with dynamically loaded plugins? For instance a dynamically loaded plugin could provide a new type of "person" in xsd-3.3.0-i686-linux-gnu/examples/cxx/tree/polymorphism/supermen.xsd If I understand correctly it is advisable not to have any global static objects in a dynamically loaded library, but after running make in the polymorphism example and looking at the generated file supermen.cxx erik@linux: examples/cxx/tree/polymorphism$ grep -m 1 -3 type_serializer_initializer supermen.cxx } static const ::xsd::cxx::tree::type_serializer_initializer< 0, char, person > _xsd_person_type_serializer_init ( "person", ""); there seems to be such a global object. Is this an obstacle for creating a dynamically loaded plugin? cheers, Erik Sj?lund