From jnw at xs4all.nl Sat Dec 1 06:41:16 2007 From: jnw at xs4all.nl (Jeroen N. Witmond [Bahco]) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] cxx-parser: Not all attributes in the XML namespace are typemapped. Message-ID: <11848.194.109.230.85.1196509276.squirrel@webmail.xs4all.nl> Greetings, When I apply xsd cxx-parser (3.0.0 or later) with the following typemap the types are applied to lang and space, but not to base and id. The latter remain ::std::string. namespace "http://www.w3.org/XML/1998/namespace" XMLnamespace { include "XMLnamespace.hpp"; base base; id id; lang lang; space space; } When I looked deeper, I noticed more samples of different treatment of these pairs of attributes, also when no typemaps are involved. My guess is that this is related to the difference in their definition. Attributes lang and space are (anonymous) simpleTypes, where base and id are xs:anyUri resp. xs:ID. Is this expected behavior of xsd cxx-parser? Regards, Jeroen. From boris at codesynthesis.com Sun Dec 2 06:47:14 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] cxx-parser: Not all attributes in the XML namespace are typemapped. In-Reply-To: <11848.194.109.230.85.1196509276.squirrel@webmail.xs4all.nl> References: <11848.194.109.230.85.1196509276.squirrel@webmail.xs4all.nl> Message-ID: <20071202114714.GA15011@karelia> Hi Jeroen, Jeroen N. Witmond [Bahco] writes: > Attributes lang and space are (anonymous) simpleTypes, where base > and id are xs:anyUri resp. xs:ID. > > Is this expected behavior of xsd cxx-parser? Yes, type maps are mapping types, not attributes or elements. If you want the base and id attributes to be represented by your own C++ types, then you will need to re-map xs:anyUri and xs:ID (and by doing this you will also make other attributes/elements that are of these built-in types to use your custom C++ types). Boris From amnon.janiv at lehman.com Tue Dec 4 21:48:34 2007 From: amnon.janiv at lehman.com (Janiv, Amnon) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] How to create custom accessors/setters/getters Message-ID: <6B749DA83016BD4BAE56E7388331A6970D371E33@njpcmg1exms305.leh.lbcorp.lehman.com> Hi, What is the best way to have custom set and get functions for attributes generated by xsd? This is required for backward compatibility, and I would to have the accessors generated automatically. Instead of: virtual void greeting (const ::std::string&); I would like: setGreeting (const ::std::string&); Thanks Amnon - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -------- IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. From Charles.Ruhs at scientificgames.com Tue Dec 4 19:24:18 2007 From: Charles.Ruhs at scientificgames.com (Ruhs, Charles) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Attributes Message-ID: <9881A8B5D92D1541A2679A69A349FDCE0B8A6968@USALPEVS01.sgi.net> I've implemented a CXX\Parser using the XSD 3.0 version and am trying to get attributes to work within this construct. What I need to know is do attributes need a different type of Parser Pointers? Right now I'm using xml_schema::string_pimpl as the parser pointer for the two attributes that I have in my xml file. The file is set up correctly according to the schema as best I can tell. Any help would be appreciated. _________________________________ Charles Ruhs 1500 Bluegrass Lakes Parkway Alpharetta, GA 30004 Work: 678-624-4290 Cell: 404-435-7805 This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation. From boris at codesynthesis.com Wed Dec 5 06:03:17 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Attributes In-Reply-To: <9881A8B5D92D1541A2679A69A349FDCE0B8A6968@USALPEVS01.sgi.net> References: <9881A8B5D92D1541A2679A69A349FDCE0B8A6968@USALPEVS01.sgi.net> Message-ID: <20071205110317.GB9125@karelia> Hi Charles, Ruhs, Charles writes: > I've implemented a CXX\Parser using the XSD 3.0 version and am trying to > get attributes to work within this construct. What I need to know is do > attributes need a different type of Parser Pointers? No, the C++/Parser mapping treats attributes and elements pretty much the same. > Right now I'm using xml_schema::string_pimpl as the parser pointer > for the two attributes that I have in my xml file. The file is set > up correctly according to the schema as best I can tell. I can think of two ways to figure out what's going on. First, you can try to generate a sample implementation and a test driver for your schema and, provided it prints the attributes your are interested in, see what you are doing differently. To generate the sample implementation that prints the data and the test driver, use the --generate-print-impl and --generate-test-driver options. The second option is for your to send a small example that reproduces the problem and we will try to figure out what's going on. Boris From boris at codesynthesis.com Wed Dec 5 06:16:21 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] How to create custom accessors/setters/getters In-Reply-To: <6B749DA83016BD4BAE56E7388331A6970D371E33@njpcmg1exms305.leh.lbcorp.lehman.com> References: <6B749DA83016BD4BAE56E7388331A6970D371E33@njpcmg1exms305.leh.lbcorp.lehman.com> Message-ID: <20071205111621.GC9125@karelia> Hi Amnon, Janiv, Amnon writes: > What is the best way to have custom set and get functions for attributes > generated by xsd? This is required for backward compatibility, and I > would to have the accessors generated automatically. > > Instead of: > virtual void > greeting (const ::std::string&); > > I would like: > setGreeting (const ::std::string&); There is a new feature that is implemented for the next release of XSD that allows you to choose type/function naming conventions. In your case all you will need to do is add the '--function-naming java' option to the XSD command line. There is a pre-release binary with this feature available for GNU/Linux: http://codesynthesis.com/~boris/tmp/xsd-3.1.0.a3-i686-linux-gnu.tar.bz2 If you need a binary for a different OS, please let me know. For more information on the new naming convention options, see the NAMING CONVENTION section in the XSD Compiler Command Line Manual which can be found in the documentation/ directory in the above distribution as either xsd.xhtml (HTML) or xsd.1 (man pages). Boris From Charles.Ruhs at scientificgames.com Wed Dec 5 10:52:01 2007 From: Charles.Ruhs at scientificgames.com (Ruhs, Charles) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Attributes In-Reply-To: <20071205110317.GB9125@karelia> Message-ID: <9881A8B5D92D1541A2679A69A349FDCE0B8A6C07@USALPEVS01.sgi.net> Thanks for the quick reply. I spent about 4 hours on this only to realize I forgot to copy the XSD to the release folder. It was using an old schema to validate the new code. Charlie _________________________________ Charles Ruhs 1500 Bluegrass Lakes Parkway Alpharetta, GA 30004 Work: 678-624-4290 Cell: 404-435-7805 -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, December 05, 2007 6:03 AM To: Ruhs, Charles Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Attributes Hi Charles, Ruhs, Charles writes: > I've implemented a CXX\Parser using the XSD 3.0 version and am trying to > get attributes to work within this construct. What I need to know is do > attributes need a different type of Parser Pointers? No, the C++/Parser mapping treats attributes and elements pretty much the same. > Right now I'm using xml_schema::string_pimpl as the parser pointer > for the two attributes that I have in my xml file. The file is set > up correctly according to the schema as best I can tell. I can think of two ways to figure out what's going on. First, you can try to generate a sample implementation and a test driver for your schema and, provided it prints the attributes your are interested in, see what you are doing differently. To generate the sample implementation that prints the data and the test driver, use the --generate-print-impl and --generate-test-driver options. The second option is for your to send a small example that reproduces the problem and we will try to figure out what's going on. Boris This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation. From techlane64 at gmail.com Fri Dec 7 12:07:37 2007 From: techlane64 at gmail.com (Lane Wimberley) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] KML schema namespace problem Message-ID: I am new to this list, and new to XML schema and the Code Synthesis tools, so please forgive me if this question is inappropriate or seems silly. I am really impressed with the xsd tools. So far, I've had great success with compiling my own schemata. But, recently I wanted to see if I could compile Google's KML schema ( http://code.google.com/apis/kml/schema/kml21.xsd). Initially, I tried ... $ xsd cxx-tree --generate-polymorphic --root-element kml kml21.xsd But, this produces ... kml21.xsd:7:37: error: unable to map XML Schema namespace ' http://earth.google.com/kml/2.1' to C++ namespace kml21.xsd:7:37: info: use the --namespace-map or --namespace-regex option to provide custom mapping On a whim, I attempted ... xsd cxx-tree --generate-polymorphic --root-element --namespace-regex http://earth.google.com/kml/2.1=foo::bar kml kml21.xsd ...and the result was... http://earth.google.com/kml/2.1=foo::bar: error: ' http://earth.google.com/kml/2.1=foo::bar': unable to open in read mode As I indicated, I'll be the first to admit that I know next to nothing about how namespaces work. I've been reading the XML schema documentation in an attempt to educate myself about namespaces and what this problem might be, but to no avail. Any clues about how to resolve this problem MUCH appreciated! -Lane Wimberley Zebra Imaging Austin, TX From boris at codesynthesis.com Fri Dec 7 13:13:21 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] KML schema namespace problem In-Reply-To: References: Message-ID: <20071207181321.GB25998@karelia> Hi Lane, Lane Wimberley writes: > On a whim, I attempted ... > > xsd cxx-tree --generate-polymorphic --root-element --namespace-regex > http://earth.google.com/kml/2.1=foo::bar kml kml21.xsd You almost got it right: you just need to use --namespace-map instead of --namespace-regex. The following command lines worked for me: xsd cxx-tree --root-element kml --generate-polymorphic --namespace-map http://earth.google.com/kml/2.1=kml kml21.xsd xsd cxx-tree --root-element kml --generate-polymorphic --namespace-map http://earth.google.com/kml/2.1=kml_2_1 kml21.xsd Boris From techlane64 at gmail.com Fri Dec 7 14:56:36 2007 From: techlane64 at gmail.com (Lane Wimberley) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] KML schema namespace problem In-Reply-To: <20071207181321.GB25998@karelia> References: <20071207181321.GB25998@karelia> Message-ID: Superb! Thanks so much! -Lane On Dec 7, 2007 1:13 PM, Boris Kolpackov wrote: > Hi Lane, > > Lane Wimberley writes: > > > On a whim, I attempted ... > > > > xsd cxx-tree --generate-polymorphic --root-element --namespace-regex > > http://earth.google.com/kml/2.1=foo::bar kml kml21.xsd > > You almost got it right: you just need to use --namespace-map instead > of --namespace-regex. The following command lines worked for me: > > xsd cxx-tree --root-element kml --generate-polymorphic --namespace-map > http://earth.google.com/kml/2.1=kml kml21.xsd > > xsd cxx-tree --root-element kml --generate-polymorphic --namespace-map > http://earth.google.com/kml/2.1=kml_2_1 kml21.xsd > > > Boris > From rmanwani at tpcsed.com Wed Dec 12 04:16:15 2007 From: rmanwani at tpcsed.com (rmanwani@tpcsed.com) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] instance document parsing failed Message-ID: <200712120916.lBC9GFWi015813@mum.tpcsed.com> Sir, This is my first effort at using XSD for my own classes ( not available in examples ). I have been able to generate the .cxx, .hxx files using xsd application but when I run the driver, I get the following error : terminate called after throwing an instance of 'xsd::cxx::tree::parsing' what(): instance document parsing failed Aborted I have attached .xsd, .xml, .hxx and driver source code for your reference. Please guide me on above error. How can I resolve it? Regards, Rajesh G Manwani. -------------- next part -------------- A non-text attachment was scrubbed... Name: Filter.xsd Type: application/octet-stream Size: 2586 bytes Desc: Filter.xsd Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20071212/44a2d6b5/Filter.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: Filter.xml Type: text/xml Size: 1614 bytes Desc: Filter.xml Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20071212/44a2d6b5/Filter.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: Filter.hxx Type: application/octet-stream Size: 29389 bytes Desc: Filter.hxx Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20071212/44a2d6b5/Filter-0001.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: FilterDriver.cxx Type: application/octet-stream Size: 737 bytes Desc: FilterDriver.cxx Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20071212/44a2d6b5/FilterDriver.obj From boris at codesynthesis.com Wed Dec 12 04:37:38 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] instance document parsing failed In-Reply-To: <200712120916.lBC9GFWi015813@mum.tpcsed.com> References: <200712120916.lBC9GFWi015813@mum.tpcsed.com> Message-ID: <20071212093738.GA24199@karelia> Hi Rajesh, rmanwani@tpcsed.com writes: > terminate called after throwing an instance of 'xsd::cxx::tree::parsing' > what(): instance document parsing failed > Aborted If you catch and print xml_schema::exception (see any example on how to do this), you will get a more descriptive error message, something along the "Unknown element ..." lines. For the possible causes of this error and various solutions, see the C++/Tree Mapping FAQ, Q2.1: http://wiki.codesynthesis.com/Tree/FAQ Boris From tmaenner at aehr.com Wed Dec 12 21:04:18 2007 From: tmaenner at aehr.com (Thomas Maenner) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Howto to use an attribute as an index to a sequence Message-ID: <200712121804.18439.tmaenner@aehr.com> Hi Boris, I'd like to use unsigned int attributes as an index or key into a sequence. Basically, I'd like to use the attribute "unIndex" in something like this (See xsd and xml files below): ---snip--- test_root::node_sequence& ns( t->node() ); for( unsigned int i=0; i < ns.size(); i++ ) { cout << i << ": " << ns[i].strTest() << endl; } ---snip--- The output should be: 0: String0 1: String2 2: String1 and not: 0: String0 1: String1 2: String2 Would this be possible? If so, I'm just too blind to see it... ;) Thanks much in advance for your help Tom ------------------------------------------------------ Comment describing your root element String0 -100 0 String1 -10 10 String2 -20 20 -- Thomas Maenner E-Mail: mailto:tmaenner@aehr.com From boris at codesynthesis.com Wed Dec 12 23:23:18 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Howto to use an attribute as an index to a sequence In-Reply-To: <200712121804.18439.tmaenner@aehr.com> References: <200712121804.18439.tmaenner@aehr.com> Message-ID: <20071213042318.GD24199@karelia> Hi Thomas, Thomas Maenner writes: > The output should be: > 0: String0 > 1: String2 > 2: String1 > and not: > 0: String0 > 1: String1 > 2: String2 This code should do it: test_root::node_sequence& ns( t->node() ); for( unsigned int i=0; i < ns.size(); i++ ) { nodeType& n (ns[i]); unsigned int j = n.unIndex ().present () ? n.unIndex ().get () : i; cout << i << ": " << ns[j].strTest() << endl; } Or the same using the pointer notation: unsigned int j = n.unIndex () ? *n.unIndex () : i; Boris From tmaenner at aehr.com Wed Dec 12 23:44:02 2007 From: tmaenner at aehr.com (Thomas Maenner) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Howto to use an attribute as an index to a sequence In-Reply-To: <20071213042318.GD24199@karelia> References: <200712121804.18439.tmaenner@aehr.com> <20071213042318.GD24199@karelia> Message-ID: <200712122044.02929.tmaenner@aehr.com> Ha... cool... seems to work - Thanks! You're up early... Cheers Tom On Wednesday 12 December 2007, Boris Kolpackov wrote: > Hi Thomas, > > Thomas Maenner writes: > > The output should be: > > 0: String0 > > 1: String2 > > 2: String1 > > and not: > > 0: String0 > > 1: String1 > > 2: String2 > > This code should do it: > > test_root::node_sequence& ns( t->node() ); > for( unsigned int i=0; i < ns.size(); i++ ) > { > nodeType& n (ns[i]); > > unsigned int j = n.unIndex ().present () ? n.unIndex ().get () : i; > > cout << i << ": " << ns[j].strTest() << endl; > } > > Or the same using the pointer notation: > > unsigned int j = n.unIndex () ? *n.unIndex () : i; > > Boris -- Thomas Maenner E-Mail: mailto:tmaenner@aehr.com From sbalasub at qualcomm.com Thu Dec 13 16:55:31 2007 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Schema Validation In-Reply-To: <20071026210130.GC29001@karelia> References: <20071026193707.GB29001@karelia> <20071026210130.GC29001@karelia> Message-ID: Boris, The use case below worked as long as I have only one schema file that had a unique namespace. In our case, we have multiple schemas which has same target namespace. How do we solve this case? When I tried, I think it overwrote the mapping information. It is possible to register multiple schema files for same namespace? Thanks, Shiva -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Friday, October 26, 2007 2:02 PM To: Balasubramanyam, Shivakumar Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Schema Validation Hi Shiva, Balasubramanyam, Shivakumar writes: > Let's say, I have the schemas in > > /opt/schemas/namespace1/namespace2/schemafile1.xsd > > /opt/schemas/namespace1/namespace2/schemafile2.xsd > > And the XML document contains > http://someurl/namespace1/namespace2/schemafile1.xsd > > How do I pass this information to xsd/tree parser? Let's say schemafile1.xsd is in the http://www.example.com/namespace1 namespace and schemafile2.xsd is in http://www.example.com/namespace2. Then you can do the following: xml_schema::properties props; props.schema_location ( "http://www.example.com/namespace1", "file:////opt/schemas/namespace1/namespace2/schemafile1.xsd"); props.schema_location ( "http://www.example.com/namespace2", "file:////opt/schemas/namespace1/namespace2/schemafile2.xsd"); root ("file.xml", 0, props); Here 'root' is the parser function for the document root. Note that the above schema location properties override the schema location information specified in the XML documents. Boris From sbalasub at qualcomm.com Thu Dec 13 20:12:49 2007 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Schema Validation In-Reply-To: References: <20071026193707.GB29001@karelia><20071026210130.GC29001@karelia> Message-ID: Boris, I used the alternative you mentioned in the email and available in test program (examples/xsd/tree/caching), which works great so far. The XSD's have the namespaces and also I have to specify only the physical location to the schema file. However, I am curious why Code Synthesis is not supporting this scheme. For instance, in Code Synthesis, if I use schemaLocation in schemas, then I could not find a way to validate without specifying the mapping of namespaces to physical schema files. Am I missing something? Thanks, Shiva -----Original Message----- From: xsd-users-bounces@codesynthesis.com [mailto:xsd-users-bounces@codesynthesis.com] On Behalf Of Balasubramanyam, Shivakumar Sent: Thursday, December 13, 2007 1:56 PM To: Boris Kolpackov Cc: xsd-users@codesynthesis.com Subject: RE: [xsd-users] Schema Validation Boris, The use case below worked as long as I have only one schema file that had a unique namespace. In our case, we have multiple schemas which has same target namespace. How do we solve this case? When I tried, I think it overwrote the mapping information. It is possible to register multiple schema files for same namespace? Thanks, Shiva -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Friday, October 26, 2007 2:02 PM To: Balasubramanyam, Shivakumar Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Schema Validation Hi Shiva, Balasubramanyam, Shivakumar writes: > Let's say, I have the schemas in > > /opt/schemas/namespace1/namespace2/schemafile1.xsd > > /opt/schemas/namespace1/namespace2/schemafile2.xsd > > And the XML document contains > http://someurl/namespace1/namespace2/schemafile1.xsd > > How do I pass this information to xsd/tree parser? Let's say schemafile1.xsd is in the http://www.example.com/namespace1 namespace and schemafile2.xsd is in http://www.example.com/namespace2. Then you can do the following: xml_schema::properties props; props.schema_location ( "http://www.example.com/namespace1", "file:////opt/schemas/namespace1/namespace2/schemafile1.xsd"); props.schema_location ( "http://www.example.com/namespace2", "file:////opt/schemas/namespace1/namespace2/schemafile2.xsd"); root ("file.xml", 0, props); Here 'root' is the parser function for the document root. Note that the above schema location properties override the schema location information specified in the XML documents. Boris From matt.burnham.ctr at mhpcc.hpc.mil Thu Dec 13 16:42:06 2007 From: matt.burnham.ctr at mhpcc.hpc.mil (Matt Burnham) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] using --include-regex within VisualStudio Command Line Message-ID: <4761A72E.7090305@mhpcc.hpc.mil> I have a schema (main.xsd) that includes another schema: This originally produced the following: #include "../../foo/schemas/test.hxx" I want to use --include-regex to remove the schemas directory from the path so I use: --include-regex %foo/schemas%foo% I am using XSD version 3.0 on Windows XP and run xsd within VisualStudio (v7) using a "Custom Build Step" with the following "Command Line": xsd.exe cxx-tree --include-regex %foo/schemas%foo% --include-regex-trace main.xsd Instead of the expected results I get: #include "../../f/schemas/test.hxx" If I run the same command line from a command prompt, I get the expected results. I'm confused. :-( Any ideas? - matt From boris at codesynthesis.com Fri Dec 14 01:17:40 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] using --include-regex within VisualStudio Command Line In-Reply-To: <4761A72E.7090305@mhpcc.hpc.mil> References: <4761A72E.7090305@mhpcc.hpc.mil> Message-ID: <20071214061740.GA18549@karelia> Hi Matt, Matt Burnham writes: > I am using XSD version 3.0 on Windows XP and run xsd within VisualStudio > (v7) using a "Custom Build Step" with the following "Command Line": > xsd.exe cxx-tree --include-regex %foo/schemas%foo% > --include-regex-trace main.xsd I think in the VC command lines %foo% denotes environment variable expansion. Try to chance %foo/schemas%foo% to #foo/schema#foo#. If that still does not work, try to add quotes: "#foo/schema#foo#" (in the .vcproj file it should look like "#foo/schema#foo#"). Boris From boris at codesynthesis.com Fri Dec 14 02:41:13 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Schema Validation In-Reply-To: References: Message-ID: <20071214074113.GB18549@karelia> Hi Shiva, Balasubramanyam, Shivakumar writes: > I used the alternative you mentioned in the email and available in test > program (examples/xsd/tree/caching), which works great so far. > > The XSD's have the namespaces and also I have to specify only the > physical location to the schema file. If by "works" you mean that it allows you to load more than one schema with the same target namespace, then I am afraid you are mistaken. The loadGrammar function uses target namespace as a key to determine whether a schema for this namespace is already available (see below). So if you try to load more than one schema with the same target namespace, all schemas except the first will be ignored. > However, I am curious why Code Synthesis is not supporting this scheme. > > For instance, in Code Synthesis, if I use schemaLocation in schemas, > then I could not find a way to validate without specifying the mapping > of namespaces to physical schema files. Most XML Schema processors (in fact I am not aware of any processor that uses a more elaborate approach) use target namespaces as keys in their schema repositories to identify and ignore subsequent references to the same schemas. This mechanism is used for both referencing schemas from XML documents as well as importing one schema into another. Note also that this is what the spec is prescribing. In case of the schemLocation attributes, see Section 4.3.2, "How schema definitions are located on the Web" sub-section "Schema Representation Constraint: Schema Document Location Strategy": http://www.w3.org/TR/xmlschema-1/#schema-loc As a result, and this is a well known "best practice", you need to have an "entry point" schema for a particular target namespace which should bring in all type and element declarations for this namespace. You would then use this root schema in XML documents, xsd:import's, etc. It is often tempting (as is probably the case in your situation) to "optimize" by referencing only the necessary declarations from a particular XML document. You normally can achieve this by creating smaller "entry point" schemas which include all the necessary declarations for various document classes but remember that it should always be one schema per namespace. If you do not want to (or cannot) create any extra schema files, then you can create an "entry point" schema in memory dynamically and then use loadGrammar to load all the necessary declarations (if it is likely that your application will need all declarations during its execution, then it make sense to load all declarations from the beginning). Using the example from the previous emails, let's say we have two schema files schemafile1.xsd and schemafile2.xsd both with target namespace http://www.example.com/namespace. We can manually create an entry point schema and then use loadGrammar or schema location properties to load it: Alternatively, we can create the entry point schema on the fly ( C++ namespaces are assumed to be as in the caching example): std::string entry_schema ( "\n" " \n" " \n" ""); std::istringstream istr (entry_schema); xml::sax::std_input_source isrc (istr, "entry-schema.xsd"); Wrapper4InputSource wrap (&isrc, false); parser->loadGrammar (wrap, Grammar::SchemaGrammarType, true); Boris From rmanwani at tpcsed.com Thu Dec 20 00:49:39 2007 From: rmanwani at tpcsed.com (rmanwani@tpcsed.com) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] (no subject) Message-ID: <200712200549.lBK5ndsY005767@mum.tpcsed.com> Hi, I have just started using XSD. I was experimenting with ability of XSD to serialize an object. I have looked at libxml example given to understand the same. I copied some code from the example to my source files. While I compile, the compiler is unable to identify the classes XmlManager, XmlDocument, DOMDocument. The piece of code is given below: XmlManager manager; XmlDocument doc(manager.CreateDocument()); doc.setname("FilterObject.xml"); // Obtain DOM representation xerces::DOMDocument &dom_doc (*doc.getContentsAsDOM()); filterscreenclass_(dom_doc,*c,map); I have gone through the entire package offered by XSD but I am unable to locate definition for these classes in any of the header files included. Also, the header file DbXml.hpp mentioned in driver.cxx of dbxml could not be located anywhere. I do not know if I am looking at entire source code properly or not. I will be thankful I somebody can help me out to resolve this issue. Regards, Rajesh G Manwani From xunich at gmail.com Thu Dec 20 05:59:54 2007 From: xunich at gmail.com (Nicholas Xu) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] naming conflict Message-ID: Hello , I met a problem when I work with xsd generated codes. I have a schema which contains a recursion, let's say, a 'list' element contains a sequence of 'list's. XSD generates a listType class which has several list methods (setter and getter), at the same time, another class 'list' which inherits the listType. The problem is when I call list method an instance of a list object, my code cannot compile, the same name confuses the compiler. Is there a way to change the name convention of generated methods, or is there a C++ trick to solve the problem? I work with windows version of xsd (cxx-tree) mode. Thanks. Xu From boris at codesynthesis.com Thu Dec 20 07:04:54 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] naming conflict In-Reply-To: References: Message-ID: <20071220120454.GB9842@karelia> Hi Nicholas, Nicholas Xu writes: > I met a problem when I work with xsd generated codes. I have a schema > which contains a recursion, let's say, a 'list' element contains a > sequence of 'list's. XSD generates a listType class which has several > list methods (setter and getter), at the same time, another class > 'list' which inherits the listType. My understanding of the problem from your description above is as follows: struct base { void list (); }; struct list: base { }; void f () { list l; l.list (); // error } > Is there a way to change the name convention of generated methods, or > is there a C++ trick to solve the problem? The C++ trick to resolve the above error is this: l.base::list (); That is, you need to qualify the 'list' name. As for the naming convention, there will be a way to change it in the next release. If you would like, you can also try it now with pre- release binaries which are available for Windows and GNU/Linux: http://codesynthesis.com/~boris/tmp/xsd-3.1.0.a5-i686-windows.zip http://codesynthesis.com/~boris/tmp/xsd-3.1.0.a5-i686-linux-gnu.tar.bz2 For the naming convention options, see the NEWS file in the above distributions. Boris From boris at codesynthesis.com Thu Dec 20 07:19:17 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Berkeley DB XML example In-Reply-To: <200712200549.lBK5ndsY005767@mum.tpcsed.com> References: <200712200549.lBK5ndsY005767@mum.tpcsed.com> Message-ID: <20071220121917.GC9842@karelia> Hi Rajesh, rmanwani@tpcsed.com writes: > I have just started using XSD. I was experimenting with ability of XSD > to serialize an object. I have looked at libxml example given to > understand the same. You mean the dbxml example, right? There is no example named libxml in the XSD distribution. > I copied some code from the example to my source files. While I compile, > the compiler is unable to identify the classes XmlManager, XmlDocument, > DOMDocument. The piece of code is given below: > > XmlManager manager; > XmlDocument doc(manager.CreateDocument()); > doc.setname("FilterObject.xml"); > > // Obtain DOM representation > > xerces::DOMDocument &dom_doc (*doc.getContentsAsDOM()); > filterscreenclass_(dom_doc,*c,map); > > I have gone through the entire package offered by XSD but I am unable > to locate definition for these classes in any of the header files > included. Also, the header file DbXml.hpp mentioned in driver.cxx of > dbxml could not be located anywhere. The dbxml example shows how to use the C++/Tree mapping on top of the Berkeley DB XML database (see the README file in the dbxml directory for details). As a result you need to have Berkeley DB XML installed before you can build the dbxml example or your own code that uses DB XML. The DbXml.hpp header file is provided by Berkeley DB XML. For more information and to download Berkeley DB XML, see: http://www.oracle.com/database/berkeley-db/xml/index.html Now, if all you want is to serialize an object to XML in a file or an in-memory string as opposed to an XML store managed by Berkeley DB XML, then a better example would be 'library'. Also this topic is covered in detail in the C++/Tree Getting Started Guide, Chapter 2, Section 2.5, "Adding Serialization" and in Chapter 6, "Serialization": http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/ Boris From dabee21 at gmail.com Thu Dec 20 07:38:47 2007 From: dabee21 at gmail.com (=?ISO-8859-2?Q?Miros=B3aw_Madej?=) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Courious question Message-ID: <507fc4d50712200438v46f1d4d0i349a121de51f3e6c@mail.gmail.com> I try tu use xsd cxx-tree but I have same problems. I know that generally we shoud use xsd this way: 1) we genereta source files from xsd files wich is call databinding 2) we use this code in our aplications 3) and we runs it for example ./main file.xml Now my question is: When we generate code from xsd file is this file still used when we launch ./main file.xml?? (./main - this is our program) I mean do we use that xsd file only when we generate code (wich is comand xsd cxx-tree file.xsd) ?? -- Mirek Madej From boris at codesynthesis.com Thu Dec 20 07:39:59 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Courious question In-Reply-To: <507fc4d50712200438v46f1d4d0i349a121de51f3e6c@mail.gmail.com> References: <507fc4d50712200438v46f1d4d0i349a121de51f3e6c@mail.gmail.com> Message-ID: <20071220123959.GE9842@karelia> Hi Mirek, Miroslaw Madej writes: > When we generate code from xsd file is this file still used when we > launch ./main file.xml?? (./main - this is our program) This file is used by the underlying XML parser (Xerces-C++) to perform schema validation if validation in the underlying parser is not disabled. If validation is disabled then the schema file is not used. Section 5.1, "XML Schema Validation and Searching" from the C++/Tree Mapping Getting Started Guide has more information on enabling/disabling validation as well as on various ways to provide the schema file to the underlying XML parser during execution: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#5.1 Boris From dabee21 at gmail.com Thu Dec 20 08:12:32 2007 From: dabee21 at gmail.com (=?ISO-8859-2?Q?Miros=B3aw_Madej?=) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Same simple files Message-ID: <507fc4d50712200512o72b3ff77y981d421b27c0acbd@mail.gmail.com> Thx for fast answer! I switched off this parsing by adding: xml_schema::flags::dont_validate and I have less errors. But still I don't understand why with parsing enabled program throws that my sample xml file don't have any of declarated in schema elements and atributes. And with parsing disabled it throws only one not importand problem. I think that the simplest reason is that I have bad xml sample file. So now I'm looking for simple program where I can give it xml and xsd files and check If my xml file is good. (I'm running Gentoo Linux ) I send You my files so You can see if they are good. -- Mirek Madej -------------- next part -------------- A non-text attachment was scrubbed... Name: swiad.xml Type: text/xml Size: 1594 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20071220/46a7a1bc/swiad.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: swx.xsd Type: application/octet-stream Size: 31417 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20071220/46a7a1bc/swx.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: swx_nfz.xsd Type: application/octet-stream Size: 11594 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20071220/46a7a1bc/swx_nfz.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: typy_danych.xsd Type: application/octet-stream Size: 16214 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20071220/46a7a1bc/typy_danych.obj From boris at codesynthesis.com Thu Dec 20 08:30:36 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Same simple files In-Reply-To: <507fc4d50712200512o72b3ff77y981d421b27c0acbd@mail.gmail.com> References: <507fc4d50712200512o72b3ff77y981d421b27c0acbd@mail.gmail.com> Message-ID: <20071220133036.GF9842@karelia> Hi Mirek, Miroslaw Madej writes: > But still I don't understand why with parsing enabled program throws that > my sample xml file don't have any of declarated in schema elements and > atributes. See Q 2.1 in the C++/Tree Mapping FAQ: http://wiki.codesynthesis.com/Tree/FAQ > So now I'm looking for simple program where I can give it xml and xsd > files and check If my xml file is good. (I'm running Gentoo Linux ) You can use the DOMCount example that comes with Xerces-C++. I tried to run it on your sample XML and got an error saying that the windows- 1250 encoding (used in your XML) is not supported by my build. I suggest that you convert your XML to something more portable (e.g., UTF-8) or build Xerces-C++ with ICU to get support for this encoding. Boris From dabee21 at gmail.com Thu Dec 20 11:15:53 2007 From: dabee21 at gmail.com (=?ISO-8859-2?Q?Miros=B3aw_Madej?=) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] Possible answer Message-ID: <507fc4d50712200815v30028adcsf3c89eab89ee521@mail.gmail.com> In previous posts You gave me same advices, and now I think I now what is my problem. When I have enabled xml_schema::flags::validate I have many errors because as You said parser can't find my schema files. And propably this is the main reason because I don't have in my xml files this: xsi:schemaLocation='' or xsi:noSchemaLocation='' so my parser really can't find schema files. -- Mirek Madej From rutgeraldo at gmail.com Fri Dec 21 02:53:42 2007 From: rutgeraldo at gmail.com (Rutger Vos) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] schema => simple print program, need walkthrough Message-ID: <2bb9b24a0712202353w21ea09c1ya9b9f5af01391896@mail.gmail.com> Dear list members, I sense this is going to be a long email, so here's the executive summary: I have a large-ish modular schema and I'd like to use the codesynthesis xsd tool (from now csxsd) to create a simple proof-of-concept program that, given a valid instance document, will print out its contents - or in any case some sort of sign of life to indicate the mappings are working. I'm looking for some help to get this done. Okay, here's the long version: my endeavor is hampered by two problems: i) I'm new to csxsd; ii) I don't know C++. I realize that the latter is a rather big problem and I don't expect you to help me with that, but I gather from what I've read so far that csxsd can generate just the sort of simple read => print example program I'm after without me having to write (a lot of) code. Also, I do have experience with C (not so much, that, though) and Java, so the syntax isn't entirely alien and I understand the general principles of OO and type-mapping. The schema I'm working with is this one: http://www.nexml.org/nexml/xsd/ . The general requirements of the schema are community-driven, but I'm the main designer, and I'm quite willing to make (small, syntactical) changes if that helps csxsd. The "root" file of the schema is nexml.xsd, which does a number of includes (and some of the files it pulls in do so as well, recursively), which all have the same targetNamespace. In fact, here is a clickable image map that shows the inclusions: http://www.nexml.org/nexml/html/doc/schema-1/nexml/inclusions/ In addition, it does a number of imports, specifically so that instance documents can have some of the standard xml attributes (xml:id, xml:lang, xml:base, xml:space) and xlink attributes (xlink:href). Lastly about the general schema design: it's "venetian blinds", one root element, otherwise all named complexTypes and simpleTypes and it uses polymorphism in instance documents (i.e. xsi:type="nex:SomeSubclass" attributes on a number of elements). Here are some example files: http://nexml-dev.nescent.org/nexml/examples/ (e.g. look at characters.xml) Because I've been using the oxygen plugin for eclipse (which complains every time there's something wrong in the schema, using Xerces-J) and are able to generate xmlbeans using apache's tools for java I conclude that the schema is more or less sane and that what I'm trying to do is possible. Now, I've been trying to turn the schema into C++ source files and headers, create a driver, then compile everything. The idea is that I may be able to show my C++-coding colleagues that csxsd might be worth their while. Anyway, I ran into a number of snags, so here's what I've learned so far: * csxsd doesn't download remote schema files, so I've downloaded the schemas I import (the xml and xlink namespaces) and reference them locally, they're in the external/ folder. * csxsd doesn't follow inclusions itself, you need to tell it explicitly from which schema files to generate code * csxsd - or actually gcc when I try to compile - doesn't like cycles in schema inclusions (and hence generated code?), so I've broken them to create an acyclic inclusion tree * csxsd doesn't like the http://www.nexml.org/1.0 namespace, so I need to declare a namespace mapping * because of the xsi:type polymorphism I need to generate polymorphic bindings With those things taken into account, I generate code as follows: * I make a list of all schema files I will be working with, i.e. in shell I do files=$(find . -name "*.xsd") out of which I "grep -v" the files that aren't reached by the inclusions starting from nexml.xsd (e.g. the "draft1" folder) * because the schema files are organized in a folder structure (see inclusions graph) I assume I will be happiest if the generated code ends up in a similar folder structure, so I loop over each $file in $files and modify the string to get $outdir, such that for file ./characters/dna.xsd $outdir is characters/ * I then run csxsd for each schema file with the following incantation: ./xsd cxx-tree --namespace-map http://www.nexml.org/1.0=Nexml \ --generate-polymorphic --output-dir ./out/$outdir $file * this works without problems, I get ./out/$outdir/$file.hxx headers and ./out/$outdir/$file.cxx sources * however, to make my print program, I understand I should also generate parser code (right?), so I also run: ./xsd cxx-parser --namespace-map http://www.nexml.org/1.0=Nexml \ --generate-print-impl --output-dir ./out/$outdir $file * again, this works without problems, I get the $file-pskel header and source files and $file-pimpl header and source files ==> Here is where I think things are starting to get sketchy <== * because there is a single root element, which is defined in nexml.xsd, I need to generate a test driver from that schema file, so I do: ./xsd cxx-parser --namespace-map http://www.nexml.org/1.0=Nexml --root-element nexml \ --output-dir ./out --generate-print-impl --force-overwrite --generate-test-driver ../../nexml/xsd/nexml.xsd * this yields an additional nexml-driver.cxx * I then need to compile this driver file so I do: g++ -W -Wall -I../../libxsd -I../../../xerces-c_2_8_0-x86-macosx-gcc_4_0/include -c nexml-driver.cxx * but I am rewarded with: characters/continuous-pskel.hxx:292: error: expected class-name before '{' token ...times a million, and things go downhill from there. To be quite honest, I'm probably making the wrong gcc incantation, in which case I apologize for asking off topic questions (help still greatly appreciated, of course), but if I'm making any wrong assumptions further upstream, please let me know. I'm very eager to get this to work, but haven't gotten much further by googling, checking the list archives, or the csxsd wiki. Thank you, best wishes, Rutger -- Dr. Rutger A. Vos Department of zoology University of British Columbia http://www.nexml.org http://rutgervos.blogspot.com From boris at codesynthesis.com Fri Dec 21 08:48:36 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] schema => simple print program, need walkthrough In-Reply-To: <2bb9b24a0712202353w21ea09c1ya9b9f5af01391896@mail.gmail.com> References: <2bb9b24a0712202353w21ea09c1ya9b9f5af01391896@mail.gmail.com> Message-ID: <20071221134836.GA29112@karelia> Hi Rutger, Rutger Vos writes: > The schema I'm working with is this one: > http://www.nexml.org/nexml/xsd/ . If you can create a .tar.gz archive of all the schemas so that I can download all of them in one go, then I could give it try and maybe even create a small test driver for you. > * csxsd doesn't download remote schema files, so I've downloaded the > schemas I import (the xml and xlink namespaces) and reference them > locally, they're in the external/ folder. In the next version of XSD[1], there will be support for re-mapping the remote locations of imported/included schemas without changing the importing/including schemas. > * csxsd doesn't follow inclusions itself, you need to tell it > explicitly from which schema files to generate code Yes, XSD follows the so-called separate compilation model. The next version[1] will also support the file-per-type compilation model which will generate all the code from one schema. > * csxsd - or actually gcc when I try to compile - doesn't like cycles > in schema inclusions (and hence generated code?), so I've broken them > to create an acyclic inclusion tree The generated code can handle cycles as long as they don't involve inheritance. If there is inheritance involved then you will need to either get rid of the cycle or use the file-per-type compilation model mentioned above. > With those things taken into account, I generate code as follows: > > * I make a list of all schema files I will be working with, i.e. in > shell I do files=$(find . -name "*.xsd") out of which I "grep -v" the > files that aren't reached by the inclusions starting from nexml.xsd > (e.g. the "draft1" folder) > > * because the schema files are organized in a folder structure (see > inclusions graph) I assume I will be happiest if the generated code > ends up in a similar folder structure, so I loop over each $file in > $files and modify the string to get $outdir, such that for file > ./characters/dna.xsd $outdir is characters/ > > * I then run csxsd for each schema file with the following incantation: > > ./xsd cxx-tree --namespace-map http://www.nexml.org/1.0=Nexml \ > --generate-polymorphic --output-dir ./out/$outdir $file Sounds good. Can you perhaps also make available the script that does all this so that I don't need to reinvent it? > * however, to make my print program, I understand I should also > generate parser code (right?), so I also run: > > ./xsd cxx-parser --namespace-map http://www.nexml.org/1.0=Nexml \ > --generate-print-impl --output-dir ./out/$outdir $file No, you don't need to do this. The generated C++/Tree code (cxx-tree) already has the parsing functionality. C++/Parser is a different kind of XML Schema to C++ mapping (event-driven as opposed to in-memory, similar to how SAX and DOM are different). > * because there is a single root element, which is defined in > nexml.xsd, I need to generate a test driver from that schema file, so > I do: > > ./xsd cxx-parser --namespace-map http://www.nexml.org/1.0=Nexml > --root-element nexml \ > --output-dir ./out --generate-print-impl --force-overwrite > --generate-test-driver ../../nexml/xsd/nexml.xsd Again, you can't do this with C++/Tree. Automatic generation of the test driver implementation is only available in the C++/Parser mapping. What you can do with the C++/Tree mapping is to add the --generate-ostream option to the 'xsd cxx-tree ...' command line. This will result in std::ostream insertion operators (operator<<) being generated for each C++ class. Then you can create a simple test driver for your schema: #include #include #include "nexml.xsd" using namespace std; int main (int argc, char* argv[]) { try { auto_ptr root (Nexml::nexml (argv[1])); cout << *root << endl; } catch (const xml_schema::exception& e) { cerr << e << endl; return 1; } } The only problem in the above test driver is that you schemas use polymorphism (xsi:type) while the generated std::ostream insertion operators are not polymorphism-aware and will only print the date from the base type. But this should at least get you started. BTW, in case you haven't read it, I suggest that you take a look at the C++/Tree Mapping Getting Started Guide, at least the "Hello World" chapter of it: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/ [1] You can start using these features before the release by getting the pre-release binaries which are available for GNU/Linux and Windows: http://codesynthesis.com/~boris/tmp/xsd-3.1.0.a5-i686-linux-gnu.tar.bz2 http://codesynthesis.com/~boris/tmp/xsd-3.1.0.a5-i686-windows.zip Boris From guinux7 at gmail.com Fri Dec 28 15:20:16 2007 From: guinux7 at gmail.com (guillaume) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] xsd and collada Message-ID: hi, i have been trying to read a .dae file with xsd, however there's a problem i can't fix at runtime. dae is the extension of the collada 3d file format in xml. so i took the latest schema for collada 1.4, and generated the corresponding hxx and cxx with xsd cxx-tree --generate-polymorphic --root-element COLLADA COLLADASchema.xsd then the main file : #include #include "COLLADASchema.hxx" using namespace std; using namespace COLLADASchema; int main(int argc, char **argv) { try { auto_ptr< COLLADA > c (COLLADA_ (argv[1])); } catch (const xml_schema::exception& e) { cerr << e << endl; return 1; } return 0; } compiled this way : g++ -c COLLADASchema.cxx main.cpp g++ -o test COLLADASchema.o main.o -lxerces-c so i tried on a collada file exported from blender, and the output is : /home/guillaume/Desktop/test/a.dae:2:79 error: Unknown element 'COLLADA' /home/guillaume/Desktop/test/a.dae:2:79 error: Attribute 'version' is not declared for element 'COLLADA' /home/guillaume/Desktop/test/a.dae:2:79 error: Attribute 'xmlns' is not declared for element 'COLLADA' /home/guillaume/Desktop/test/a.dae:3:9 error: Unknown element 'asset' /home/guillaume/Desktop/test/a.dae:4:16 error: Unknown element 'contributor' /home/guillaume/Desktop/test/a.dae:5:12 error: Unknown element 'author' /home/guillaume/Desktop/test/a.dae:6:20 error: Unknown element 'authoring_tool' /home/guillaume/Desktop/test/a.dae:7:14 error: Unknown element 'comments' /home/guillaume/Desktop/test/a.dae:8:15 error: Unknown element 'copyright' /home/guillaume/Desktop/test/a.dae:9:17 error: Unknown element 'source_data' /home/guillaume/Desktop/test/a.dae:11:12 error: Unknown element 'created' /home/guillaume/Desktop/test/a.dae:12:13 error: Unknown element 'modified' and so on... seems like it doesn't recognize the format at all. does anyone have an idea ? what part do i miss ? happy hollidays guillaume From boris at codesynthesis.com Fri Dec 28 15:59:08 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] xsd and collada In-Reply-To: References: Message-ID: <20071228205908.GA28999@karelia> Hi Guillaume, guillaume writes: > so i tried on a collada file exported from blender, and the output is : > > /home/guillaume/Desktop/test/a.dae:2:79 error: Unknown element 'COLLADA' > > [...] > > and so on... seems like it doesn't recognize the format at all. does anyone > have an idea ? what part do i miss ? Check out Q2.1 in the C++/Tree Mapping FAQ: http://wiki.codesynthesis.com/Tree/FAQ Boris From boris at codesynthesis.com Mon Dec 31 07:13:28 2007 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] xsd and collada In-Reply-To: References: <20071228205908.GA28999@karelia> Message-ID: <20071231121328.GA3076@karelia> Hi Guillaume, In the future please keep your replies CC'ed to the xsd-users mailing list. This way other developers who may have experienced a similar problem can provide you with a solution. Plus questions and answers will be archived and available to others with similar problems. guillaume writes: > hi boris, > thank you for the very fast answer. i'm sorry i didn't take enough time to > look at the faq. i see things better now, however, i don't understand well > how all these xml schema validations are handled Please see Section 5.1, "XML Schema Validation and Searching" in the C++/Tree Mapping Getting Started Guide: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#5.1 > (are they downloaded from the urls?). If you have Xerces-C++ built with network support then, yes, schemas that are specified as URLs will be downloaded. There are also other methods of specifying schemas to be used for validation, as described in the document mentioned above. > if i understand well, i need to copy all of them from ... > to . No, that's not how you do it. Please read Section 5.1 mentioned above as well as the "XML Schema Part 0: Primer Second Edition", particularly Section 5.6: http://www.w3.org/TR/xmlschema-0/ > at the same time, i saw one can disable this checking, so is the xml > still read and the c++ classes usable ? Yes, the generated classes are perfectly usable if you know that the XML documents you are planning to parse are valid. From Section 5: "Even when XML Schema validation is disabled, the generated code still performs a number of checks to prevent construction of an inconsistent object model (for example, an object model with missing required attributes or elements)." Boris From jnw at xs4all.nl Mon Dec 31 11:31:59 2007 From: jnw at xs4all.nl (Jeroen N. Witmond [Bahco]) Date: Sun Oct 11 15:34:00 2009 Subject: [xsd-users] cxx-parser: Not all attributes in the XML namespace are typemapped. Message-ID: <6785.194.109.230.85.1199118719.squirrel@webmail.xs4all.nl> Hi Boris, Boris Kolpackov writes: > Jeroen N. Witmond [Bahco] writes: > >> Attributes lang and space are (anonymous) simpleTypes, where base >> and id are xs:anyUri resp. xs:ID. >> >> Is this expected behavior of xsd cxx-parser? > > Yes, type maps are mapping types, not attributes or elements. If > you want the base and id attributes to be represented by your own > C++ types, then you will need to re-map xs:anyUri and xs:ID (and > by doing this you will also make other attributes/elements that > are of these built-in types to use your custom C++ types). It's not so much that I want to use custom types. What I was trying to achieve with them was a proper source code organization. I use multiple xsd files (one importing the other) and I prefer the code generated and written for each xsd file to have its own distinct set of source files. I have added a new implementation, parser-datamodel, to my page on cxx-parser[1, bottom left]. This implementation introduces a data model to handle the uniquenes of xml:id and the inheritance of the other attributes in that namespace. In this implementation, which is based on a Schema that references these attributes explicitely, the setters for xml:base and xml:id are called from the application's source files. To the same page[1, bottom right] I added another new implementation, parser-anytype, that is based on your examples[2] and uses almost the same data model as parser-datamodel above. The advantages of parser-anytype are that it does not depend on how the client Schema treats the attributes, and that the maintenance of the data model is hidden from the application logic. All this also resulted in a number of questions and comments: 1. The generated test driver for parser-datamodel contains, under '// Instantiate individual parsers.', the declaration '::xml_schema::ncname_pimpl ncname_p;'. This variable ncname_p is never used. 2. It would be nice if cxx-parser supported the --generate-xml-schema and --extern-xml-schema like cxx-tree. 3. In the handler for xml:id, I throw an exception when the value of the attribute has been seen before. Is there a way to include information about the source location in the xml file in this exception? I also reworked the data model into a new implementation, custom-datamodel, for my page on cxx-tree[3, item 7]. custom-datamodel is based on custom-intended [3, item 4], and like it uses a customization of anyType. In custom-datamodel, the code for the data model and its interaction with the code generated by xsd cxx-tree can be used both with char and with wchar_t as the character type for the application logic. Note that for custom-datamodel, I use cxx-parser to generate a program that in its turn generates the header file that defines the literals for both character types. :) 4. To handle the inheritance for an element, I need access to the parent of that element. At the moment, I use an ugly hack for this, see file custom-datamodel/XmlNamespace.cpp[4], starting at line 146. Is there a better way to do this? 5. When I throw an exception in the setter for xml:id (called from the constructor of the custom type), the program terminates with pure virtual method called terminate called without an active exception Debugging with Valgrind[4] shows that the DOMDocument is reset twice. Invalid read of size 4 at 0x804B41C: xsd::cxx::xml::dom::auto_ptr::reset(xercesc_2_7::DOMDocument*) (auto-ptr.hxx:145) by 0x804B456: xsd::cxx::xml::dom::auto_ptr::~auto_ptr() (auto-ptr.hxx:49) by 0x8052E9A: metadox::foo(std::string const&, xsd::cxx::tree::flags, xsd::cxx::tree::properties const&) (lax.cxx:387) by 0x805ACE2: main (driver-char.cpp:87) Address 0x51678E4 is 20 bytes inside a block of size 164 free'd at 0x401BCBC: operator delete(void*) (vg_replace_malloc.c:244) by 0x420ADBC: xercesc_2_7::MemoryManagerImpl::deallocate(void*) (in /usr/lib/libxerces-c.so.27.0) by 0x42D38A8: xercesc_2_7::XMemory::operator delete(void*) (in /usr/lib/libxerces-c.so.27.0) by 0x41889FD: xercesc_2_7::DOMDocumentImpl::~DOMDocumentImpl() (in /usr/lib/libxerces-c.so.27.0) by 0x418542C: xercesc_2_7::DOMDocumentImpl::release() (in /usr/lib/libxerces-c.so.27.0) by 0x804B432: xsd::cxx::xml::dom::auto_ptr::reset(xercesc_2_7::DOMDocument*) (auto-ptr.hxx:145) by 0x804B456: xsd::cxx::xml::dom::auto_ptr::~auto_ptr() (auto-ptr.hxx:49) by 0x804C336: xsd::cxx::tree::_type::dom_element_info::~dom_element_info() (elements.hxx:449) by 0x804B15E: std::auto_ptr::~auto_ptr() (memory:259) by 0x804CB97: xsd::cxx::tree::_type::~_type() (elements.hxx:190) by 0x804CCF5: xml_schema::XmlNamespace::~XmlNamespace() (XmlNamespace.cpp:281) by 0x8051842: metadox::foo_type::foo_type(xercesc_2_7::DOMElement const&, xsd::cxx::tree::flags, xsd::cxx::tree::_type*) (lax.cxx:254) by 0x805A83F: xsd::cxx::tree::traits::create(xercesc_2_7::DOMElement const&, xsd::cxx::tree::flags, xsd::cxx::tree::_type*) (elements.hxx:711) by 0x80519B7: metadox::foo(xercesc_2_7::DOMDocument*, xsd::cxx::tree::flags, xsd::cxx::tree::properties const&) (lax.cxx:648) by 0x8052E1D: metadox::foo(std::string const&, xsd::cxx::tree::flags, xsd::cxx::tree::properties const&) (lax.cxx:382) by 0x805ACE2: main (driver-char.cpp:87) 6. As in the case of cxx-parser, it would be nice if I could report the source location in the xml file also with cxx-tree. Happy New Year to all! Jeroen. [1] http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/parser.html [2] http://codesynthesis.com/pipermail/xsd-users/2007-November/001377.html [3] http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/index.html [4] http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/custom-datamodel/XmlNamespace.cpp