From boris at codesynthesis.com Thu Jul 1 06:11:06 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 1 04:00:13 2010 Subject: [xsd-users] problem with polymorphic dynamic cast In-Reply-To: <315123AEEA98E94CA171FF059C0A80BC0AF63C7E@dhnl001ex001.intra.local> References: <315123AEEA98E94CA171FF059C0A80BC0AF63C7E@dhnl001ex001.intra.local> Message-ID: Hi John, Dingelstad, John writes: > I'll used the option -generetate-polymorphic along with version 3.3. The DATEXII schema uses xsi:type to specify dynamic types. When you use the --generate-polymorphic option, the XSD compiler will auto- detect types that are used in substitution groups and treat them as polymorphic. However, if the vocabulary uses the xsi:type approach, the XSD compiler has no way of knowing which types are potentially polymorphic. There are two ways to resolve this. You can explicitly specify the bases of polymorphic type hierarchies with the --polymorphic-type option. Alternatively, you can specify that all types should be treated as polymorphic with the --polymorphic-type-all option. The former approach is preferable since it results in smaller and faster generated code. For more information on this see Section 2.11, "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11 For the DATEXII schema, it appears that the polymorphic type hierarchies start with abstract types (types that have abstract="true" attribute). To make your example work using the former approach I added the following options to the XSD command line: --polymorphic-type PayloadPublication --polymorphic-type Location --polymorphic-type AlertCPoint I also tried the --polymorphic-type-all options and it works fine as well. If you are going to use the --polymorphic-type approach, then it may be tidier to place the options in a file and then use the --options-file option to include them into the command line (see the XSD Compiler Command Line Manual for details). Boris From gahr at gahr.ch Thu Jul 1 02:52:10 2010 From: gahr at gahr.ch (Pietro Cerutti) Date: Thu Jul 1 04:00:30 2010 Subject: [xsd-users] build problem In-Reply-To: References: <20100628102357.GN50859@gahrfit.gahr.ch> Message-ID: <20100701065210.GC15928@gahrfit.gahr.ch> On 2010-Jun-28, 18:24, Boris Kolpackov wrote: > Hi Pietro, Hi Boris, > Pietro Cerutti writes: > > > I'm porting xsdcxx (and all its dependent packages) to FreeBSD, and have > > this error while building the examples. > > The driver.cxx file in the XPath example will only work with Xerces-C++ > 3-series. If you want to use Xerces-C++ 2-series, you will need to > replace it with the driver-2.cxx file that can be found in the same > directory. > > You also need the XQilla library to build this example. Ok great. I have xqilla-2.2.0 installed. driver-2.cxx gives the following error: /usr/home/gahr/FreeBSD/ports/devel/xsdcxx/work/xsd-3.3.0/examples/cxx/tree/xpath/driver-2.cxx:104: error: 'class XPath2Result' has no member named 'asNode' > > I have tried with xerces-c 2.7, 2.8 and 3.1.1. > > What kind of errors do you get with 3.1.1? Also, which version of > XQilla are you using with this version of Xerces-C++? I've solved the problem of 3.1.1 by upgrading xqilla to 2.2.4, thanks! > > Boris -- Pietro Cerutti gahr@gahr.ch PGP Public Key: http://gahr.ch/pgp -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20100701/01bf3415/attachment.pgp From boris at codesynthesis.com Thu Jul 1 06:27:51 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 1 04:16:54 2010 Subject: [xsd-users] Problem in translating schema to C++ (following parser guide) In-Reply-To: <4C2B5151.6050002@sapo.pt> References: <4C2B5151.6050002@sapo.pt> Message-ID: Hi Pedro, Pedro writes: > I'm not using the tree mapping because i need support for large xml files. It is possible to use C++/Tree with large files (i.e., those that won't fit into memory) with a bit of extra work. For larger schemas it may still be easier than C++/Parser. For more information on this see the 'streaming' example in the examples/cxx/tree/ directory of the XSD distribution (only available in XSD 3.3.0 or later). > When i type "xsd" on the console, this is the result: > > xsd.exe - a utility for generating schema or class files This is Mono's xsd.exe utility. If you are using the XSD package from the Debian/Ubuntu/Fedora/etc repository, then the compiler name is xsdcxx. > ... but when I enter the command "xsdcxx cxx-parser --xml-parser > expat hello.xsd" it returns "terminate called after throwing an instance > of 'std::length_error' what(): basic_string::resize". Hm, that's odd. I assume hello.xsd is the unmodified schema from the guide, right? I just tried the following on my Debian box: 1. Install xsdcxx 3.2.0.1-1.1+b3 from the Debian testing repository. 2. Copy and paste the schema from Section 2.1 of the online guide to hello.xsd 3. Run xsdcxx cxx-parser --xml-parser expat hello.xsd And everything works without any problems. > I have reinstalled xsdcxx, I have updated everything, reinstalled > xsd-3.3.0 from your website but I'm stuck at this point. Do you get the same error with xsd-3.3.0? Can you send me the hello.xsd schema that you are trying to compile? Boris From boris at codesynthesis.com Thu Jul 1 06:30:56 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 1 04:19:59 2010 Subject: [xsd-users] build problem In-Reply-To: <20100701065210.GC15928@gahrfit.gahr.ch> References: <20100628102357.GN50859@gahrfit.gahr.ch> <20100701065210.GC15928@gahrfit.gahr.ch> Message-ID: Hi Pietro, Pietro Cerutti writes: > Ok great. I have xqilla-2.2.0 installed. driver-2.cxx gives the > following error: > > /usr/home/gahr/FreeBSD/ports/devel/xsdcxx/work/xsd-3.3.0/examples/cxx/tree/xpath/driver-2.cxx:104: > error: 'class XPath2Result' has no member named 'asNode' Is it with Xerces-C++ 2.7.0? I believe the XQilla project only supports 2.8.0 for the Xerces-C++ 2-series. We also only tested Xerces-C++ 2.8.0 with the latest version of XQilla. Boris From boris at codesynthesis.com Thu Jul 1 06:35:15 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 1 04:24:20 2010 Subject: [xsd-users] Polymorphic type as root element In-Reply-To: <4C2B3BF5.2030403@inf.ethz.ch> References: <4C29DF06.6010606@inf.ethz.ch> <4C2B3BF5.2030403@inf.ethz.ch> Message-ID: Hi Benjamin, Benjamin Schindler writes: > I tried the following too, but to no avail: Does it fail in the same way as before or the error is different now? Perhaps the validation is enabled (default) and the schema cannot be found (see Q 2.1 in http://wiki.codesynthesis.com/Tree/FAQ)? > Sorry for not mentioning: EnsightReaderSettings_t is a type which > extends BaseSettings, and parseBaseSettings is therefore the parser > function to parse any BaseSettings type and should return a > EnsightReaderSettings object (in form of a BaseSettings > reference/pointer of course) I don't see why this won't work then. I will need a test case that reproduces the problem. Boris From gahr at gahr.ch Thu Jul 1 04:21:35 2010 From: gahr at gahr.ch (Pietro Cerutti) Date: Thu Jul 1 10:14:39 2010 Subject: [xsd-users] build problem In-Reply-To: References: <20100628102357.GN50859@gahrfit.gahr.ch> <20100701065210.GC15928@gahrfit.gahr.ch> Message-ID: <20100701082135.GD15928@gahrfit.gahr.ch> On 2010-Jul-01, 12:30, Boris Kolpackov wrote: > Hi Pietro, > > Pietro Cerutti writes: > > > Ok great. I have xqilla-2.2.0 installed. driver-2.cxx gives the > > following error: > > > > /usr/home/gahr/FreeBSD/ports/devel/xsdcxx/work/xsd-3.3.0/examples/cxx/tree/xpath/driver-2.cxx:104: > > error: 'class XPath2Result' has no member named 'asNode' > > Is it with Xerces-C++ 2.7.0? I believe the XQilla project only > supports 2.8.0 for the Xerces-C++ 2-series. We also only tested > Xerces-C++ 2.8.0 with the latest version of XQilla. Yes, this was with xerces-x 2.7.x. 2.8 solved the problem. Maybe you can update the CodySynthesis page where you list the requirements of each package, and change xerces' dependency from >= 2.6.0 to >= 2.8.0? Thanks a lot! -- Pietro Cerutti gahr@gahr.ch PGP Public Key: http://gahr.ch/pgp -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20100701/f8ac496b/attachment.pgp From boris at codesynthesis.com Thu Jul 1 12:30:20 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 1 10:19:24 2010 Subject: [xsd-users] build problem In-Reply-To: <20100701082135.GD15928@gahrfit.gahr.ch> References: <20100628102357.GN50859@gahrfit.gahr.ch> <20100701065210.GC15928@gahrfit.gahr.ch> <20100701082135.GD15928@gahrfit.gahr.ch> Message-ID: Hi Pietro, Pietro Cerutti writes: > Maybe you can update the CodySynthesis page where you list the > requirements of each package, and change xerces' dependency > from >= 2.6.0 to >= 2.8.0? Thanks for the suggestion. The problem with making this change is that the XPath support is an optional component. The core functionality of XSD is working with older versions of Xerces-C++. The good news is that in the next version of XSD (4.0.0) we are dropping support for Xerces-C++ 2-series. So this will become a non-issue. Boris From boris at codesynthesis.com Thu Jul 1 12:51:37 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 1 10:40:41 2010 Subject: [xsd-users] Problem in translating schema to C++ (following parser guide) In-Reply-To: <4C2C5F89.3010500@sapo.pt> References: <4C2B5151.6050002@sapo.pt> <4C2C5F89.3010500@sapo.pt> Message-ID: <20100701165137.GA23159@tpad> Hi Pedro, In the future please keep your replies CC'ed to the xsd-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Pedro writes: > Hmm, I've tryed following that guide too, but I'm stuck at the "xsdcxx > cxx-tree hello.xsd". Same error. I have XSD 3.3.0. Are you using xsdcxx Debian/Ubuntu package or are you using the xsd package downloaded from the codesynthesis.com website? Can you try to download the .tar.bz2 package and see if the 'xsd' binary in the bin/ subdirectory works for you? The error makes me think that there is some conflict between the g++ version (or, more precisely, libstdc++) that was used to build xsdcxx and the version that you have installed on your box. You may want to try to upgrade or downgrade libstdc++6 package and see if this helps. > I've installed xsd3.3.0 in Windows XP, and extracted the .cxx and > .hxx files with "xsd cxx-parser --xml-parser expat hello.xsd" but > I'm not sure those files can be used in windows and linux. Yes, the files are the same on all platforms. Just make sure you have the same version of XSD on both platforms (that is, using 3.3.0 on Windows and 3.2.0 on Linux won't work). > Also, when i compile hello.xml with xsd, the result is a bit different > from the hello.xsd that the example shows: > > [...] > > and it gives me a few errors when I try to compile in windows xsd.exe. This schema is invalid. Since it was generated with Mono's xsd.exe, I am afraid I can't help you with that. You may want to contact the Mono developers to report this problem. Generally, thought, schemas that are auto-generated from a sample XML document are quite inaccurate. They usually require a lot of manual editing to make them usable. Boris From gahr at gahr.ch Thu Jul 1 10:22:02 2010 From: gahr at gahr.ch (Pietro Cerutti) Date: Thu Jul 1 10:40:53 2010 Subject: [xsd-users] build problem In-Reply-To: References: <20100628102357.GN50859@gahrfit.gahr.ch> <20100701065210.GC15928@gahrfit.gahr.ch> <20100701082135.GD15928@gahrfit.gahr.ch> Message-ID: <20100701142202.GA23751@gahrfit.gahr.ch> On 2010-Jul-01, 18:30, Boris Kolpackov wrote: > Hi Pietro, > > Pietro Cerutti writes: > > > Maybe you can update the CodySynthesis page where you list the > > requirements of each package, and change xerces' dependency > > from >= 2.6.0 to >= 2.8.0? > > Thanks for the suggestion. The problem with making this change > is that the XPath support is an optional component. The core > functionality of XSD is working with older versions of Xerces-C++. Ok I see, makes sense! > The good news is that in the next version of XSD (4.0.0) we are > dropping support for Xerces-C++ 2-series. So this will become a > non-issue. Great, any release schedules disclosed yet? > > Boris -- Pietro Cerutti gahr@gahr.ch PGP Public Key: http://gahr.ch/pgp -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20100701/f2e1e3a4/attachment.pgp From boris at codesynthesis.com Thu Jul 1 12:54:17 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 1 10:43:21 2010 Subject: [xsd-users] build problem In-Reply-To: <20100701142202.GA23751@gahrfit.gahr.ch> References: <20100628102357.GN50859@gahrfit.gahr.ch> <20100701065210.GC15928@gahrfit.gahr.ch> <20100701082135.GD15928@gahrfit.gahr.ch> <20100701142202.GA23751@gahrfit.gahr.ch> Message-ID: Hi Pietro, Pietro Cerutti writes: > Great, any release schedules disclosed yet? No concrete time table yet. XSD 3.3.0 was released just a few months ago. Boris From matthew.d.wood at intel.com Thu Jul 1 19:59:36 2010 From: matthew.d.wood at intel.com (Wood, Matthew D) Date: Fri Jul 2 10:54:21 2010 Subject: [xsd-users] Issue parsing document using namespace declaration with cxx-parser Message-ID: <8DD2590731AB5D4C9DBF71A877482A900159277D41@orsmsx509.amr.corp.intel.com> I'm writing an application that uses cxx-parser to handle documents using the XACML schema (http://docs.oasis-open.org/xacml/2.0/access_control-xacml-2.0-policy-schema-os.xsd). The skeleton was generated to include validation and use Xerces as the parser. Many of the documents I'm receiving have the form: Anyone can access anything. The code that initiates the parse looks like the following: std::istream& policyXml; // opened elsewhere xml_schema::document doc_p( PolicyType_p, "urn:oasis:names:tc:xacml:2.0:policy:schema:os", "Policy", true ); PolicyType_p.pre(); doc_p.parse( policyXml, xml_schema::flags::dont_validate ); // parser skeletons are built with validation support std::auto_ptr policy( PolicyType_p.post_PolicyType() ); When I run the code, it catches a xml_schema::exception with message ":2:256 error: unexpected attribute 'xmlns'" instead of treating it as the namespace declaration for the elements. I tried hand modifying a message to use a namespace prefix like the following and parsing works as expected. Anyone can access anything. Is there a known workaround for this or am I missing something in the parser setup? I tried using a cxx-tree skeleton to parse the same documents and had no issues with either encoding. Thanks, Matt From pmonteirorocha at sapo.pt Fri Jul 2 05:59:23 2010 From: pmonteirorocha at sapo.pt (Pedro) Date: Fri Jul 2 10:54:22 2010 Subject: [xsd-users] Problem in translating schema to C++ (following parser guide) In-Reply-To: <20100701165137.GA23159@tpad> References: <4C2B5151.6050002@sapo.pt> <4C2C5F89.3010500@sapo.pt> <20100701165137.GA23159@tpad> Message-ID: <4C2DB87B.60407@sapo.pt> On 01-07-2010 17:51, Boris Kolpackov wrote: > Hi Pedro, > > In the future please keep your replies CC'ed to the xsd-users mailing > list as discussed in the posting guidelines: > > http://www.codesynthesis.com/support/posting-guidelines.xhtml > > > Sorry, I thought the answer would come from that e-mail. > Pedro writes: > > >> Hmm, I've tryed following that guide too, but I'm stuck at the "xsdcxx >> cxx-tree hello.xsd". Same error. I have XSD 3.3.0. >> > Are you using xsdcxx Debian/Ubuntu package or are you using the > xsd package downloaded from the codesynthesis.com website? Can > you try to download the .tar.bz2 package and see if the 'xsd' > binary in the bin/ subdirectory works for you? > > The error makes me think that there is some conflict between the > g++ version (or, more precisely, libstdc++) that was used to build > xsdcxx and the version that you have installed on your box. You may > want to try to upgrade or downgrade libstdc++6 package and see if > this helps. > > Used the package from the Ubuntu repository, and then switched to the xsd package from codesynthesis.com. Same error, nothing changed. Executing the xsd in the /bin folder of the .tar.bz2 package returns the same error. Updated the libstdx++ package. I had 4.1, or 4.4 already... I now have the following libraries: Libstdc++6-v3(Standard); Libstdc++6.4.4(development). All 32 bits. I do not have any libstdc++6 v3 "shared library subset kit" package, neither the debugging files. I have the xsdcxx 3.2.0.1-1.1 build 2 version, and from "http://packages.ubuntu.com/lucid/xsdcxx" it says libstdc++6 (>= 4.4.0). Each one seems to be correct. The xsd package was compiled with which version? > >> I've installed xsd3.3.0 in Windows XP, and extracted the .cxx and >> .hxx files with "xsd cxx-parser --xml-parser expat hello.xsd" but >> I'm not sure those files can be used in windows and linux. >> > Yes, the files are the same on all platforms. Just make sure you > have the same version of XSD on both platforms (that is, using > 3.3.0 on Windows and 3.2.0 on Linux won't work). > > > This should allow me to proceed foward, altough having to create the files in windows is a bit of a pain. >> Also, when i compile hello.xml with xsd, the result is a bit different >> from the hello.xsd that the example shows: >> >> [...] >> >> and it gives me a few errors when I try to compile in windows xsd.exe. >> > This schema is invalid. Since it was generated with Mono's xsd.exe, I > am afraid I can't help you with that. You may want to contact the > Mono developers to report this problem. > > Generally, thought, schemas that are auto-generated from a sample > XML document are quite inaccurate. They usually require a lot of > manual editing to make them usable. > So it seems I'll have to handcraft my xsd file... > Boris > I'll test all the libstc libraries, downgrading until I reach 4.1, and Ill install the 2 libraries I don't have, just in case something is missing. Thank you for your support, Pedro Rocha. From boris at codesynthesis.com Fri Jul 2 17:11:23 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 2 15:00:26 2010 Subject: [xsd-users] Issue parsing document using namespace declaration with cxx-parser In-Reply-To: <8DD2590731AB5D4C9DBF71A877482A900159277D41@orsmsx509.amr.corp.intel.com> References: <8DD2590731AB5D4C9DBF71A877482A900159277D41@orsmsx509.amr.corp.intel.com> Message-ID: Hi Matthew, Wood, Matthew D writes: > When I run the code, it catches a xml_schema::exception with > message ":2:256 error: unexpected attribute 'xmlns'" instead > of treating it as the namespace declaration for the elements. Ok, I did some debugging and it appears that there is a bug (or misfeature) in Xerces-C++ in that it reports attributes such as xmlns:p="..." as belonging to the XML namespace while attributes such as xmlns="..." as unqualified. On the other hand, the XML Schema validation code generated with the --generate-validation option expects special attributes to be in the XML namespace and when it sees an unqualified xmlns attribute, it reports it as unexpected. I have worked around this problem and you can download the fix via these links: http://codesynthesis.com/~boris/tmp/xsd-3.3.0-cxx-parser-xmlns.zip http://codesynthesis.com/~boris/tmp/xsd-3.3.0-cxx-parser-xmlns.tar.gz Simply copy the file in the archive over your vanilla XSD 3.3.0 distribution (no XSD compiler update is necessary). I have also filed a bug report with the Xerces-C++ project: https://issues.apache.org/jira/browse/XERCESC-1934 You may be wondering how come this issue hasn't been detected a long time ago. The answer is that when people use Xerces-C++ with C++/Parser, they normally use the XML Schema validation in Xerces-C++ rather than in the generated code. If the XML Schema validation is performed in the generated code then it makes sense to use the Expat parser since it is smaller and faster (--xml-parser expat). And Expat always reports the xmlns attributes as belonging to the XML namespace. Boris From boris at codesynthesis.com Sun Jul 4 16:06:01 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Jul 4 13:55:14 2010 Subject: [xsd-users] Problem in translating schema to C++ (following parser guide) In-Reply-To: <4C2DB87B.60407@sapo.pt> References: <4C2B5151.6050002@sapo.pt> <4C2C5F89.3010500@sapo.pt> <20100701165137.GA23159@tpad> <4C2DB87B.60407@sapo.pt> Message-ID: Hi Pedro, Pedro writes: > Used the package from the Ubuntu repository, and then switched to the > xsd package from codesynthesis.com. Same error, nothing changed. Ok, this gets even stranger. The xsd binary in the package from our website is statically linked to everything except libc. So this has nothing to do with libstdc++. Can you send me the stack trace of the crash (using xsd from codesynthesis.com) by doing the following: $ ulimit -c unlimit $ path/to/xsd # trigger the crash; this should produce core $ gdb path/to/xsd core Once the gdb prompt appears, type 'bt' and copy the stack trace to an email. Boris From pmonteirorocha at sapo.pt Sun Jul 4 18:54:05 2010 From: pmonteirorocha at sapo.pt (Pedro) Date: Mon Jul 5 05:32:18 2010 Subject: [xsd-users] Problem in translating schema to C++ (following parser guide) In-Reply-To: References: <4C2B5151.6050002@sapo.pt> <4C2C5F89.3010500@sapo.pt> <20100701165137.GA23159@tpad> <4C2DB87B.60407@sapo.pt> Message-ID: <4C31110D.606@sapo.pt> On 04-07-2010 21:06, Boris Kolpackov wrote: > Hi Pedro, > > Pedro writes: > > >> Used the package from the Ubuntu repository, and then switched to the >> xsd package from codesynthesis.com. Same error, nothing changed. >> > Ok, this gets even stranger. The xsd binary in the package from our > website is statically linked to everything except libc. So this has > nothing to do with libstdc++. Can you send me the stack trace of > the crash (using xsd from codesynthesis.com) by doing the following: > > $ ulimit -c unlimit > $ path/to/xsd # trigger the crash; this should produce core > $ gdb path/to/xsd core > > Once the gdb prompt appears, type 'bt' and copy the stack trace > to an email. > > Boris > Hmm, the gdb command does not accept arguments into the executable that we are trying to execute, so I did it in a diferent way. I searched arround and I think I did everything correctly. The steps and results are shown below: pedro@Ubt-Pedro:~/Transfer?ncias/xsd-3.3.0-i686-linux-gnu/bin$ gdb ./xsd GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu". For bug reporting instructions, please see: ... Lendo s?mbolos de /home/pedro/Transfer?ncias/xsd-3.3.0-i686-linux-gnu/bin/xsd...conclu?do. (gdb) run cxx-parser --xml-parser expat hello.xsd Starting program: /home/pedro/Transfer?ncias/xsd-3.3.0-i686-linux-gnu/bin/xsd cxx-parser --xml-parser expat hello.xsd terminate called after throwing an instance of 'std::length_error' what(): basic_string::resize Program received signal SIGABRT, Aborted. 0x0012d422 in __kernel_vsyscall () (gdb) bt #0 0x0012d422 in __kernel_vsyscall () #1 0x00198651 in raise () from /lib/tls/i686/cmov/libc.so.6 #2 0x0019ba82 in abort () from /lib/tls/i686/cmov/libc.so.6 #3 0x085b3591 in __gnu_cxx::__verbose_terminate_handler () at ../../../../src/gcc-3.4.4/libstdc++-v3/libsupc++/vterminate.cc:96 #4 0x085b1365 in __cxxabiv1::__terminate ( handler=0x85b3490 <__gnu_cxx::__verbose_terminate_handler()>) at ../../../../src/gcc-3.4.4/libstdc++-v3/libsupc++/eh_terminate.cc:43 #5 0x085b13a2 in std::terminate () at ../../../../src/gcc-3.4.4/libstdc++-v3/libsupc++/eh_terminate.cc:53 #6 0x085b1522 in __cxa_throw (obj=0x89b4710, tinfo=0x0, dest=0) at ../../../../src/gcc-3.4.4/libstdc++-v3/libsupc++/eh_throw.cc:80 #7 0x0856109d in std::__throw_length_error (__s=0x0) at /home/boris/build/gcc/gcc-3.4.4-i686-linux-gnu/i686-unknown-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:69 #8 0x085ac9cc in std::basic_string, std::allocator >::resize (this=0xbfffda70, __n=4294967295, __c=0 L'\000') at /home/boris/build/gcc/gcc-3.4.4-i686-linux-gnu/i686-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:576 #9 0x0831d553 in XSDFrontend::Parser::Impl::dom(boost::filesystem::path const&, bool) () #10 0x0833a4a7 in XSDFrontend::Parser::Impl::parse(boost::filesystem::path const&) () #11 0x0833bb0d in XSDFrontend::Parser::parse(boost::filesystem::path const&) () ---Type to continue, or q to quit--- #12 0x08053ffc in main () (gdb) I did a second try, to include the core file generated before: pedro@Ubt-Pedro:~/Transfer?ncias/xsd-3.3.0-i686-linux-gnu/bin$ gdb ./xsd GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu". For bug reporting instructions, please see: ... Lendo s?mbolos de /home/pedro/Transfer?ncias/xsd-3.3.0-i686-linux-gnu/bin/xsd...conclu?do. (gdb) run cxx-parser --xml-parser expat hello.xsd core Starting program: /home/pedro/Transfer?ncias/xsd-3.3.0-i686-linux-gnu/bin/xsd cxx-parser --xml-parser expat hello.xsd core terminate called after throwing an instance of 'std::length_error' what(): basic_string::resize Program received signal SIGABRT, Aborted. 0x0012d422 in __kernel_vsyscall () (gdb) bt #0 0x0012d422 in __kernel_vsyscall () #1 0x00198651 in raise () from /lib/tls/i686/cmov/libc.so.6 #2 0x0019ba82 in abort () from /lib/tls/i686/cmov/libc.so.6 #3 0x085b3591 in __gnu_cxx::__verbose_terminate_handler () at ../../../../src/gcc-3.4.4/libstdc++-v3/libsupc++/vterminate.cc:96 #4 0x085b1365 in __cxxabiv1::__terminate ( handler=0x85b3490 <__gnu_cxx::__verbose_terminate_handler()>) at ../../../../src/gcc-3.4.4/libstdc++-v3/libsupc++/eh_terminate.cc:43 #5 0x085b13a2 in std::terminate () at ../../../../src/gcc-3.4.4/libstdc++-v3/libsupc++/eh_terminate.cc:53 #6 0x085b1522 in __cxa_throw (obj=0x89b4740, tinfo=0x0, dest=0) at ../../../../src/gcc-3.4.4/libstdc++-v3/libsupc++/eh_throw.cc:80 #7 0x0856109d in std::__throw_length_error (__s=0x0) at /home/boris/build/gcc/gcc-3.4.4-i686-linux-gnu/i686-unknown-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:69 #8 0x085ac9cc in std::basic_string, std::allocator >::resize (this=0xbfffda70, __n=4294967295, __c=0 L'\000') at /home/boris/build/gcc/gcc-3.4.4-i686-linux-gnu/i686-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:576 #9 0x0831d553 in XSDFrontend::Parser::Impl::dom(boost::filesystem::path const&, bool) () #10 0x0833a4a7 in XSDFrontend::Parser::Impl::parse(boost::filesystem::path const&) () ---Type to continue, or q to quit--- #11 0x0833bb0d in XSDFrontend::Parser::parse(boost::filesystem::path const&) () #12 0x08053ffc in main () (gdb) I hope this gives some clue to what's happening, and that every thing was done correctly. Thank you for your support. Pedro Rocha. From boris at codesynthesis.com Mon Jul 5 08:15:34 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 5 06:04:31 2010 Subject: [xsd-users] Problem in translating schema to C++ (following parser guide) In-Reply-To: <4C31110D.606@sapo.pt> References: <4C2B5151.6050002@sapo.pt> <4C2C5F89.3010500@sapo.pt> <20100701165137.GA23159@tpad> <4C2DB87B.60407@sapo.pt> <4C31110D.606@sapo.pt> Message-ID: Hi Pedro, Pedro writes: > pedro@Ubt-Pedro:~/Transfer?ncias/xsd-3.3.0-i686-linux-gnu/bin$ gdb ./xsd Ok, I figured out what the problem is. The directory name which contains the schema file that you are trying to compile has a non-ASCII character ('?' in Transfer?ncias). For some reason this results in the crash. The XSD compiler uses the filesystem library from Boost to represent paths so I will have to dig into that to figure out what's wrong, which may take some time. In the meantime, the easy work around that you can use is to place your schemas into a directory with ASCII-only characters. Thanks for helping to track this down. Boris From pmonteirorocha at sapo.pt Mon Jul 5 06:45:41 2010 From: pmonteirorocha at sapo.pt (Pedro) Date: Mon Jul 5 15:39:55 2010 Subject: [xsd-users] Problem in translating schema to C++ (following parser guide) In-Reply-To: References: <4C2B5151.6050002@sapo.pt> <4C2C5F89.3010500@sapo.pt> <20100701165137.GA23159@tpad> <4C2DB87B.60407@sapo.pt> <4C31110D.606@sapo.pt> Message-ID: <4C31B7D5.6020200@sapo.pt> On 05-07-2010 13:15, Boris Kolpackov wrote: > Hi Pedro, > > Pedro writes: > > >> pedro@Ubt-Pedro:~/Transfer?ncias/xsd-3.3.0-i686-linux-gnu/bin$ gdb ./xsd >> > Ok, I figured out what the problem is. The directory name which contains > the schema file that you are trying to compile has a non-ASCII character > ('?' in Transfer?ncias). For some reason this results in the crash. The > XSD compiler uses the filesystem library from Boost to represent paths > so I will have to dig into that to figure out what's wrong, which may > take some time. In the meantime, the easy work around that you can use > is to place your schemas into a directory with ASCII-only characters. > > Thanks for helping to track this down. > > Boris > No problem, just tested it now, that's it. Changed the path and it worked fine. Thank you for everything. Pedro Rocha. From emiliano.leporati at gmail.com Tue Jul 13 05:48:50 2010 From: emiliano.leporati at gmail.com (Emiliano Leporati) Date: Tue Jul 13 05:48:54 2010 Subject: [xsd-users] unnamed sequence of sequence Message-ID: Hi, i have a question about the class transposition of this XSD fragment: <*sequence* maxOccurs="unbounded"> <*sequence*> reading the XSD code one would imagine a sequence of set of fours (every element is mandatory), but the outer class representing the node containing the MeasurementLogTSSType expose four distinct sequences, one for EventPCRIndex, one for EventClass, and so on ... the resulting XML appears like this: -1 -1 CONFIG_FILE LIBRARY TVhNQ29uZmlndXJhdGlvbi1saW51eC11YmsueG1s L3Vzci9sb2NhbC9saWIvbXhtX2VuZ2luZXMvbGlibXhtX3ViaWtfbXBlZzIx ZmlsZV9lbmdpbmUuc28= this XML fragment does not seem to match the XSD definition, and moreover, having four distinct sequences lets us put different number of values for every element ( one EventPCRIndex, two EventClass, three EventValue and no EventPCRValue for example). am I misinterpreting something or is this a bug in the xsd tool ? is there a simple workaround to achieve the desired result, for example giving a name to the inner sequence by defining it as a separate element ? thanks Emiliano Leporati From boris at codesynthesis.com Tue Jul 13 12:13:05 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 13 10:01:52 2010 Subject: [xsd-users] unnamed sequence of sequence In-Reply-To: References: Message-ID: Hi Emiliano, Emiliano Leporati writes: > this XML fragment does not seem to match the XSD definition, and moreover, > having four distinct sequences lets us put different number of values for > every element ( one EventPCRIndex, two EventClass, three EventValue and no > EventPCRValue for example). > > am I misinterpreting something or is this a bug in the xsd tool? This is a deliberate design choice in the C++/Tree mapping. For more information, please see: http://www.codesynthesis.com/pipermail/xsd-users/2007-March/000863.html > is there a simple workaround to achieve the desired result, The following post list a number of possible solutions to a very similar problem (unbounded choice). They all apply to your case as well: http://codesynthesis.com/pipermail/xsd-users/2010-March/002741.html > for example giving a name to the inner sequence by defining it as > a separate element ? Yes, this is one of the solution, probably the simplest one. Let me know if you still have any questions after reading the above two posts. Boris From alex at alexchamberlain.co.uk Tue Jul 13 16:44:23 2010 From: alex at alexchamberlain.co.uk (Alex Chamberlain) Date: Tue Jul 13 16:44:49 2010 Subject: [xsd-users] Trouble getting started Message-ID: <003b01cb22cc$2d8fe970$88afbc50$@co.uk> Hi, I'm having some trouble getting started. I have a schema supplied by a web site, which includes (among others) the following root element, I have the following code, std::auto_ptr p = ping(buffer); std::cout << "Code: " << p->code() << std::endl; I get the following error (among others), Error: no matching function for call to ping::ping(std::istringstream&) I used the following cmd line to generate the header files, xsd cxx-tree --generate-serialization --generate-element-type --generate-element-map --root-element-all schema.xsd Why is this not working? Thanks for your help, Alex From boris at codesynthesis.com Wed Jul 14 03:06:38 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 14 00:55:25 2010 Subject: [xsd-users] Trouble getting started In-Reply-To: <003b01cb22cc$2d8fe970$88afbc50$@co.uk> References: <003b01cb22cc$2d8fe970$88afbc50$@co.uk> Message-ID: Hi Alex, Alex Chamberlain writes: > > > [...] > > > > I have the following code, > std::auto_ptr p = ping(buffer); > std::cout << "Code: " << p->code() << std::endl; > > I get the following error (among others), > Error: no matching function for call to ping::ping(std::istringstream&) The 'ping' element is of an anonymous type so in the generated code the class is named 'ping' and the parsing/serialization function names are escaped to 'ping_'. The first line in your code fragment then should be: std::auto_ptr p = ping_(buffer); > I used the following cmd line to generate the header files, > xsd cxx-tree --generate-serialization --generate-element-type > --generate-element-map --root-element-all schema.xsd You specified the --generate-element-type option which actually suppresses the generation of parsing/serialization functions and instead results in element types being generated. For more information on this, see Chapter 2.9, "Mapping for Global Elements" in the C++/Tree Mapping User Manual: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.9 There is also the 'messaging' example that shows how to use element types and maps. If you don't need this functionality and would rather prefer the parsing functions (so that the above code works), then remove the --generate-element-* options. Boris From howes at ll.mit.edu Wed Jul 14 09:11:03 2010 From: howes at ll.mit.edu (Brad Howes) Date: Wed Jul 14 09:11:17 2010 Subject: [xsd-users] XSD Libraries Message-ID: All, I'm working with a set of XML schema files that use GML 3.2 for their base. Everything works fine, but I was wondering if it was possible to generate C++ files for GML 3.2 first and build a library, and then when generating the C++ files for the other schema files xsd would somehow know to stop generating stuff when it reached GML 3.2 entities that have already been generated in the previous step. The motivation for doing so is that a recompile due to a schema change is incredibly long, even when using ccache. Regards, Brad -- Brad Howes Group 42 MIT Lincoln Laboratory ? 244 Wood St. ? Lexington, MA 02173 Phone: 781.981.5292 ? Fax: 781.981.3495 ? Secretary: 781.981.7420 From boris at codesynthesis.com Thu Jul 15 10:48:54 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 15 10:42:21 2010 Subject: [xsd-users] XSD Libraries In-Reply-To: References: Message-ID: Hi Brad, Brad Howes writes: > I'm working with a set of XML schema files that use GML 3.2 for their > base. Everything works fine, but I was wondering if it was possible > to generate C++ files for GML 3.2 first and build a library, and then > when generating the C++ files for the other schema files xsd would > somehow know to stop generating stuff when it reached GML 3.2 entities > that have already been generated in the previous step. This is, of course, trivially possible if one uses the file-per-schema mode (which is the default). This is just a clarification for other folks who may be reading this and wondering what's the big deal. The problem is that GML 3.2 can only be compiled in the file-per-type mode. I think it should also be possible in this case provided that your schemas that reference the GML 3.2 schema do that via the "official entry point" (e.g., gml.xsd), that is, they only import the GML schema files that are complete wrt GML import/include (one of the reasons why GML 3.2 cannon be compiled in the file-per-schema mode is that some of its schema files are not valid by themselves; they reference declarations without the corresponding include/import statements and which are made "visible" only if these files are loaded indirectly via the "official entry points"). If this requirement is satisfied, then you can do the following: 1. Compile the GML 3.2 schemas with the --file-per-type options and place the generated code into a library. 2. Compile you schemas without the --file-per-type option. The resulting generated code will reference header files corresponding to the "official entry point" generated on step 1. Boris From john.dingelstad at dhv.com Sat Jul 17 10:37:19 2010 From: john.dingelstad at dhv.com (Dingelstad, John) Date: Mon Jul 19 09:14:52 2010 Subject: [xsd-users] FW: map files and extended types... References: <9167A10F4E23294A98CED445A591727D09F594099F@dhnl001ex001.intra.local> Message-ID: <315123AEEA98E94CA171FF059C0A80BC02C37868@dhnl001ex001.intra.local> HI Boris, I'm using the C++ parser to process DATEXII files. Unfortunately this proves to be a hell of a job to set all the required mappings and after a slow start, I finally made some progress. Unfortunately I now got struck again and don't know to get further. The issue I am trying to solve is related to the following piece of xsd code If defined the following object for D2LogicalModel:MeasurementSpecificCharacteristics class MeasurementSpecificCharacteristics { public: MeasurementSpecificCharacteristics(float period, const std::string& specificLane, ::MeasuredOrDerivedDataTypeEnum specificMeasurementValueType, const ::VehicleCharacteristics& specificVehicleCharacteristics) : _period(period), _specificLane(specificLane), _specificMeasurementValueType(specificMeasurementValueType), _specificVehicleCharacteristics(specificVehicleCharacteristics) { } //... private: float _period; std::string _specificLane; ::MeasuredOrDerivedDataTypeEnum _specificMeasurementValueType; ::VehicleCharacteristics _specificVehicleCharacteristics; }; And the implementation is as follow: void MeasurementSpecificCharacteristics_pimpl::period(float period) { _period = period; } void MeasurementSpecificCharacteristics_pimpl::specificLane(const std::string& specificLane) { _specificLane = specificLane; } void MeasurementSpecificCharacteristics_pimpl::specificMeasurementValueType(::MeasuredOrDerivedDataTypeEnum specificMeasurementValueType) { _specificMeasurementValueType = specificMeasurementValueType; } void MeasurementSpecificCharacteristics_pimpl::specificVehicleCharacteristics(const ::VehicleCharacteristics& specificVehicleCharacteristics) { _specificVehicleCharacteristics = specificVehicleCharacteristics; } ::MeasurementSpecificCharacteristics MeasurementSpecificCharacteristics_pimpl::post_MeasurementSpecificCharacteristics () { return ::MeasurementSpecificCharacteristics(_period, _specificLane, _specificMeasurementValueType, _specificVehicleCharacteristics); } When I compile my code, I get an error stating datex2::measurementSpecificCharacteristics_pimpl' : no appropriate default constructor available This seems to be due to the fact of the private variables I've declared in MeasurementSpecificCharacteristics_pimpl for _period etc. Anyway, what I want is to pass on the data of the MeasurementSpecificCharacteristics object along with the index to the MeasurementSiteRecord but have no clue ho to achive this is as all attempts to define a measurementSpecificCharacteristics object and/or altering the measurementSpecificCharacteristics_pimpl results in more problems... Can you please help me out on how I can deal with this issue? I've been looking in the examples as well but didn't find anything related to this in combination with map files Many thanks in advance, John Dingelstad DISCLAIMER =========================================================================== This e-mail and the information it contains are confidential and meant only for the use of the addressee(s); disclosure or copying is strictly prohibited. If you are not addressed, but in the possession of this e-mail, please notify the sender immediately. =========================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: DATEXII Parsers.zip Type: application/zip Size: 295165 bytes Desc: DATEXII Parsers.zip Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20100717/e17e0592/DATEXIIParsers-0001.zip From boris at codesynthesis.com Mon Jul 19 09:35:31 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 19 09:29:16 2010 Subject: [xsd-users] FW: map files and extended types... In-Reply-To: <315123AEEA98E94CA171FF059C0A80BC02C37868@dhnl001ex001.intra.local> References: <9167A10F4E23294A98CED445A591727D09F594099F@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC02C37868@dhnl001ex001.intra.local> Message-ID: Hi John, Dingelstad, John writes: > I'm using the C++ parser to process DATEXII files. > > Unfortunately this proves to be a hell of a job to set all the > required mappings and after a slow start, I finally made some > progress. Yes, handling complex schemas with C++/Parser can require some effort. Is there a good reason for you to prefer it over C++/Tree? >From your code I see that you are constructing an in-memory object model. Have you considered using C++/Hybrid from XSD/e[1] if C++/Tree it too heavy-weight for you? [1] http://www.codesynthesis.com/products/xsde/ > Unfortunately I now got struck again and don't know to get further. I took a look at your code and the problem has to do with the lack of default constructors in your object model types (DATEXIIObjectModel.h). Since you store instances of these types as member variables in parser implementation classes, you will either need to add default constructors to these types or you will need to add constructors to the parser classes that call non-default constructors of these types with some default values. Adding default constructors will probably be the easiest way forward. Boris From john.dingelstad at dhv.com Mon Jul 19 09:55:48 2010 From: john.dingelstad at dhv.com (Dingelstad, John) Date: Mon Jul 19 10:28:20 2010 Subject: [xsd-users] FW: map files and extended types... In-Reply-To: References: <9167A10F4E23294A98CED445A591727D09F594099F@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC02C37868@dhnl001ex001.intra.local> Message-ID: <315123AEEA98E94CA171FF059C0A80BC0B403A90@dhnl001ex001.intra.local> Hi Boris, Thanks for your answer. Yes, I have considered C++ Tree, but given the fact that I get XML files which can be >1GB in size, it's just not going to work as I sooner or later will hit the 3GB barrier on windows. Therefore, I went with C++ Parser as it allows me to process and discard each dataset that has been retrieved from the input file. I'll haven't looked at Hybrid as it was/seems to be targeted towards embedded applications. John DISCLAIMER =========================================================================== This e-mail and the information it contains are confidential and meant only for the use of the addressee(s); disclosure or copying is strictly prohibited. If you are not addressed, but in the possession of this e-mail, please notify the sender immediately. =========================================================================== From boris at codesynthesis.com Mon Jul 19 10:43:07 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 19 10:36:50 2010 Subject: [xsd-users] FW: map files and extended types... In-Reply-To: <315123AEEA98E94CA171FF059C0A80BC0B403A90@dhnl001ex001.intra.local> References: <9167A10F4E23294A98CED445A591727D09F594099F@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC02C37868@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC0B403A90@dhnl001ex001.intra.local> Message-ID: Hi John, Dingelstad, John writes: > Yes, I have considered C++ Tree, but given the fact that I get XML files > which can be >1GB in size, it's just not going to work as I sooner or > later will hit the 3GB barrier on windows. Therefore, I went with C++ > Parser as it allows me to process and discard each dataset that has been > retrieved from the input file. You can do that with C++/Tree as well. See the 'streaming' example in the examples/cxx/tree/ directory. > I'll haven't looked at Hybrid as it was/seems to be targeted towards > embedded applications. Configured with STL, iostream, and C++ exceptions enabled, C++/Hybrid is quite suitable for general-purpose applications, especially those looking for small footprint and runtime memory consumption. It also supports partially in-memory processing (in fact, C++/Hybrid is built on top of C++/Parser). There is also the 'streaming' example that shows how to accomplish this. Boris From howes at ll.mit.edu Mon Jul 19 11:12:26 2010 From: howes at ll.mit.edu (Brad Howes) Date: Mon Jul 19 11:12:41 2010 Subject: [xsd-users] XSD Libraries In-Reply-To: References: Message-ID: On Jul 15, 2010, at 10:48 AM, Boris Kolpackov wrote: >> I'm working with a set of XML schema files that use GML 3.2 for their >> base. Everything works fine, but I was wondering if it was possible >> to generate C++ files for GML 3.2 first and build a library, and then >> when generating the C++ files for the other schema files xsd would >> somehow know to stop generating stuff when it reached GML 3.2 entities >> that have already been generated in the previous step. [snip] > 1. Compile the GML 3.2 schemas with the --file-per-type options > and place the generated code into a library. > > 2. Compile you schemas without the --file-per-type option. The > resulting generated code will reference header files > corresponding to the "official entry point" generated on > step 1. Thanks Boris! That's is what I assumed would work. Unfortunately, the schemas I am using from another team suffer from using a 'kitchen-sink' include that includes all of the real includes. The problem this causes is undefined types in the C++ files because the include guard macros in the 'kitchen-sink' include keep the compiler from seeing the other include files. The other team insists that it would be too much work to know which include files they really need. I've told them that their software engineering methods take too much work for me to support... Regards, Brad -- Brad Howes Group 42 MIT Lincoln Laboratory ? 244 Wood St. ? Lexington, MA 02173 Phone: 781.981.5292 ? Fax: 781.981.3495 ? Secretary: 781.981.7420 From boris at codesynthesis.com Mon Jul 19 12:00:55 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jul 19 11:54:39 2010 Subject: [xsd-users] XSD Libraries In-Reply-To: References: Message-ID: Hi Brad, Brad Howes writes: > Unfortunately, the schemas I am using from another team suffer from > using a 'kitchen-sink' include that includes all of the real includes. > The problem this causes is undefined types in the C++ files because > the include guard macros in the 'kitchen-sink' include keep the > compiler from seeing the other include files. You can append prefixes to include guards using the --guard-prefix option. You can do it on the file-by-file basis which should allow you to make the guards unique across the generated files. Boris From howes at ll.mit.edu Mon Jul 19 14:12:04 2010 From: howes at ll.mit.edu (Brad Howes) Date: Mon Jul 19 14:12:21 2010 Subject: [xsd-users] XSD Libraries In-Reply-To: References: Message-ID: <31A81CAF-6190-46D5-BE57-8E827593C802@ll.mit.edu> On Jul 19, 2010, at 12:00 PM, Boris Kolpackov wrote: > You can append prefixes to include guards using the --guard-prefix > option. You can do it on the file-by-file basis which should allow > you to make the guards unique across the generated files. I don't think this will help. Take for example the following scenario: one.xsd: defines One two.xsd: defines Two, derived from One both.xsd: includes one.xsd and then two.xsd The C++ generation for two.xsd will generate two.hxx which does this: #include "both.hxx" and both.hxx does this: #include "two.hxx" #include "one.hxx" Now two derives from one (note the order), but I cannot define Two, because when one.hxx tries to include both.hxx, it skips the other includes because the both.hxx guard macro protects from multiple loading, and thus one.hxx never gets loaded. Brad -- Brad Howes Group 42 MIT Lincoln Laboratory ? 244 Wood St. ? Lexington, MA 02173 Phone: 781.981.5292 ? Fax: 781.981.3495 ? Secretary: 781.981.7420 From john.dingelstad at dhv.com Mon Jul 19 13:30:56 2010 From: john.dingelstad at dhv.com (Dingelstad, John) Date: Mon Jul 19 16:24:52 2010 Subject: [xsd-users] FW: map files and extended types... References: <9167A10F4E23294A98CED445A591727D09F594099F@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC02C37868@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC0B403A90@dhnl001ex001.intra.local> Message-ID: <315123AEEA98E94CA171FF059C0A80BC02C37869@dhnl001ex001.intra.local> Hi Boris, Too many tools allow for simple things to be done in to many different ways! I like your tools, but they also make sometimes wondering whether I am doing things the right way, each time i discover something new. There is nothing wrong with that, but sometimes, I feel I am spending more time understanding all the bells and whistles of the xsd tools than on working on my actual problem... Guess it's all part of the learning curve. Anyway, maybe you could tell me your opinion on what the best approach would be in my case: Basically, I get 2 DATEX files delivered. One which contains a measured data publication and which indirect refers to the other file which contains the measured site table publication. The measured data publication (approx. 1GB large) contains all kinds of measurement data records, which I shall process and store into a database and in order to do so, I need info from the measurement site table publication. Due to the large size of the measured dat publication, I choose the C++ parser approach. First I will parse the measurement site table publication and create an internal data structure of only that data in which I am actually interested in. This is something I've nearly finished. The 2nd step would be parse the measured data publication. Once I've collected/parsed a record, I could do the necessary processing in one of the callback functions. BTW is there a way to pass on some extra data to the parser? I.e. I'll need to access the data I previously collected from the measurement site table publication within the parser callback functions when I've collected a measurement data record. Sure it can be done through some global variables but that wouldn't be the nicest way I can think of. Regards, John -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Mon 19-7-2010 16:43 To: Dingelstad, John Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] FW: map files and extended types... Hi John, Dingelstad, John writes: > Yes, I have considered C++ Tree, but given the fact that I get XML files > which can be >1GB in size, it's just not going to work as I sooner or > later will hit the 3GB barrier on windows. Therefore, I went with C++ > Parser as it allows me to process and discard each dataset that has been > retrieved from the input file. You can do that with C++/Tree as well. See the 'streaming' example in the examples/cxx/tree/ directory. > I'll haven't looked at Hybrid as it was/seems to be targeted towards > embedded applications. Configured with STL, iostream, and C++ exceptions enabled, C++/Hybrid is quite suitable for general-purpose applications, especially those looking for small footprint and runtime memory consumption. It also supports partially in-memory processing (in fact, C++/Hybrid is built on top of C++/Parser). There is also the 'streaming' example that shows how to accomplish this. Boris From boris at codesynthesis.com Tue Jul 20 10:04:48 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 20 09:58:37 2010 Subject: [xsd-users] XSD Libraries In-Reply-To: <31A81CAF-6190-46D5-BE57-8E827593C802@ll.mit.edu> References: <31A81CAF-6190-46D5-BE57-8E827593C802@ll.mit.edu> Message-ID: Hi Brad, Brad Howes writes: > Take for example the following scenario: > > one.xsd: defines One > two.xsd: defines Two, derived from One > both.xsd: includes one.xsd and then two.xsd > > The C++ generation for two.xsd will generate two.hxx which does this: > > #include "both.hxx" > > and both.hxx does this: > > #include "two.hxx" > #include "one.hxx" Yes, this is one of the cases where you need the file-per-type mode. Unfortunately, it seems your choices are limited to using the file- per-type mode (and enduring long compilation times) or cleaning up the schemas. Theoretically it should be possible to limit the file-per-type generation to only certain namespaces (or files) so that you can compile the schemas as two separate file-per-type executions, one for GML and one for your schemas. However, this will require quite a bit of work and I am not sure how generally useful such a functionality will be. Boris From boris at codesynthesis.com Tue Jul 20 10:38:40 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 20 10:32:29 2010 Subject: [xsd-users] FW: map files and extended types... In-Reply-To: <315123AEEA98E94CA171FF059C0A80BC02C37869@dhnl001ex001.intra.local> References: <9167A10F4E23294A98CED445A591727D09F594099F@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC02C37868@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC0B403A90@dhnl001ex001.intra.local> <315123AEEA98E94CA171FF059C0A80BC02C37869@dhnl001ex001.intra.local> Message-ID: Hi John, Dingelstad, John writes: > Too many tools allow for simple things to be done in to many > different ways! I don't think one can really expect that processing multi-gigabyte XML files that use a fairly complex XML vocabulary like DATEXII will be a simple task, regardless of which tool one chooses. > I like your tools, but they also make sometimes wondering whether > I am doing things the right way, each time i discover something > new. There is nothing wrong with that, but sometimes, I feel I > am spending more time understanding all the bells and whistles > of the xsd tools than on working on my actual problem... Guess > it's all part of the learning curve. Yes, it is hard to "see" the best way to apply an unfamiliar tool to a fairly complex problem. I think spending some time and getting to know what's available, while time consuming, I am afraid is the only way to solve this. Well, describing your problem and asking for suggestions on the mailing list is probably another alternative ;-). For example, XSD included a large number of examples that show how to solve some fairly tricky problems. The C++/Tree mapping has 24 such examples and one of them ('streaming') addresses the issue that you are trying to overcome. > Anyway, maybe you could tell me your opinion on what the best > approach would be in my case: > > Basically, I get 2 DATEX files delivered. One which contains a > measured data publication and which indirect refers to the other > file which contains the measured site table publication. The > measured data publication (approx. 1GB large) contains all kinds > of measurement data records, which I shall process and store into > a database and in order to do so, I need info from the measurement > site table publication. > > Due to the large size of the measured dat publication, I choose > the C++ parser approach. First I will parse the measurement site > table publication and create an internal data structure of only > that data in which I am actually interested in. This is something > I've nearly finished. The 2nd step would be parse the measured > data publication. Once I've collected/parsed a record, I could > do the necessary processing in one of the callback functions. I see three possible ways to approach this: 1. Use the C++/Tree mapping with the streaming extension (see the 'streaming' example). This will allow you to parse the document a chunk at a time and handle the object model fragment for this chunk. This approach will probably require the least amount of work. 2. Use the C++/Hybrid mapping from XSD/e in the partially in-memory mode (again, see the 'streaming' example but this time in the XSD/e distribution). The idea is the same as in (1) above however here you will override C++/Parser skeletons to "intercept" object model fragments (C++/Hybrid is built on top of C++/Parser). While this will probably require slightly more work than (1), the advantage over C++/Tree is the more compact (runtime memory wise) object model. 3. Use C++/Parser as you are trying to do now. This will require a lot more work than the above two approaches. However, it is the most flexible approach since you control how the object model will look (for example, if you don't need certain fields, then you can leave them out of your object model and save some memory). Let me know if you have any questions on any of this. > BTW is there a way to pass on some extra data to the parser? I.e. > I'll need to access the data I previously collected from the > measurement site table publication within the parser callback > functions when I've collected a measurement data record. You can add member variables to your parser implementation classes and initialize them when the parsers are being created. Boris From pavelpgt at gmail.com Wed Jul 21 13:15:02 2010 From: pavelpgt at gmail.com (Pavel Pohanka) Date: Wed Jul 21 13:15:15 2010 Subject: [xsd-users] Sample code for GML creation? Message-ID: Hallo, I would like to create a GML file in Visual Studio 2008 by means of XSD. I have done a manual creation of *.cxx and *.hxx files according to http://wiki.codesynthesis.com/Schemas/GML (GML 3.2.0) xsd cxx-tree --generate-xml-schema --output-dir gen --options-file common.options xml-schema.xsd xsd cxx-tree --file-per-type --output-dir gen --options-file common.options --options-file gml.options gml/3.2.1/gml.xsd I put all created files and all gml schemas into a project, but I do not know how to start creating an XML file. Can you please provide me with an example code (driver.cxx) of how to start to create an GML XML file. Thanks a lot. Pavel PS: Hello example code works fine (driver.cxx file). int main (int argc, char* argv[]) { try { hello_t h ("Hi"); hello_t::name_sequence& ns (h.name ()); ns.push_back ("Jane"); ns.push_back ("John"); ns.push_back ("John"); ns.push_back ("Pavel"); // Serialize the object model to XML. // xml_schema::namespace_infomap map; map[""].name = ""; map[""].schema = "hello.xsd"; std::ofstream ofs (argv[1]); hello (ofs, h, map); } catch (const xml_schema::exception& e) { cerr << e << endl; return 1; } } } From boris at codesynthesis.com Thu Jul 22 09:52:12 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 22 09:46:08 2010 Subject: [xsd-users] Sample code for GML creation? In-Reply-To: References: Message-ID: Hi Pavel, Pavel Pohanka writes: > I put all created files and all gml schemas into a project, but I do not > know how to start creating an XML file. I am not an expert in this matter but as I understand GML is not used directly as an XML vocabulary but rather as a platform for building other schemas (e.g., CityGML). However, I don't think there is anything that prevents you from creating a GML document. Simply pick a root element of the document that you want to create, for example gml:Point. Add the '--root-element Point' option to the gml.options file and recompile the schema. This way you get parsing/serialization functions generated for this element. Then create and populate a variable of this element's type in your application (PointType in out case; to see its interface, check the PointType.hxx file): #include "gml.hxx" using namespace gml32; gml32::PointType p ("p1"); p.coordinates (CoordinatesType ("100,200")); For a complex schema like GML it may also make sense to generate the Doxygen documentation (--generate-doxygen) so that you get browsable documentation for the generated classes. The final step is to serialize the point to XML: xml_schema::namespace_infomap map; map["gml"].name = "http://www.opengis.net/gml/3.2"; map["gml"].schema = "gml.xsd"; std::ofstream ofs (argv[1]); gml32::Point (ofs, p, map); This should result in a GML document like this: 100,200 Boris From rc.mail.dev at gmail.com Thu Jul 22 22:30:31 2010 From: rc.mail.dev at gmail.com (Romain) Date: Thu Jul 22 22:30:34 2010 Subject: [xsd-users] Parsing and validation from CDR stream Message-ID: Hi everyone, Given this example (from C++ / Tree mapping user manual): // Parse XML to object model. // std::auto_ptr r = root ("root.xml"); // Save to a CDR stream. // ACE_OutputCDR ace_ocdr; xml_schema::ostream ocdr (ace_ocdr); ocdr << *r; // Load from a CDR stream. // ACE_InputCDR ace_icdr (buf, size); xml_schema::istream icdr (ace_icdr); std::auto_ptr copy (new object (icdr)); Is it possible to parse and validate the XML message after loading from the CDR stream? Thank you for your help. Regards, Romain From boris at codesynthesis.com Fri Jul 23 09:46:16 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 23 09:40:15 2010 Subject: [xsd-users] Parsing and validation from CDR stream In-Reply-To: References: Message-ID: Hi Romain, Romain writes: > std::auto_ptr r = root ("root.xml"); > > // Save to a CDR stream. > // > ACE_OutputCDR ace_ocdr; > xml_schema::ostream ocdr (ace_ocdr); > > ocdr << *r; > > // Load from a CDR stream. > // > ACE_InputCDR ace_icdr (buf, size); > xml_schema::istream icdr (ace_icdr); > > std::auto_ptr copy (new object (icdr)); > > Is it possible to parse and validate the XML message after loading > from the CDR stream? I am not sure what you mean by parse and validate in this context. The object model extracted from CDR ('copy' in this case), is already parsed (in XML sense). That is, it is equivalent to 'r' in the above example. You also don't normally need to validate this object model since, unlike XML, the CDR representation is constructed by the generated code and is valid provided you have serialized a valid object model in the first place. The only scenario that I can think of that may make you want to validate the object model after extraction from CDR is if you are not sure the original object model that was saved to CDR was valid (for example, it was created by the application or you disabled validation during XML parsing). In this case the only way to validate the data is to serialize it in XML into an in-memory buffer and then re-parse it with validation. Something along these lines: std::stringstream buf; root (buf, *copy, map); // map specified schema copy = root (buf, "tmp.xml"); // tmp.xml name for diagnostics Boris From pavelpgt at gmail.com Mon Jul 26 11:08:02 2010 From: pavelpgt at gmail.com (Pavel Pohanka) Date: Mon Jul 26 11:08:23 2010 Subject: [xsd-users] Sample code for GML creation? In-Reply-To: References: Message-ID: Thanks for your answer. Now I switched to CityGML (as you sugested ;)) and I am able to created an XML file with root element CityModel. But I am not able to put anything else to it. I can create building building::BuildingType b; b.id("Building#1"); b._name("Embassy"); But I don't know, how to incorporate it to XML. I would like to get such citygml xml file. Embassy 441935.836984 111587.590725 10.164845 441949.039878 111604.323501 17.14007 441947.976168 111587.590725 17.135723 441949.039878 111603.792466 17.135723 441936.624433 111604.323501 17.135723 441935.836984 111588.123909 17.14007 441947.976168 111587.590725 17.135723 Can I please ask you for a hint or some sample code how to make such xml? I very appreciate your help. Thanks. Pavel From boris at codesynthesis.com Tue Jul 27 10:45:24 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 27 10:38:44 2010 Subject: [xsd-users] Sample code for GML creation? In-Reply-To: References: Message-ID: Hi Pavel, Pavel Pohanka writes: > But I am not able to put anything else to it. I can create building > > building::BuildingType b; > b.id("Building#1"); > b._name("Embassy"); > But I don't know, how to incorporate it to XML. I would like to get such > citygml xml file. > > > > > > Embassy > As I mentioned in my previous email, the best way is to start from the root element and to study the generated code (or, better yet, the generated doxygen documentation). As a general rule, if you see a nested element, say cityObjectMember, directly inside an outer element, say CityModel, then there should be a set of functions in the outer element's type (CityModelType in our case) for this inner element. If I look through the generated CityModelType class, I see accessors/modifiers for a sequence of _GenericApplicationPropertyOfCityModel elements. The reason why cityObjectMember can appear in place of that element is because cityObjectMember is in the substitution group rooted at _GenericApplicationPropertyOfCityModel (this is one of the flavors of polymorphism in XML Schema). cityObjectMember is of the FeaturePropertyType type. So we create an instance of that type and add it to the sequence: CityModelType city_model (...); FeaturePropertyType city_object_member; city_model._GenericApplicationPropertyOfCityModel ().push_back ( city_object_member); We can apply the same reasoning to the cityObjectMember and Building elements: CityModelType city_model (...); FeaturePropertyType city_object_member; building::BuildingType b; b.id("Building#1"); b._name("Embassy"); city_object_member._Feature (b); city_model._GenericApplicationPropertyOfCityModel ().push_back ( city_object_member); And so on. Also, if you are not familiar with substitution groups in XML Schema, I suggest that you familiarize yourself with this mechanism since it is used extensively in GML/CityGML. Boris From pavelpgt at gmail.com Wed Jul 28 13:52:23 2010 From: pavelpgt at gmail.com (Pavel Pohanka) Date: Wed Jul 28 13:52:31 2010 Subject: [xsd-users] Sample code for GML creation? In-Reply-To: References: Message-ID: Thank you very much Boris. It helps me a lot. I was able to write an example XML file as ilustrated before. There is only one thing, that bothers me. Why the following code generates element instead of element (which I want to get) within element? CityModelType city_model; FeaturePropertyType city_object_member; city_model.featureMember().push_back(city_object_member); CityModel (ofs, city_model, map); When I use city_model._GenericApplicationPropertyOfCityModel().push_back(city_object_member); it generates <_GenericApplicationPropertyOfCityModel xsi:type="gml:FeaturePropertyType">. I can't figure it out, where could be mistake. Within building element is everything all right. Thank you for your great help. Pavel From mattia.db at gmail.com Fri Jul 30 09:26:59 2010 From: mattia.db at gmail.com (Mattia Donna Bianco) Date: Fri Jul 30 09:27:08 2010 Subject: [xsd-users] Problem with mixed content Message-ID: <4C52D323.1030109@gmail.com> Dear Boris, I'm Mattia Donna Bianco. I used Xsd for some time and it always worked. Currently I'm working on a LASeR project (a mpeg standard for richmedia). In the schema svg3.xsd I have this: When I write a xml file where there is a inside a , for example my text example there is no problem, but when I try to parse the file created previously XSD throws this exception: exception: xsd::cxx::tree::expected_text_content at memory location I'm using VS 2008 and XSD 3.3.0 on Windows 7. The schemas validate using the validation tool online provided by w3c (http://validate.openlaboratory.net/). The command I give are: xsd cxx-tree --generate-xml-schema --generate-serialization --generate-polymorphic XMLSchema.xsd and xsd cxx-tree --generate-wildcard --extern-xml-schema XMLSchema.hxx --generate-serialization --generate-polymorphic --file-per-type --namespace-map urn:mpeg:mpeg4:LASeR:types:2005=mxm_dataobject::laser --namespace-map http://www.w3.org/2000/svg=mxm_dataobject::laser::svg --namespace-map urn:mpeg:mpeg4:LASeR:2005=mxm_dataobject::laser --namespace-map urn:mpeg:mpeg4:LASeR:types:2005=mxm_dataobject::laser --namespace-map http://www.w3.org/2001/xml-events=mxm_dataobject::laser --namespace-map http://www.w3.org/XML/1998/namespace=mxm_dataobject::laser --namespace-map http://www.w3.org/1999/xlink=mxm_dataobject::laser --namespace-map http://www.w3.org/2005/SMIL21=mxm_dataobject::laser saf2.xsd This is the link to download the schemas: http://www.mediafire.com/?8o8sa3pp0grk373. Any helps will be appreciated. Thanks for the attention, best regards -- Mattia From boris at codesynthesis.com Fri Jul 30 10:20:52 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 30 10:14:05 2010 Subject: [xsd-users] Sample code for GML creation? In-Reply-To: References: Message-ID: Hi Pavel, Pavel Pohanka writes: > Why the following code generates element instead of > element (which I want to get) within > element? This has to do with how XML Schema polymorphism is implemented in the generated code. Both featureMember and cityObjectMember elements are of the same type (FeaturePropertyType) and belong to the same substitution group. When the generated code sees that the instance in the object model is of the FeaturePropertyType type, it looks for the first substituting element that it can use. This happens to be featureMember. The CityGML package from the Wiki includes an object model customization (see the xml-schema-custom.* files) that allows you to work around this problem. The idea is to provide a "hint" to the generate code where the default element choice is not what's desired. Here is how to use it: > CityModelType city_model; > FeaturePropertyType city_object_member; city_object_member._name ("cityObjectMember") city_object_member._namespace ("http://www.opengis.net/citygml/1.0"); Boris From boris at codesynthesis.com Fri Jul 30 10:41:42 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 30 10:34:54 2010 Subject: [xsd-users] Problem with mixed content In-Reply-To: <4C52D323.1030109@gmail.com> References: <4C52D323.1030109@gmail.com> Message-ID: Hi Mattia, Mattia Donna Bianco writes: > When I write a xml file where there is a inside a , for > example > > my text > example > > > there is no problem, How do you write this XML? If it is using the generated code, then you must have done something extra to support mixed content. Are you doing something similar to what is shown in the 'mixed' or 'custom/mixed' examples? > but when I try to parse the file created previously XSD throws > this exception: > > exception: xsd::cxx::tree::expected_text_content at memory location I checked the types involved in parsing this fragment and I don't see how they can trigger this exception. The exception is thrown only by the internal text_content() function that is only used to extract data for simple types like xs:string. And the type hierarchy involved does not inherit from a simple type. Is the exception thrown from the parsing code or is it perhaps your own code that calls text_content()? If it is thrown by the generated code, can you send a complete XML document that triggers this error so that I can try to reproduce it? Boris From mattia.db at gmail.com Fri Jul 30 11:27:42 2010 From: mattia.db at gmail.com (Mattia Donna Bianco) Date: Fri Jul 30 11:27:46 2010 Subject: [xsd-users] Problem with mixed content In-Reply-To: References: <4C52D323.1030109@gmail.com> Message-ID: <4C52EF6E.1000400@gmail.com> Hi Boris, I haven't done something extra to support mixed content and I write the xml file with the generated code. The exception is thrown from the parsing code (the generated code not mine), to be precise in the file text.txx. Here is the complete XML file that generates the exception: http://www.mediafire.com/?p5t1w7k587qc7d4 Thanks, Mattia Il 30/07/2010 16:41, Boris Kolpackov ha scritto: > Hi Mattia, > > Mattia Donna Bianco writes: > >> When I write a xml file where there is a inside a, for >> example >> >> my text >> example >> >> >> there is no problem, > > How do you write this XML? If it is using the generated code, then > you must have done something extra to support mixed content. Are > you doing something similar to what is shown in the 'mixed' or > 'custom/mixed' examples? > > >> but when I try to parse the file created previously XSD throws >> this exception: >> >> exception: xsd::cxx::tree::expected_text_content at memory location > > I checked the types involved in parsing this fragment and I don't > see how they can trigger this exception. The exception is thrown only > by the internal text_content() function that is only used to extract > data for simple types like xs:string. And the type hierarchy involved > does not inherit from a simple type. Is the exception thrown from > the parsing code or is it perhaps your own code that calls > text_content()? > > If it is thrown by the generated code, can you send a complete XML > document that triggers this error so that I can try to reproduce it? > > Boris