From bhartsb at gmail.com Wed May 2 11:44:32 2012 From: bhartsb at gmail.com (B Hart) Date: Fri May 4 04:55:25 2012 Subject: [xsd-users] Re: Can one use ODB with Classes generated by XSD Message-ID: Hello Boris, (this is a re-post as the original thread is quite old and may getting buried). Per my earlier thread titled "Can one use ODB with Classes generated by XSD"since ODB now supports MS SQL and I'm at a place where I might be able to use ODB, and my requirements have changed . Particularly I no longer have the need to map my schema into an existing DB that doesn't match the schema well. That is I'm going to create a DB that matches the Schema. I've used CodeSynthesis XSD to generate classes for a set of schemas that happen to be nicely hierarchical. Essentially the XSDs define the elements for patient care records. Each record has up to ~550 elements divided into ~23 subsections/categories. Elements in the subsections have all the different cardinalities. For example, elements relating to adminstering a medication are defined in a complex element with cardinality sequence (since multiple medications might be administered to the same patient, or the same medication given at different times). As an evaluation exercise I generated a DB schema from the XSDs using Altova's XMLSpy. It generated a set of tables very reflective of the organization of the XML Schemas as well as the element constraints. I'm wondering if I similarly relied on ODB to generate the tables if it would produce a similar DB schema, as well as the constraints based on the element types? Haven't tried it yet. Also, I'm wondering if item #2 below has been implemented? I have written a program that with excellent help from XSD generated classes reads in patient records in an XML file, validates the XML, and checks various business rules and generates a report. At the point after validation has occurred and Business Rules are checked and pass, the data is ready to put into the DB. It would be nice if I could use ODB to generate the Schema and make it happen with just a few lines of code (similar to how easy it is with XSD to read in a complex schema and serialize it out again.). Thanks in advance for your comments. Boris Kolpackov: I see two possible approaches here, depending on how closely the XML vocabulary models the database representation. 1. If XML and database models are very different (as in the case you described above), then the best approach would probably be to have two object models (sets of C++ classes): the first is for XML (generated by the XSD compiler) and the second is for the database (hand-written or auto-generated by ODB SQL-to-C++ compiler from the existing schema, something that is on our TODO list). Once you have the two models, you manually write the code that convert between the two, such as performing merging and splitting of members, etc. 2. If XML models the database pretty closely, then you can take the XSD-generated model and map it (using ODB pragmas) to the database tables (those can be placed into a separate file and included into the ODB compilation with the --odb-epilogue option). Once that is done, you can just load the classes from XML and store them into the RDBMS. From boris at codesynthesis.com Fri May 4 05:00:22 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri May 4 04:57:07 2012 Subject: [xsd-users] Re: Can one use ODB with Classes generated by XSD In-Reply-To: References: Message-ID: See this thread on the odb-users mailing list if you are interested in this topic: http://www.codesynthesis.com/pipermail/odb-users/2012-May/000526.html Boris From barrie.kovish at singularsoftware.com Tue May 15 16:27:06 2012 From: barrie.kovish at singularsoftware.com (Barrie Kovish) Date: Tue May 15 16:27:15 2012 Subject: [xsd-users] Compilation error in zc-istream.txx Message-ID: I noticed that zc-istream.txx won't compile with the LLVM. An error is reported at: Method: init () Line: 35 Code: setg (b, b, e); To fix this compile time issue I changed the code to: this->setg (b, b, e); Barrie From boris at codesynthesis.com Wed May 16 08:24:39 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 16 08:24:49 2012 Subject: [xsd-users] Compilation error in zc-istream.txx In-Reply-To: References: Message-ID: Hi Barrie, Barrie Kovish writes: > I noticed that zc-istream.txx won't compile with the LLVM. Yes, we have already fixed this for the next release. Here is the commit: http://scm.codesynthesis.com/?p=xsd/xsd.git;a=commit;h=a6f85da576d5d1fafce01bb6c3070c408adba913 Thanks for reporting this and for suggesting the fix! Also let me know if you need a patch. Boris From docjunior at web.de Wed May 23 09:30:42 2012 From: docjunior at web.de (Jens Rapp) Date: Wed May 23 09:31:02 2012 Subject: [xsd-users] generated tree with ambiguous references Message-ID: hi, i tried to play a little with xsdcxx but didn't get any working code. here's my xsd: &n & " type="int"> &nbs my code generation loo GENSRCDIR = src/generated-source SCHEMADIR = src/schem XSD2CXX = /usr/bin/xsdcxx XTFLAGS = --output-dir $(GENSRCDIR) --hxx-suffix .h --cxx-suffix .cpp --generate -seri alization --generate-ostream --generate-wildcard --generate-comp ariso object-list: generate-source echo - for i in `find ./src -name *.cpp`; do echo -n " ec br/> echo "HDR = \$$(SRC:%.cpp=%.h)" ; >>sourcefiles.in generate-source: generate-tree: $(XSD2 It int main(int argc, char **argv) try { & el (datei)); for (ac tion_t::object_const_iterator i (model->action().begin()); ; i != model->action().end(); ++i) { } catch (const xml_schema::excepti cerr <& re } return 0;} this is my compiler output: make all rm /usr/bin/g++ -Wall -g -c src/generated-source /usr/bin/g++ -Wall -g -c src/cxx/main.cpp src/cxx s s ambiguous src/cxx/../generated-source/mind.h:251: error: candid ates are: namespace mindmodel { } src/cxx/../generated-source xsd::cxx::xml::dom::auto_ptr&l t;xercesc_3_1::DOMDocument> mindmodel::mindmodel(const mindmodel:: mi ndmodel_t&, const xml_schema::namespace_infomap&, xml_schema: :flags) src/cxx/../generated-source/mind.h:691: error: &nb sp; void mindmodel::mindmodel(xercesc_3_1::DOMDocument&, const mindmodel::mindmodel_t&, xml_schema::flags) src/cxx/../generat sp; void mindmodel::min dmodel(xercesc_3_1::XMLFormatTarget&, const mindmodel::mindmodel_t & amp;, xercesc_3_1::DOMErrorHandler&, const xml_schema::namespace _ src/cxx/ ; void mind model::mindmodel(xercesc_3_1::XMLFormatTarget&, const mindmodel::m i ndmodel_t&, xml_schema::error_handler&, const xml_schema::nam espace_infomap&, const std::string&, xml_schema::flags) s p; void mindmodel::mindmodel(xercesc_3_1::XMLFormatTarget&, const mindm o del::mindmodel_t&, const xml_schema::namespace_infomap&, cons t std::string&, xml_schema::flags) src/cxx/../generated-source/ nbsp; void mindmodel::mindmodel(std ::ostream&, const mindmodel::mindmodel_t&, xercesc_3_1::DOMEr rorHandler&, const xml_schema::namespace_infomap&, const st d::string&, xml_schema::flags) src/cxx/../generated-source/mind.h nbsp; void mindmodel::mindmodel(std::ostr eam&, const mindmodel::mindmodel_t&, xml_schema::error_handle r&, const xml_schema::namespace_infomap&, const std::string &, xml_schema::flags) src/cxx/../generated-source/mind.h:639: e p; void mindmodel::mindmodel(std::ostream&, const mindmodel::mindmodel_t&, const xml_schema::namespace_in f src/cxx/../ bsp; std::auto_ptr& lt;mindmodel::mindmodel_t> mindmodel::mindmodel(xsd::cxx::xml::dom:: au xml_schema::properties&) src/cxx/../generated-source/mind.h:612: std::auto_ptr ; mindmodel::mindmodel(const xercesc_3_1::DOMDocument&, xml_sche m src/cxx/../generated-s nbsp; std::auto_ptr mindmodel::mindmodel(xercesc_3_1::InputSource&, xercesc_3_1::DOMErrorHandler&, xml_schema::flags, const xml_sche m src/cxx/../generated-source/mind.h:597: error:&nb std::auto_ptr mindmode l::mindmodel(xercesc_3_1::InputSource&, xml_schema::error_handler& ;, xml_schema::flags, const xml_schema::properties&) src/cxx/ ; std::auto_p tr mindmodel::mindmodel(xercesc_3_1::InputS ource&, xml_schema::flags, const xml_schema::properties&) bsp; st d::auto_ptr mindmodel::mindmodel(std::istre am&, const std::string&, xercesc_3_1::DOMErrorHandler&, xml_schema::flags, const xml_schema::properties&) src/cxx/.. nbsp; std::auto_ptr mindmodel::mindmodel(std::istream&, const std::string&, xml_schema::error_handler&, xml_schema::f lags, const xml_schema::properties&) src/cxx/../generated-sourc ; std::auto_ptr mindmodel::mindmodel(std::istream&, const std::str ing&, xml_schema::flags, const xml_schema::properties&) s p; std: :auto_ptr mindmodel::mindmodel(std::istream &, xercesc_3_1::DOMErrorHandler&, xml_schema::flags, const xml_schema::properties&) src/cxx/../generated-source/mind.h:557: sp; std::auto_ptr mindmodel::mindmodel(std::istream&, xml_schema::error_handler& , xml_schema::flags, const xml_schema::properties&) src/cxx/. std::auto_pt r mindmodel::mindmodel(std::istream&, xml_schema::flags, const xml_schema::properties&) src/cxx/.. nbsp; std::auto_ptr mindmodel::mindmodel(const std::string&a mp;, xercesc_3_1::DOMErrorHandler&, xml_schema::flags, const x m src/cxx/../generated-source/mind.h:537: er ; std::auto_ptr m indmodel::mindmodel(const std::string&, xml_schema::error_handler& a src/cx sp; std::auto _ptr mindmodel::mindmodel(const std::stri ng&, xml_schema::flags, const xml_schema::properties&) sr ambiguous src/cxx/../generated-source/mind.h:251: error: candida tes are: namespace mindmodel { } src/cxx/../generated-source/ nbsp; xsd::cxx::xml::dom::auto_ptr< ;xercesc_3_1::DOMDocument> mindmodel::mindmodel(const mindmodel::m in dmodel_t&, const xml_schema::namespace_infomap&, xml_schema:: flags) src/cxx/../generated-source/mind.h:691: error: &nbs p; & nbsp; void mindmodel::mindmodel(xercesc_3_1::DOMDocument&, const src/cxx/../generat sp; void mindmodel::min dmodel(xercesc_3_1::XMLFormatTarget&, const mindmodel::mindmodel_t & amp;, xercesc_3_1::DOMErrorHandler&, const xml_schema::namespace _ src/cxx/ ; void mind model::mindmodel(xercesc_3_1::XMLFormatTarget&, const mindmodel::m i ndmodel_t&, xml_schema::error_handler&, const xml_schema::nam espace_infomap&, const std::string&, xml_schema::flags) s p; void mindmodel::mindmodel(xercesc_3_1::XMLFormatTarget&, const mindm o del::mindmodel_t&, const xml_schema::namespace_infomap&, cons t std::string&, xml_schema::flags) src/cxx/../generated-source/ nbsp; void mindmodel::mindmodel(std ::ostream&, const mindmodel::mindmodel_t&, xercesc_3_1::DOMEr rorHandler&, const xml_schema::namespace_infomap&, const st d::string&, xml_schema::flags) src/cxx/../generated-source/mind.h nbsp; void mindmodel::mindmodel(std::ostr eam&, const mindmodel::mindmodel_t&, xml_schema::error_handle r&, const xml_schema::namespace_infomap&, const std::string &, xml_schema::flags) src/cxx/../generated-source/mind.h:639: e p; void mindmodel::mindmodel(std::ostream&, const mindmodel::mindmodel_t&, const xml_schema::namespace_in f src/cxx/../ bsp; std::auto_ptr& lt;mindmodel::mindmodel_t> mindmodel::mindmodel(xsd::cxx::xml::dom:: au xml_schema::properties&) src/cxx/../generated-source/mind.h:612: std::auto_ptr ; mindmodel::mindmodel(const xercesc_3_1::DOMDocument&, xml_sche m src/cxx/../generated-s nbsp; std::auto_ptr mindmodel::mindmodel(xercesc_3_1::InputSource&, xercesc_3_1::DOMErrorHandler&, xml_schema::flags, const xml_sche m src/cxx/../generated-source/mind.h:597: error:&nb std::auto_ptr mindmode l::mindmodel(xercesc_3_1::InputSource&, xml_schema::error_handler& ;, xml_schema::flags, const xml_schema::properties&) src/cxx/ ; std::auto_p tr mindmodel::mindmodel(xercesc_3_1::InputS ource&, xml_schema::flags, const xml_schema::properties&) bsp; st d::auto_ptr mindmodel::mindmodel(std::istre am&, const std::string&, xercesc_3_1::DOMErrorHandler&, xml_schema::flags, const xml_schema::properties&) src/cxx/.. nbsp; std::auto_ptr mindmodel::mindmodel(std::istream&, const std::string&, xml_schema::error_handler&, xml_schema::f lags, const xml_schema::properties&) src/cxx/../generated-sourc ; std::auto_ptr mindmodel::mindmodel(std::istream&, const std::str ing&, xml_schema::flags, const xml_schema::properties&) s p; std: :auto_ptr mindmodel::mindmodel(std::istream &, xercesc_3_1::DOMErrorHandler&, xml_schema::flags, const xml_schema::properties&) src/cxx/../generated-source/mind.h:557: sp; std::auto_ptr mindmodel::mindmodel(std::istream&, xml_schema::error_handler& , xml_schema::flags, const xml_schema::properties&) src/cxx/. std::auto_pt r mindmodel::mindmodel(std::istream&, xml_schema::flags, const xml_schema::properties&) src/cxx/.. nbsp; std::auto_ptr mindmodel::mindmodel(const std::string&a mp;, xercesc_3_1::DOMErrorHandler&, xml_schema::flags, const x m src/cxx/../generated-source/mind.h:537: er ; std::auto_ptr m indmodel::mindmodel(const std::string&, xml_schema::error_handler& a src/cx sp; std::auto _ptr mindmodel::mindmodel(const std::stri ng&, xml_schema::flags, const xml_schema::properties&) ma what's wron Ihr WEB.DE Postfach immer dabei: die kostenlose WEB.DE=2 0M https://produ From boris at codesynthesis.com Wed May 23 11:44:04 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 23 11:44:16 2012 Subject: [xsd-users] generated tree with ambiguous references In-Reply-To: References: Message-ID: Hi Jens, I don't know what happened but your email is unreadable. You can see what it looks like in the archives: http://www.codesynthesis.com/pipermail/xsd-users/2012-May/003625.html Can you resend it using plain text? Boris From boris at codesynthesis.com Wed May 23 16:27:50 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed May 23 16:27:59 2012 Subject: [xsd-users] generated tree with ambiguous references In-Reply-To: <4FBD140C.3060501@web.de> References: <4FBD140C.3060501@web.de> Message-ID: Hi Jens, In the future please send such questions to the xsd-users mailing list instead of to me directly, as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Jens Rapp writes: > Hi Boris, > > sorry, I had to send via webmail and this is the worst webmailer I know. > > I'll try to repeat my problem description.. > > this is my schema > > > targetNamespace="http://www.example.org/mindmodel" > xmlns:tns="http://www.example.org/mindmodel" > elementFormDefault="qualified"> > > > > minOccurs="0"> > > > > > > > > minOccurs="1"> > > > > > > > > minOccurs="0"> > > > > In your schema you have the 'mindmodel' global element which is translated to the mindmodel() parsing/serialization functions. Your schema's target namespace (http://www.example.org/mindmodel) is mapped by default to 'mindmodel' (XSD compiler just takes the path component from the namespace URI and turns into a C++ namespace). Because the namespace and the functions inside this namespace have the same name, they conflict. The easiest way to fix this is to re-map the namespace to some other name using the --namespace-map option. For example: --namespace-map http://www.example.org/mindmodel=mm If you want to place the generated code in the global namespace (might be the best option for such a small schema), then you can write this: --namespace-map http://www.example.org/mindmodel= Alternatively, you can change the names of the parsing/serialization functions (e.g., add the 'parse_' and 'serialize_' prefixes) using the --parser-regex and --serializer-regex options. See the XSD compiler command line manual (man pages) for details: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml Boris [The rest of the email follows for context.] > > Here's how I generate the classes, calling make generate-source. > > GENSRCDIR = src/generated-source > SCHEMADIR = src/schema > > XSD2CXX = /usr/bin/xsdcxx > XTFLAGS = --output-dir $(GENSRCDIR) --hxx-suffix .h --cxx-suffix .cpp > XPFLAGS = --output-dir $(GENSRCDIR) --hxx-suffix .h --cxx-suffix .cpp > --xml-parser expat > > object-list: generate-source > echo -n "SRC = " >sourcefiles.in > for i in `find ./src -name *.cpp`; do echo -n " $$i" >> sourcefiles.in; done > echo "" >>sourcefiles.in > echo "OBJ = \$$(SRC:%.cpp=%.o)" >>sourcefiles.in > echo "HDR = \$$(SRC:%.cpp=%.h)" >>sourcefiles.in > > generate-source: generate-tree > > generate-tree: > $(XSD2CXX) cxx-tree $(XTFLAGS) $(SCHEMADIR)/*.xsd > > generate-parser: > $(XSD2CXX) cxx-parser $(XPFLAGS) $(SCHEMADIR)/*.xsd > > Next is my main function, basically copied from the Getting Started Guide. > > my compile (do you need the makefile?) trhows these messages.. > > > **** Build of configuration Default for project ai-persistence **** > > make all > rm -rf target/* > /usr/bin/g++ -Wall -g -c src/generated-source/mind.cpp > /usr/bin/g++ -Wall -g -c src/cxx/main.cpp > src/cxx/main.cpp: In function ?int main(int, char**)?: > src/cxx/main.cpp:19: error: reference to ?mindmodel? is ambiguous > src/cxx/../generated-source/mind.h:223: error: candidates are: namespace > mindmodel { } > src/cxx/../generated-source/mind.h:553: error: > std::auto_ptr > mindmodel::mindmodel(xsd::cxx::xml::dom::auto_ptr&, > xml_schema::flags, const xml_schema::properties&) > > [...] From gordan.sikic at uljanik.hr Mon May 28 09:18:38 2012 From: gordan.sikic at uljanik.hr (Gordan Sikic) Date: Mon May 28 09:18:48 2012 Subject: [xsd-users] DLL's VS 2010 and dllexport problems revisited Message-ID: <4FC37B2E.1050200@uljanik.hr> Hi, I've been bitten by the problems described in these threads: http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003010.html http://codesynthesis.com/pipermail/xsd-users/2011-July/003356.html all the suggestions I found didn't help, the problem did not vanish. However, I'm in a position that does not require complete class to be exported. If I change definitions in headers so only member functions are exported, and not class itself, everything works like a charm. The approach is descried in the following document, in Selective Member Import/Export section: http://msdn.microsoft.com/en-us/library/81h27t8c%28v=vs.80%29.aspx Right now, I would like to change attributes of all member functions in automatically generated classes to include import/export macro, i.e.: class DLL_API SomeData { return_type function_name(); void other_return_type some_other_function(); }; should become : class SomeData { DLL_API return_type function_name(); DLL_API other_return_type some_other_function(); }; note, class itself is NOT exported, but functions are. I would like to ask is there possibility to automatically add this function decoration during parsing XSD schema? thanks, Gordan The information in this email is confidential and it is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any distribution, copying, duplication or disclosure is prohibited and may be unlawful. If you have received this email in error, please notify the sender immediately and destroy it, and all copies of it. Ova poruka je povjerljiva i namijenjena isklju?ivo primateljima navedenim u zaglavlju iste. Svaki pristup, distribucija, umno?avanje ili otkrivanje sadr?aja ove poruke tre?im osobama strogo je zabranjeno i smatra se protuzakonitim. Ukoliko ste gre?kom dobili ovu poruku, molimo Vas da ?to prije obavijestite po?iljatelja poruke i uni?tite sve postoje?e kopije. From boris at codesynthesis.com Mon May 28 10:11:10 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon May 28 10:11:17 2012 Subject: [xsd-users] DLL's VS 2010 and dllexport problems revisited In-Reply-To: <4FC37B2E.1050200@uljanik.hr> References: <4FC37B2E.1050200@uljanik.hr> Message-ID: Hi Gordan, > all the suggestions I found didn't help, the problem did not vanish. It would be helpful to have more details on this. Generally, if followed correctly, this approach works. Here is the list of steps that you need to take: http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003011.html And at the bottom of the following email there is some additional information on cases where you have your own (not generated) classes that inherit from std::string: http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003019.html > If I change definitions in headers so only member functions are exported, > and not class itself, everything works like a charm. > > [...] > > I would like to ask is there possibility to automatically add this > function decoration during parsing XSD schema? I am pretty sure we won't be able to do this for built-in types which are class templates. What's exported in their case are template instantiations (using the "template class EXPORT_MACROS foo;" syntax). Maybe it is possible to instantiate and export individual member functions this way but we definitely don't want to go that route (there will be hundreds of them). Boris From gordan.sikic at uljanik.hr Tue May 29 03:48:26 2012 From: gordan.sikic at uljanik.hr (Gordan Sikic) Date: Tue May 29 03:48:36 2012 Subject: [xsd-users] DLL's VS 2010 and dllexport problems revisited In-Reply-To: References: <4FC37B2E.1050200@uljanik.hr> Message-ID: <4FC47F4A.2040800@uljanik.hr> Hi Boris, thanks for your answer, > It would be helpful to have more details on this. It is the similar problem as explained in "2010-september" thread. There are couple of mutually unrelated schemas, and every schema is compiled into one dll. On many places in schemas, string enumerations are used, and it turns out that resulting classes in c++ are inherited from ::xml_schema::string. At the end, I have dependant dll that links all other dlls generated from xsd schemas. Link stage of this dependant dll reports problem. I have tried to compile minimal example, but it doesn't trigger the problem, so I posted the question without it. Maybe you can (if possible) send me example that is used in thread you refer to, so I can check it as well? > Generally, if followed correctly, this approach works. Here is the > list of steps that you need to take: > > http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003011.html I tried it (and followed it correctly), more than once. I've been dealing with this problem for a couple of weeks now, and before posting I made sure that all other possibilities are already explored and checked. >> I would like to ask is there possibility to automatically add this >> function decoration during parsing XSD schema? > > I am pretty sure we won't be able to do this for built-in types which > are class templates. What's exported in their case are template > instantiations (using the "template class EXPORT_MACROS foo;" Maybe I was little bit vague in my explanation. When I wrote automatically, I did not mean obligatory, just possibly, as some kind of command line option (some kind of regex?). I don't want to export types "per se", I don't need it. I want to export member functions of generated classes only. > syntax). Maybe it is possible to instantiate and export individual > member functions this way but we definitely don't want to go that > route (there will be hundreds of them). Ok, I understand that it is not route you are willing to take. I would just like to ask why do you think it is a problem to have hundreds of export macros within class, after all, it is automatically generated code? once more, thanks for you answers, cheers, Gordan The information in this email is confidential and it is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any distribution, copying, duplication or disclosure is prohibited and may be unlawful. If you have received this email in error, please notify the sender immediately and destroy it, and all copies of it. Ova poruka je povjerljiva i namijenjena isklju?ivo primateljima navedenim u zaglavlju iste. Svaki pristup, distribucija, umno?avanje ili otkrivanje sadr?aja ove poruke tre?im osobama strogo je zabranjeno i smatra se protuzakonitim. Ukoliko ste gre?kom dobili ovu poruku, molimo Vas da ?to prije obavijestite po?iljatelja poruke i uni?tite sve postoje?e kopije. From boris at codesynthesis.com Tue May 29 04:34:42 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue May 29 04:34:51 2012 Subject: [xsd-users] DLL's VS 2010 and dllexport problems revisited In-Reply-To: <4FC47F4A.2040800@uljanik.hr> References: <4FC37B2E.1050200@uljanik.hr> <4FC47F4A.2040800@uljanik.hr> Message-ID: Hi Gordan, Gordan Sikic writes: > It is the similar problem as explained in "2010-september" thread. There > are couple of mutually unrelated schemas, and every schema is compiled > into one dll. On many places in schemas, string enumerations are used, > and it turns out that resulting classes in c++ are inherited from > ::xml_schema::string. > > [...] > > I tried it (and followed it correctly), more than once. In this case you will need to create another (root) DLL which will contain just xml-schema.hxx (generated with the --export-xml-schema) option (step 1). You will also need to create a dummy xml-schema.cxx file (step 2). All your other schemas must be compiled with the --extern-xml-schema option to use this xml-schema.hxx from the root DLL and also link to this root DLL (step 3). Have you done all of this? > Maybe you can (if possible) send me example that is used in thread > you refer to, so I can check it as well? Unfortunately I cannot do this since it was provided by a customer and we agreed not to make it public. > Maybe I was little bit vague in my explanation. When I wrote > automatically, I did not mean obligatory, just possibly, as some kind of > command line option (some kind of regex?). Yes, I understand. > Ok, I understand that it is not route you are willing to take. > I would just like to ask why do you think it is a problem to have > hundreds of export macros within class, after all, it is automatically > generated code? The problem is not with classes that are generated from your schema (there it will be relatively easy to add export macros for each function provided, of course, there are no silly limitations/bugs that would prevent us from exporting special functions, like c-tors, assignement operators, etc). The problem is with the built-in types. Thease are hand-written class templates that reside in libxsd and some of them also derive from std::string. The XSD compiler simply generate a typedef for these types in the xml_schema namespace (and template class EXPORT_MACROS foo if exporting was requested). With the approach you are proposing we will have to make the XSD compiler generate an export directive (if such exists) for each member function in each such built-in type. I would expect there will be hundreds of them. Plus, every time we add or remove a member function from a built-in type, we will have to remember to update the XSD compiler as well. Boris From owagh at tower-research.com Wed May 30 16:36:36 2012 From: owagh at tower-research.com (Omkar Wagh) Date: Wed May 30 16:36:40 2012 Subject: [xsd-users] copying IDREF elements classes Message-ID: <4FC684D4.5010103@tower-research.com> Hey I want to be able to copy IDREF structs. So I have something like this :- Now, I'm using xsd and cxx-tree and I want to be able to construct instances of class some_bigger_unit from instances of class some_unit. However, thanks to the auto_pointer thing, if I do that, the original class looses ownership of the pointer to the referenced element (or so I believe). How do I work around this thing? Is there any way to use standard pointers instead of auto_ptrs? Will simply detaching the root node work? Alternatively, how do I copy elements that contain IDREF elements as children? Omkar From boris at codesynthesis.com Thu May 31 03:38:44 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 31 03:38:51 2012 Subject: [xsd-users] copying IDREF elements classes In-Reply-To: <4FC684D4.5010103@tower-research.com> References: <4FC684D4.5010103@tower-research.com> Message-ID: Hi Omkar, Omkar Wagh writes: > I want to be able to copy IDREF structs. > > > > > > > > > > > > > > > Now, I'm using xsd and cxx-tree and I want to be able to construct > instances of class some_bigger_unit from instances of class some_unit. I am not sure what the issue is. You can do: some_unit u1 ("id1"), u2 ("id2); some_bigger_unit bu (u1, u2); some_bigger_unit bu2 (bu.unit2 (), bu.unit1 ()); > However, thanks to the auto_pointer thing, if I do that, the original > class looses ownership of the pointer to the referenced element (or so > I believe). I am not sure what you mean here? Are you detaching some_unit instance from some other tree? That's the only way to get an auto_ptr in C++/Tree. I think it will be the best if you show some sample code that doesn't work for you (always a good idea). Boris From owagh at tower-research.com Thu May 31 10:53:59 2012 From: owagh at tower-research.com (Omkar Wagh) Date: Thu May 31 10:54:04 2012 Subject: [xsd-users] copying IDREF elements classes In-Reply-To: References: <4FC684D4.5010103@tower-research.com> Message-ID: <4FC78607.50203@tower-research.com> hi On 05/31/2012 03:38 AM, Boris Kolpackov wrote: > Hi Omkar, > > Omkar Wagh writes: > >> I want to be able to copy IDREF structs. >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Now, I'm using xsd and cxx-tree and I want to be able to construct >> instances of class some_bigger_unit from instances of class some_unit. > I am not sure what the issue is. You can do: > > some_unit u1 ("id1"), u2 ("id2); > some_bigger_unit bu (u1, u2); > some_bigger_unit bu2 (bu.unit2 (), bu.unit1 ()); > >> However, thanks to the auto_pointer thing, if I do that, the original >> class looses ownership of the pointer to the referenced element (or so >> I believe). > I am not sure what you mean here? Are you detaching some_unit instance > from some other tree? That's the only way to get an auto_ptr in C++/Tree. > I think it will be the best if you show some sample code that doesn't > work for you (always a good idea). > > Boris Yeah I think I'll try to post some more code. The entire code is a bit complex but essentially it's something like this :- document doc = document_(filename); Now, at some point in the code, I have with me two references to some_bigger_unit say sbu1, sbu2. I want to do this :- some_bigger_unit sbu_new (sbu1.unit1(), sbu2.unit1()); Now if I try to dereference the element that sbu_new.unit1() should point to, I get a dynamic cast failure. Basically, referenced_class& myclass ( dynamic_cast (* ( sbu_new.unit1() ) ) ); doesn't work since sbu_new.unit1() doesn't point to anything. On the other hand, referenced_class& myclass ( dynamic_cast (* ( sbu1.unit1() ) ) ); works perfectly fine. thanks Omkar From boris at codesynthesis.com Thu May 31 12:16:58 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 31 12:17:05 2012 Subject: [xsd-users] copying IDREF elements classes In-Reply-To: <4FC78607.50203@tower-research.com> References: <4FC684D4.5010103@tower-research.com> <4FC78607.50203@tower-research.com> Message-ID: Hi Omkar, Omkar Wagh writes: > document doc = document_(filename); > > some_bigger_unit sbu_new (sbu1.unit1(), sbu2.unit1()); > > Now if I try to dereference the element that sbu_new.unit1() should > point to, I get a dynamic cast failure. The id references are resolved in the tree to which a node belongs. In your example sbu1 and sbu2 belong to the doc tree. But your sbu_new doesn't belong to any bigger tree so the reference cannot be resolved. If you add sbu_new to the doc tree, then the references will resolve. You can also "fake" a node as belonging to a tree by setting its container node, for example: sbu_new._container (&doc); Boris From owagh at tower-research.com Thu May 31 12:48:10 2012 From: owagh at tower-research.com (Omkar Wagh) Date: Thu May 31 12:48:14 2012 Subject: [xsd-users] copying IDREF elements classes In-Reply-To: References: <4FC684D4.5010103@tower-research.com> <4FC78607.50203@tower-research.com> Message-ID: <4FC7A0CA.2070000@tower-research.com> Hi Boris On 05/31/2012 12:16 PM, Boris Kolpackov wrote: > Hi Omkar, > > Omkar Wagh writes: > >> document doc = document_(filename); >> >> some_bigger_unit sbu_new (sbu1.unit1(), sbu2.unit1()); >> >> Now if I try to dereference the element that sbu_new.unit1() should >> point to, I get a dynamic cast failure. > The id references are resolved in the tree to which a node belongs. In > your example sbu1 and sbu2 belong to the doc tree. But your sbu_new > doesn't belong to any bigger tree so the reference cannot be resolved. > If you add sbu_new to the doc tree, then the references will resolve. > You can also "fake" a node as belonging to a tree by setting its > container node, for example: > > sbu_new._container (&doc); This sounds exactly like what I need. I'll test it and post if it solves my problems. > > Boris Thanks a lot. From owagh at tower-research.com Thu May 31 13:29:30 2012 From: owagh at tower-research.com (Omkar Wagh) Date: Thu May 31 13:29:33 2012 Subject: [xsd-users] how do i use xse:refType with extra attribute? Message-ID: <4FC7AA7A.1020802@tower-research.com> I have the following schema :- This doesn't work as expected i.e. reference does not return some_type_T but returns ::xml_schema::idref Any idea how to work around this? Omkar From boris at codesynthesis.com Thu May 31 14:41:25 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu May 31 14:41:30 2012 Subject: [xsd-users] how do i use xse:refType with extra attribute? In-Reply-To: <4FC7AA7A.1020802@tower-research.com> References: <4FC7AA7A.1020802@tower-research.com> Message-ID: Hi Omkar, Omkar Wagh writes: > I have the following schema :- > > > > > > > > > > > > > > No, this won't work. We don't generate a template for ref_T which can later be specialized with a referenced type. This, however, will work: Boris From owagh at tower-research.com Thu May 31 15:03:41 2012 From: owagh at tower-research.com (Omkar Wagh) Date: Thu May 31 15:03:45 2012 Subject: [xsd-users] how do i use xse:refType with extra attribute? In-Reply-To: References: <4FC7AA7A.1020802@tower-research.com> Message-ID: <4FC7C08D.401@tower-research.com> Hi Boris. On 05/31/2012 02:41 PM, Boris Kolpackov wrote: > Hi Omkar, > > Omkar Wagh writes: > >> I have the following schema :- >> >> >> >> >> >> >> >> >> >> >> >> >> >> > No, this won't work. We don't generate a template for ref_T which > can later be specialized with a referenced type. This, however, will > work: > > > > > > > > > > > > > > It looks like this should work but it doesn't. xsd quits with the following :- xsd: /apps/stonefs1/owagh/softwares/xsd-3.3.0+dep/libxsd-frontend/xsd-frontend/semantic-graph/elements.hxx:411: XSDFrontend::SemanticGraph::Scope& XSDFrontend::SemanticGraph::Nameable::scope(): Assertion `named_p ()' failed. Omkar > > Boris