From boris at codesynthesis.com Thu Mar 1 10:48:22 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 1 10:40:59 2012 Subject: [xsd-users] multiple schemas in one program In-Reply-To: <4FAE773E-C41B-4E2E-BD3A-D3E8CA1EA39C@llnl.gov> References: <4FAE773E-C41B-4E2E-BD3A-D3E8CA1EA39C@llnl.gov> Message-ID: Hi Rich, Cook, Rich writes: > I am now having trouble using two different parsers in the same program: > One I built like this: > xsd cxx-tree --generate-serialization PursuerInputSchema.xsd > And one I built like this: > xsd cxx-parser PursuerDCDataSchema.xsd > > The trouble I'm having is each declares xml_schema::qname differently, > this causes a compiler error if I include both PursuerDCDataSchema.hxx > and PursuerInputSchema.hxx in the same source file. Normally, you would use one mapping (cxx-tree or cxx-parser) in an application (in other words, you normally only need to use cxx-tree or cxx-parser, but not both). There are cases where one would want to use several different mappings in the same application. In that case, you will need to re-map the XML Schema namespace in one of them to something other that xml_schema. For example: xsd cxx-tree --generate-serialization PursuerInputSchema.xsd xsd cxx-parser --namespace-map http://www.w3.org/2001/XMLSchema=xml_schema_parser \ PursuerDCDataSchema.xsd Boris From cook47 at llnl.gov Thu Mar 1 13:36:24 2012 From: cook47 at llnl.gov (Cook, Rich) Date: Fri Mar 2 04:59:01 2012 Subject: [xsd-users] multiple schemas in one program In-Reply-To: References: <4FAE773E-C41B-4E2E-BD3A-D3E8CA1EA39C@llnl.gov> Message-ID: Aha, I looked at --namespace-map but would never would have guessed that URL went there for any reason! Thanks -- Rich On Mar 1, 2012, at 7:48 AM, Boris Kolpackov wrote: > Hi Rich, > > Cook, Rich writes: > >> I am now having trouble using two different parsers in the same program: >> One I built like this: >> xsd cxx-tree --generate-serialization PursuerInputSchema.xsd >> And one I built like this: >> xsd cxx-parser PursuerDCDataSchema.xsd >> >> The trouble I'm having is each declares xml_schema::qname differently, >> this causes a compiler error if I include both PursuerDCDataSchema.hxx >> and PursuerInputSchema.hxx in the same source file. > > Normally, you would use one mapping (cxx-tree or cxx-parser) in an > application (in other words, you normally only need to use cxx-tree > or cxx-parser, but not both). There are cases where one would want > to use several different mappings in the same application. In that > case, you will need to re-map the XML Schema namespace in one of > them to something other that xml_schema. For example: > > xsd cxx-tree --generate-serialization PursuerInputSchema.xsd > xsd cxx-parser --namespace-map http://www.w3.org/2001/XMLSchema=xml_schema_parser \ > PursuerDCDataSchema.xsd > > Boris -- ?Richard Cook ? Lawrence Livermore National Laboratory Bldg-453 Rm-4024, Mail Stop L-557 7000 East Avenue, Livermore, CA, 94550, USA ? (office) (925) 423-9605 ? (fax) (925) 423-6961 --- Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept. (opinions expressed herein are mine and not those of LLNL) From verimart at hotmail.com Fri Mar 2 14:47:10 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Fri Mar 2 14:47:18 2012 Subject: [xsd-users] Linking errors (not Xerces, I believe) with date_time types in VS2010 Message-ID: Hello, I am setting up xsd usage on a project for the first time. I followed the Visual Studio 2010 configuration steps and have added the Xerces library to my link path and libs. However, when I build my project it appears that any schema element typed as xsd:dateTime the generated code for those elements produces this error message: error LNK2001: unresolved external symbol "public: __thiscall xsd::cxx::tree::date_time >::date_time >(class std::basic_string,class std::allocator > const &,class xercesc_3_1::DOMElement const *,class xsd::cxx::tree::flags,class xsd::cxx::tree::_type *)" (??0?$date_time@_WV?$simple_type@V_type@tree@cxx@xsd@@@tree@cxx@xsd@@@tree@cxx@xsd@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PBVDOMElement@xercesc_3_1@@Vflags@123@PAV_type@123@@Z) ...what am I doing wrong? Thanks,James From verimart at hotmail.com Fri Mar 2 15:19:36 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Fri Mar 2 15:19:43 2012 Subject: [xsd-users] Linking errors (not Xerces, I believe) with date_time types in VS2010 In-Reply-To: References: Message-ID: I think this is a problem with the constructor I've use. I'm trying to construct the date_time types using a constructor that accepts a string followed by a Xerces DOM pointer, a flag, and a cxx::tree::container argument , all of which I'm setting to 0 as follows: theVariable(L"2011-09-01T19:40:11Z", 0); I can't tell from the mapping documentation what this constructor is intended to be used for, but I guess I can't construct a dateTime type with a string representation of the date/time. Seems like the right thing to do is use one of these constructors instead? date_time (int year, unsigned short month, unsigned short day, unsigned short hours, unsigned short minutes, double seconds); date_time (int year, unsigned short month, unsigned short day, unsigned short hours, unsigned short minutes, double seconds, short zone_hours, short zone_minutes); James > To: xsd-users@codesynthesis.com > Date: Fri, 2 Mar 2012 12:47:10 -0700 > Subject: [xsd-users] Linking errors (not Xerces, I believe) with date_time types in VS2010 > > > Hello, > I am setting up xsd usage on a project for the first time. I followed the Visual Studio 2010 configuration steps and have added the Xerces library to my link path and libs. However, when I build my project it appears that any schema element typed as xsd:dateTime the generated code for those elements produces this error message: > error LNK2001: unresolved external symbol "public: __thiscall xsd::cxx::tree::date_time >::date_time >(class std::basic_string,class std::allocator > const &,class xercesc_3_1::DOMElement const *,class xsd::cxx::tree::flags,class xsd::cxx::tree::_type *)" (??0?$date_time@_WV?$simple_type@V_type@tree@cxx@xsd@@@tree@cxx@xsd@@@tree@cxx@xsd@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PBVDOMElement@xercesc_3_1@@Vflags@123@PAV_type@123@@Z) > > ...what am I doing wrong? > Thanks,James From verimart at hotmail.com Fri Mar 2 17:29:28 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Fri Mar 2 17:29:36 2012 Subject: [xsd-users] Serialize elements to xml with no namespace decorations In-Reply-To: References: , Message-ID: I have a case where I need to be able to serialize out to an XML file incrementally as data is made available rather thanloading an entire object model into memory and then write the whole thing out in one go. For example, I'd like to create a file, write out the opening tag for the root node, then make multiple callsto the ostream functions to write out new child elements as the data is made available. Once all the data'sbeen processed, close out the root node tag and call the file complete. Is this usage model supported by the generated code? I've been trying, for example, to just serialize a single element with no namespace decorations whatsoever on theelements, but the default code always inserts namespace information. Any suggestions? Thanks,James From tomislav.reichenbach at valida.at Mon Mar 5 04:57:22 2012 From: tomislav.reichenbach at valida.at (tomislav.reichenbach@valida.at) Date: Mon Mar 5 09:06:09 2012 Subject: [xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue Message-ID: Hello, I have a problem using CodeSythesis XSD - CXX Tree generated classes when using generated serialization functions from more threads. Basically, the setup is following, the code is compiled as dlls and then deployed on server. The Dlls are loaded only once and upon loading the xercesc::XMLPlatformUtils::Initialize () is called (once). (On shutdown the xercesc::XMLPlatformUtils::Terminate () is called to release the library.) This is in line with the "3.4 Thread Safety" chapter from " C++/Tree Mapping Getting Started Guide". Normally everything works perfect. However, during the last/stress testing with particular configuration there were problems. To reproduce the errors, the thread count should be 20+ , and objects to be serialized shoud be sufficiently large (requiring more than 1s per serialization call). The serialized xml is then sometimes (roughly 75%) incomplete -- the last part is missing (not always the same tags). Introducing a mutex before serialization prevents errors, but I have an usage question, is this supposed to be so ? To me this FAQ part is unclear : "XSD-generated code is thread-safe in the sense that you can use different instantiations of the object model in several threads concurrently. This is possible due to the generated code not relying on any writable global variables. If you need to share the same object between several threads then you will need to provide some form of synchronization." Per thread the order of executions is as follows: string calculate(string input_xml) { input xml->istringstream->create input objects --- do some suff with objects --- output object->serialize-> output xml return output_xml } There are no shared (global, static or singleton) objects in the calculate function. Another remark, I have not been able to reproduce this error on my development machine (Core 2 Duo, winXP), only on server (4xCPU, win2003 server). Thanks. Best regards Tom From boris at codesynthesis.com Mon Mar 5 09:24:21 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 5 09:18:19 2012 Subject: [xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue In-Reply-To: References: Message-ID: Hi Tom, tomislav.reichenbach@valida.at writes: > Introducing a mutex before serialization prevents errors, but I have an > usage question, is this supposed to be so ? > To me this FAQ part is unclear : > > [...] > > Per thread the order of executions is as follows: > > string calculate(string input_xml) { > input xml->istringstream->create input objects > --- do some suff with objects --- > output object->serialize-> output xml > return output_xml > } > > There are no shared (global, static or singleton) objects in the calculate > function. This should work without the mutex serializing calculate() executions. A few points to confirm/verify: 1. You said you are calling Xerces-C++ Initialize()/Terminate(). Do you also pass dont_initialize flag to the XSD parsing and serialization functions? 2. Are you using the latest version of Xerces-C++ (3.1.1)? Is it a default build (i.e., using default transcoder, etc)? 3. How do you see that the XML is incomplete? Do you write it to a file? Is it possible that not all the data has been flushed yet? Can you confirm that the object model is complete (i.e., that it is parsed correctly and the problem is in serialization)? Boris From boris at codesynthesis.com Mon Mar 5 09:40:40 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 5 09:34:36 2012 Subject: [xsd-users] Linking errors (not Xerces, I believe) with date_time types in VS2010 In-Reply-To: References: Message-ID: Hi James, James & Veri Martin writes: > I think this is a problem with the constructor I've use. I'm trying to > construct the date_time types using a constructor that accepts a string > followed by a Xerces DOM pointer, a flag, and a cxx::tree::container > argument , all of which I'm setting to 0 as follows: > > theVariable(L"2011-09-01T19:40:11Z", 0); You are using the parsing constructor. The only situation that I can think of that will result in the linker error you've showed is if you disabled parsing support (--suppress-parsing). Otherwise the constructor implementation is include into the generated header file. > I can't tell from the mapping documentation what this constructor is > intended to be used for, but I guess I can't construct a dateTime > type with a string representation of the date/time. It is normally not used directly, but you can use it if you need to. > Seems like the right thing to do is use one of these constructors instead? > > date_time (int year, unsigned short month, unsigned short day, > unsigned short hours, unsigned short minutes, > double seconds); > > date_time (int year, unsigned short month, unsigned short day, > unsigned short hours, unsigned short minutes, > double seconds, short zone_hours, short zone_minutes); Yes, that's the constructors that are normally used. Boris From boris at codesynthesis.com Mon Mar 5 09:51:48 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 5 09:45:45 2012 Subject: [xsd-users] Serialize elements to xml with no namespace decorations In-Reply-To: References: Message-ID: Hi James, James & Veri Martin writes: > I have a case where I need to be able to serialize out to an XML file > incrementally as data is made available rather thanloading an entire object > model into memory and then write the whole thing out in one go. For > example, I'd like to create a file, write out the opening tag for the root > node, then make multiple callsto the ostream functions to write out new > child elements as the data is made available. Once all the data'sbeen > processed, close out the root node tag and call the file complete. Is this > usage model supported by the generated code? Yes, see the 'streaming' example. > I've been trying, for example, to just serialize a single element with > no namespace decorations whatsoever on theelements, but the default code > always inserts namespace information. This is a Xerces-C++ limitation that we are planning to fix for the next release (i.e., allow serialization of an XML fragment as if it was in a context of some outer element). For now, depending on how your schema, uses XML namespaces, you may have to live with some extra namespace information. Boris From boris at codesynthesis.com Tue Mar 6 09:05:15 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Mar 6 08:59:15 2012 Subject: [xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue In-Reply-To: References: Message-ID: Hi Tom, In the future please keep your replies CC'ed to the xsd-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml tomislav.reichenbach@valida.at writes: > > 3. How do you see that the XML is incomplete? Do you write it to a file? > > Is it possible that not all the data has been flushed yet? Can you > > confirm that the object model is complete (i.e., that it is parsed > > correctly and the problem is in serialization)? > > The thread is finished and returns with incomplete result. The model is > parsed correctly, afterwards the calculation with the parsed model are > done, and only then in the serialization phase the error occurs. I have > spent some time analyzing the code and trying to see where it happens > and have narrow it the the serialization call. By "the error occurs" do you mean that an exception is thrown? Or does the thread complete without any errors but the written XML is incomplete? What happens if you disable your calculation code (i.e., just parse XML into the object model and then write this object model back to XML without any modifications)? If none of this makes any difference, then the next step would be to determine whether this is an XSD problems or a Xerces-C++ problem by removing XSD from the equation. Right now, when you call an XSD-generated parsing function, it first parses XML to DOM and then parses DOM to the object model. Similarly, when you call the serialization function, it first creates DOM from the object model and then serializes DOM to XML. The idea is to just do: XML->DOM->XML. Will you be able to modify your code to do this? You can find ready-to-use functions for DOM parsing and serialization in the 'messaging' example (see the dom-{parse,serialize}.?xx files). Boris From verimart at hotmail.com Tue Mar 6 12:39:54 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Tue Mar 6 12:40:02 2012 Subject: [xsd-users] Serialize elements to xml with no namespace decorations In-Reply-To: References: , Message-ID: > Yes, see the 'streaming' example. Great - thanks! > This is a Xerces-C++ limitation that we are planning to fix for the next > release (i.e., allow serialization of an XML fragment as if it was in > a context of some outer element). For now, depending on how your schema, > uses XML namespaces, you may have to live with some extra namespace > information. Ok - thank you. It looks like the generated serialization code can also be modified to replace the generated namespace values with empty strings as a workaround, which omits these attributes during serialization. This isn't preferable obviously, but for this specific usage it seems workable since the root element is getting written out manually. James From verimart at hotmail.com Tue Mar 6 12:42:31 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Tue Mar 6 12:42:39 2012 Subject: [xsd-users] Linking errors (not Xerces, I believe) with date_time types in VS2010 In-Reply-To: References: , Message-ID: > You are using the parsing constructor. The only situation that I can > think of that will result in the linker error you've showed is if you > disabled parsing support (--suppress-parsing). Otherwise the constructor > implementation is include into the generated header file. Yes, this was my codegen configuration. Thanks for the explanation... From verimart at hotmail.com Tue Mar 6 22:35:26 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Tue Mar 6 22:35:34 2012 Subject: [xsd-users] Static linking Message-ID: Hi Boris, In building projects with the c++/tree libraries, in order to run they require the xerces dll to be present on the target system. Is there a way to produce a fully statically-linked project? Not sure I was looking in the right place, but couldn't find information on this in the guide docs. Thanks,James From verimart at hotmail.com Tue Mar 6 22:59:00 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Tue Mar 6 22:59:08 2012 Subject: [xsd-users] Elements with CDATA content Message-ID: I have string-based elements in my schema for which I'd like to use CDATA content. I found this posting regarding the treatment of elements with CDATA content: http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001590.html ...but it dates from 2008. I am wondering if the techniques referenced there are currently the only mechanisms for including CDATA content in an xs:string-based element? Is there not an attribute I can set on an instance of a generated class for such elements that instructs serialization to enclose the content in a CDATA section? I couldn't find any mention of CDATA content in the guide docs or the wiki. Thanks,James From tomislav.reichenbach at valida.at Wed Mar 7 05:06:42 2012 From: tomislav.reichenbach at valida.at (tomislav.reichenbach@valida.at) Date: Wed Mar 7 05:24:05 2012 Subject: Antwort: Re: [xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue In-Reply-To: References: Message-ID: Hi Boris, boris@codesynthesis.com schrieb am 06.03.2012 15:05:15: > Von: boris@codesynthesis.com > An: tomislav.reichenbach@valida.at > Kopie: xsd-users@codesynthesis.com > Datum: 06.03.2012 14:59 > Betreff: Re: [xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue > > Hi Tom, > > In the future please keep your replies CC'ed to the xsd-users mailing > list as discussed in the posting guidelines: > > http://www.codesynthesis.com/support/posting-guidelines.xhtml > > sorry pressed reply, instead of reply-all > tomislav.reichenbach@valida.at writes: > > > > 3. How do you see that the XML is incomplete? Do you write it to a file? > > > Is it possible that not all the data has been flushed yet? Can you > > > confirm that the object model is complete (i.e., that it is parsed > > > correctly and the problem is in serialization)? > > > > The thread is finished and returns with incomplete result. The model is > > parsed correctly, afterwards the calculation with the parsed model are > > done, and only then in the serialization phase the error occurs. I have > > spent some time analyzing the code and trying to see where it happens > > and have narrow it the the serialization call. > > By "the error occurs" do you mean that an exception is thrown? Or does > the thread complete without any errors but the written XML is incomplete? I get both, roughly .. ... 30% of return happens with an exception thrown, unfortunatelly the one I cannot catch with all FAQ catch variants, only with catch(...). ... 60% of return have incomplete XML (no exception is thrown) ... 10% have correct return XML > > What happens if you disable your calculation code (i.e., just parse XML > into the object model and then write this object model back to XML without > any modifications)? Input and output have different structure. Calculation function instantiates new output objects. (Input size is 5KB vs Output size of 1585KB) > > If none of this makes any difference, then the next step would be to > determine whether this is an XSD problems or a Xerces-C++ problem by > removing XSD from the equation. Right now, when you call an XSD-generated > parsing function, it first parses XML to DOM and then parses DOM to the > object model. Similarly, when you call the serialization function, it > first creates DOM from the object model and then serializes DOM to XML. > The idea is to just do: XML->DOM->XML. Will you be able to modify your > code to do this? You can find ready-to-use functions for DOM parsing and > serialization in the 'messaging' example (see the dom-{parse,serialize}.?xx > files). I can make the modifications, and I will try to implement them and report the outcome. > > Boris regards Tom From boris at codesynthesis.com Wed Mar 7 05:37:42 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 7 05:31:45 2012 Subject: [xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue In-Reply-To: References: Message-ID: Hi Tom, tomislav.reichenbach@valida.at writes: > > By "the error occurs" do you mean that an exception is thrown? Or does > > the thread complete without any errors but the written XML is incomplete? > > I get both, roughly .. > > ... 30% of return happens with an exception thrown, unfortunatelly the one > I cannot catch with all FAQ catch variants, only with catch(...). > > ... 60% of return have incomplete XML (no exception is thrown) > > ... 10% have correct return XML Hm, this is very strange. Do you catch all the exceptions, including the Xerces-C++ ones? If that's the case, then chances are high this is an access violation exception (will also explain why you sometimes get just the incorrect behavior without an exception). Ideally, you would want to run this application under a debugger (or let it crash and then load it into the debugger to examine the stack trace) to figure out what kind of exception it is. > Input and output have different structure. Calculation function > instantiates new output objects. (Input size is 5KB vs Output size > of 1585KB) > > [...] > > I can make the modifications, and I will try to implement them and > report the outcome. You could change your code to send the output XML as input. Then parse it to DOM and serialize it back to XML. Boris From boris at codesynthesis.com Wed Mar 7 05:46:33 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 7 05:40:35 2012 Subject: [xsd-users] Static linking In-Reply-To: References: Message-ID: Hi James, James & Veri Martin writes: > In building projects with the c++/tree libraries, in order to run they > require the xerces dll to be present on the target system. Is there a > way to produce a fully statically-linked project? You just need to link to the static Xerces-C++ library: xerces-c_static_3.lib (Release xerces-c_static_3D.lib (Debug) Also don't forget to define the XERCES_STATIC_LIBRARY macro when building your application. Boris From boris at codesynthesis.com Wed Mar 7 05:50:07 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 7 05:44:14 2012 Subject: [xsd-users] Elements with CDATA content In-Reply-To: References: Message-ID: Hi James, James & Veri Martin writes: > > I have string-based elements in my schema for which I'd like to use CDATA > content. I found this posting regarding the treatment of elements with > CDATA content: > > http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001590.html > > ...but it dates from 2008. I am wondering if the techniques referenced > there are currently the only mechanisms for including CDATA content in > an xs:string-based element? Yes, these are the options. > Is there not an attribute I can set on an instance of a generated class > for such elements that instructs serialization to enclose the content in > a CDATA section? No, there is no such attribute. But you can always provide a custom mapping for the xs:string type which will allow you to set a flag and then serialize the data as either normal text or CDATA, depending on this flag. Boris From verimart at hotmail.com Wed Mar 7 07:10:04 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Wed Mar 7 07:10:12 2012 Subject: [xsd-users] Elements with CDATA content In-Reply-To: References: , Message-ID: > No, there is no such attribute. But you can always provide a custom> mapping for the xs:string type which will allow you to set a flag and> then serialize the data as either normal text or CDATA, depending on> this flag. Ok - thanks. Looks like I have a date with the customization guide. From verimart at hotmail.com Wed Mar 7 07:11:00 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Wed Mar 7 07:11:07 2012 Subject: [xsd-users] Static linking In-Reply-To: References: , , Message-ID: > Also don't forget to define the XERCES_STATIC_LIBRARY macro when building > your application. ...ah - that's what I was missing. New to xerces. Thanks! From verimart at hotmail.com Wed Mar 7 07:27:32 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Wed Mar 7 07:27:39 2012 Subject: [xsd-users] Static linking In-Reply-To: References: , , , , , Message-ID: > You just need to link to the static Xerces-C++ library: > > xerces-c_static_3.lib (Release > xerces-c_static_3D.lib (Debug) I cannot find these libraries anywhere in the XSD 3.3 distribution installed on my system. Could I have goofed the install somehow? From verimart at hotmail.com Wed Mar 7 09:18:52 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Wed Mar 7 09:19:01 2012 Subject: [xsd-users] Elements with CDATA content In-Reply-To: References: , Message-ID: Hi Boris, Forgive my ignorance, but I'm not seeing an obvious way to use custom classes to insert a CDATA section in an element as described in option 2 described below: > > http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001590.html > The difficulty I'm having is that, from the examples I've found showing how to use the xerces dom to insert cdata sections I need a DOMDocument instance that I use to create a cdata section that can then be appended as a child to the element that I'm trying to serialize. In the serialization operator, I have a reference to a DOMElement instance and a reference to an instance of my custom type, but no DOMDocument, and I can't see how to preprocess the custom type instance prior to serializing it onto the DOMElement reference in order to add the cdata section. Any suggestions or code snippets to get me off the ground? Thanks,James From boris at codesynthesis.com Wed Mar 7 09:25:14 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 7 09:19:16 2012 Subject: [xsd-users] Static linking In-Reply-To: References: Message-ID: Hi James, James & Veri Martin writes: > > xerces-c_static_3.lib (Release > > xerces-c_static_3D.lib (Debug) > > I cannot find these libraries anywhere in the XSD 3.3 distribution > installed on my system. Static libraries are not included in the XSD .msi installer (too big). But you can get them in the binary distribution from the Xerces-C++ website: http://xerces.apache.org/xerces-c/download.cgi Or you can build them yourself if you installed the Xerces-C++ source code during XSD installation. Boris From verimart at hotmail.com Wed Mar 7 09:21:48 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Wed Mar 7 09:21:55 2012 Subject: [xsd-users] Static linking In-Reply-To: References: , Message-ID: > Static libraries are not included in the XSD .msi installer (too big). Yes, I agree - I got them from the distribution and decided against static linking for that reason. Thanks! From boris at codesynthesis.com Wed Mar 7 09:33:06 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 7 09:27:07 2012 Subject: [xsd-users] Elements with CDATA content In-Reply-To: References: Message-ID: Hi James, James & Veri Martin writes: > The difficulty I'm having is that, from the examples I've found showing > how to use the xerces dom to insert cdata sections I need a DOMDocument > instance that I use to create a cdata section that can then be appended > as a child to the element that I'm trying to serialize. In the > serialization operator, I have a reference to a DOMElement instance and > a reference to an instance of my custom type, but no DOMDocument, You can call the getOwnerDocument() function on the DOMElement to get DOMDocument. This is covered in Xerces-C++ documentation. > and I can't see how to preprocess the custom type instance prior to > serializing it onto the DOMElement reference in order to add the > cdata section. I don't understand what you mean by "preprocess" here. Boris From verimart at hotmail.com Wed Mar 7 09:55:39 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Wed Mar 7 09:55:50 2012 Subject: [xsd-users] Elements with CDATA content In-Reply-To: References: , Message-ID: > I don't understand what you mean by "preprocess" here. The custom type instance in the serialization operator represents the element for which I want the CDATA content, and my understanding is that the CDATA section is treated in the DOM as a child element of the to-be-serialized type. By "preprocess" I am referring to what needs to be done, if anything, with the custom type reference prior to serializing it to the DOMElement instance in the serialization operator. If I first do something like this: void operator<< (xercesc::DOMElement& e, const CustomType& x) { const CustomType_base &b(x); e << b; } ...the text data from instance x, together with the attributes that are defined for it, would be written to the DOMElement instance without the cdata section. So how do I add the cdata section as a child of the element represented by CustomType instance x? From verimart at hotmail.com Wed Mar 7 19:22:52 2012 From: verimart at hotmail.com (James & Veri Martin) Date: Wed Mar 7 19:22:59 2012 Subject: [xsd-users] Elements with CDATA content In-Reply-To: References: , , , , Message-ID: Answer to my question: > So how do I add the cdata section as a child of the element represented by CustomType instance x? ...simpler than I was thinking: #include operator<< (xercesc::DOMElement& e, const CustomType& x) { if ( x.hasCdata() ) { const CustomType_base &b(x); e << b; } else { // cdata text xercesc::DOMDocument &doc( *e.getOwnerDocument () ); xercesc::DOMCDATASection *cdat( doc.createCDATASection(x.data()) ); e.appendChild(cdat); // ...plus similar code for attributes defined for this node } } From boris at codesynthesis.com Thu Mar 8 04:28:19 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 8 04:22:25 2012 Subject: [xsd-users] help on stdout instead of stderr In-Reply-To: References: Message-ID: Hi Erik, Erik Sj?lund writes: > This is a very minor thing but why not print the help to stdout so we > could do > > xsd help cxx-tree | less > > instead of > > xsd help cxx-tree 2>&1 | less Yes, that makes sense. Fixed, thanks for reporting! Boris From tomislav.reichenbach at valida.at Fri Mar 9 03:36:42 2012 From: tomislav.reichenbach at valida.at (tomislav.reichenbach@valida.at) Date: Fri Mar 9 07:34:46 2012 Subject: Antwort: Re: [xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue In-Reply-To: References: Message-ID: Hi Boris, > Von: boris@codesynthesis.com > An: tomislav.reichenbach@valida.at > Kopie: xsd-users@codesynthesis.com > Datum: 07.03.2012 11:31 > Betreff: Re: [xsd-users] CodeSythesis XSD - CXX Tree Multithreading issue > > Hi Tom, > > tomislav.reichenbach@valida.at writes: > > > > By "the error occurs" do you mean that an exception is thrown? Or does > > > the thread complete without any errors but the written XML is incomplete? > > > > I get both, roughly .. > > > > ... 30% of return happens with an exception thrown, unfortunatelly the one > > I cannot catch with all FAQ catch variants, only with catch(...). > > > > ... 60% of return have incomplete XML (no exception is thrown) > > > > ... 10% have correct return XML > > Hm, this is very strange. Do you catch all the exceptions, including > the Xerces-C++ ones? If that's the case, then chances are high this > is an access violation exception (will also explain why you sometimes > get just the incorrect behavior without an exception). > > Ideally, you would want to run this application under a debugger (or > let it crash and then load it into the debugger to examine the stack > trace) to figure out what kind of exception it is. > Yep. That was basically the part where I stopped, and decided to contact codesythesis dev team ;) As I saw it there were two possible options. The problem is I have to run it on server. I cannot reproduce it manually. This involves modifying build script and CI server deployment process to deploy it remotely on the server and then trying with remote debugger (which leads to asking our IT support for the remote debugging installation and permissions) :| There was no need prior to debug remotely so this setup is something I'm doing right now ... (Also today I got a new dev PC - core i5 - so I'm gonna try to reproduce it locally). The other thing I'm trying is to catch all exceptions (via SEH) and try to log them. As I said, I'm 100% sure the error is in the serialization. Also what is left to try is to try the Xerces directly, as you suggested. Unfortunately, I have to do some other stuff, so I can't dedicate a lot to this problem, but I hope in next few days to try the above mentioned approaches. > > > Input and output have different structure. Calculation function > > instantiates new output objects. (Input size is 5KB vs Output size > > of 1585KB) > > > > [...] > > > > I can make the modifications, and I will try to implement them and > > report the outcome. > > You could change your code to send the output XML as input. Then parse > it to DOM and serialize it back to XML. > btw.. Compliments on your blog ! regards, Tom From pantoss at me.com Sat Mar 10 14:07:09 2012 From: pantoss at me.com (Stefan Pantos) Date: Sat Mar 10 14:07:19 2012 Subject: [xsd-users] Trying to generate a WSDL parser using xsd code synthesis Message-ID: Hi, I don't have much experience with xsd so I'm probably being stupid. I was wanting to try and create a WSDL parser using XSD Code Synthesis for a toy project. At the moment all I want to do is output the different parts of the WSDL (messages, types, bindings etc) but I'm falling at the first hurdles. Some of this is probably irrelevant but I'm putting in as much as I can think of just in case. So I ran xsd ('xsd cxx-tree --generate-wildcard wsdl.xsd') to generate the wsdl.cxx and wsdl.hxx files. the wsdl.xsd file is from http://schemas.xmlsoap.org/wsdl/ . The test file I'm using is Example 1 from http://www.w3.org/TR/wsdl . My very simple code is: 1 ::std::auto_ptr< ::wsdl::tDefinitions > definitions; 2 try 3 { 4 definitions = wsdl::definitions(inputfile); 5 } 6 catch (const xsd::cxx::tree::exception& e) { 7 cout << "Error " << e << endl; 8 return 1; 9 } 10 if (definitions.get() != NULL) 11 { 12 ::wsdl::tDefinitions::types_sequence types = definitions->types(); 13 for (::wsdl::tDefinitions::types_const_iterator type = types.begin(); 14 type != types.end(); 15 ++type) 16 { 17 cout << type->_node()->getNodeName() << endl; 18 } 19 } It compile without a problem but when I run it against my test file I get lots of errors which are like: Error test.wsdl:8:46 error: no declaration found for element 'definitions' So I switched of the validation off, this then causes a bad access signal at line 17. I'm using xsd-3.3.0-i686-macosx and xerces-c-3.1.1 in case this might have some bearing on the problem. What am I doing wrong? If it is some ridicules error which I've made and it is possible, I will want to try and parse the XSD xml in the type section. I had even more fun trying to do something with this because of the recursive nature of it's definition. Should I just give up on this or should this be possible too? Thanks, Stefan From d922qg at me.com Sun Mar 11 03:51:14 2012 From: d922qg at me.com (Stefan Pantos) Date: Mon Mar 12 01:07:37 2012 Subject: [xsd-users] Re: Trying to generate a WSDL parser using xsd code synthesis In-Reply-To: References: Message-ID: <608EE7F1-7D55-4B4C-8634-66CD699D8501@me.com> Ah, I worked it out! There are two things wrong. Firstly, in this version I forgot to make line 4 'definitions = wsdl::definitions(inputfile, ::xml_schema::flags::keep_dom);' and line 12 should have been made a reference to the sequence. I still don't understand all the validation errors, if anyone is able to enlighten me and I'm still wondering what the best way is to go about parsing XSD files for my own use. Thanks, Stefan On 10 Mar 2012, at 19:07, Stefan Pantos wrote: > Hi, > I don't have much experience with xsd so I'm probably being stupid. I was wanting to try and create a WSDL parser using XSD Code Synthesis for a toy project. At the moment all I want to do is output the different parts of the WSDL (messages, types, bindings etc) but I'm falling at the first hurdles. > > Some of this is probably irrelevant but I'm putting in as much as I can think of just in case. > > So I ran xsd ('xsd cxx-tree --generate-wildcard wsdl.xsd') to generate the wsdl.cxx and wsdl.hxx files. the wsdl.xsd file is from http://schemas.xmlsoap.org/wsdl/ . The test file I'm using is Example 1 from http://www.w3.org/TR/wsdl . > > My very simple code is: > > 1 ::std::auto_ptr< ::wsdl::tDefinitions > definitions; > 2 try > 3 { > 4 definitions = wsdl::definitions(inputfile); > 5 } > 6 catch (const xsd::cxx::tree::exception& e) { > 7 cout << "Error " << e << endl; > 8 return 1; > 9 } > 10 if (definitions.get() != NULL) > 11 { > 12 ::wsdl::tDefinitions::types_sequence types = definitions->types(); > 13 for (::wsdl::tDefinitions::types_const_iterator type = types.begin(); > 14 type != types.end(); > 15 ++type) > 16 { > 17 cout << type->_node()->getNodeName() << endl; > 18 } > 19 } > > > It compile without a problem but when I run it against my test file I get lots of errors which are like: > Error test.wsdl:8:46 error: no declaration found for element 'definitions' > > So I switched of the validation off, this then causes a bad access signal at line 17. I'm using xsd-3.3.0-i686-macosx and xerces-c-3.1.1 in case this might have some bearing on the problem. > > What am I doing wrong? > > If it is some ridicules error which I've made and it is possible, I will want to try and parse the XSD xml in the type section. I had even more fun trying to do something with this because of the recursive nature of it's definition. Should I just give up on this or should this be possible too? > > Thanks, > Stefan > > From hamishagi at yahoo.com Mon Mar 12 02:45:30 2012 From: hamishagi at yahoo.com (Wahid) Date: Mon Mar 12 02:45:38 2012 Subject: [xsd-users] segmentation fault when using --type-map Message-ID: <1331534730.76682.YahooMailClassic@web160901.mail.bf1.yahoo.com> Hi, I am new to this interesting area and this is my first question. I am reading the "C++/Parser Mapping Getting Started Guide" section 4(type mapping). I tried to repeat the same example given in this tutorial but get segmentation fault when executing the driver example. Here are the details. I will appreciate your kind help: people schema: ? ??? ????? ????? ??? ? ? ??? ????? ????? ????? ????? ??? ? ? ??? ????? ??? ? ? people.xml: ????? ??? John ??? Doe ??? male ??? 32 ? ? ??? Jane ??? Doe ??? female ??? 28 ? people.hxx : #include #include enum gender { ? male, ? female }; class person { public: ? person (const std::string& first, ????????? const std::string& last, ????????? ::gender gender, ????????? short age) ??? : first_ (first), last_ (last), ????? gender_ (gender), age_ (age) ? { ? } ? const std::string& ? first () const ? { ??? return first_; ? } ? const std::string& ? last () const ? { ??? return last_; ? } ? ::gender ? gender () const ? { ??? return gender_; ? } ? short ? age () const ? { ??? return age_; ? } private: ? std::string first_; ? std::string last_; ? ::gender gender_; ? short age_; }; typedef std::vector people; and finally people.map: include "people.hxx"; gender ::gender ::gender; person ::person; people ::people; the commands are: 1-xsd cxx-parser? --generate-print-impl --generate-test-driver --type-map people.map? people.xsd 2-c++ -I.../libxsd -c *.c* 3-c++ *.o -o driver -lxerces-c 4-? ./driver the output is: first-name: John last-name: Doe age: 32 Segmentation fault how to solve this issue and, more importantly, why am i getting this? thank you vahid From hamishagi at yahoo.com Mon Mar 12 04:52:20 2012 From: hamishagi at yahoo.com (Wahid) Date: Mon Mar 12 04:52:27 2012 Subject: [xsd-users] segmentation fault in the simplified library example(C++/Parser) Message-ID: <1331542340.5842.YahooMailClassic@web160906.mail.bf1.yahoo.com> Hi everyone, earlier today I posted a question regarding a segmentation fault I detected during C++/Parser practice(http://www.codesynthesis.com/pipermail/xsd-users/2012-March/003581.html) Moreover, I did some more testing and I can rephrase the same question in another form and another example: In the "xsd-3.3.0/examples/cxx/parser/library" example, the pimpl files are hand-written, if i just ignore them and ask the compiler to generate pskel and impml hxx&cxx files (with or without print implementation), I will get segmentation fault(while I shouldn't) could you help me with that? In short, just delete pskel and pimpl files, and keep the libary.map, driver.cxx and library.xsd& library xml file. Then let the following command creat the skeleton and implementation files for you: xsd cxx-parser? --generate-noop-impl? --type-map library.map library.xsd $c++ -I.../libxsd -c *.cxx $c++ *.o -o driver -lxerces-c $./driver library.xml Segmentation fault why am I getting this please? thank you From boris at codesynthesis.com Mon Mar 12 06:55:25 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 12 06:49:41 2012 Subject: [xsd-users] segmentation fault in the simplified library example(C++/Parser) In-Reply-To: <1331542340.5842.YahooMailClassic@web160906.mail.bf1.yahoo.com> References: <1331542340.5842.YahooMailClassic@web160906.mail.bf1.yahoo.com> Message-ID: Hi Wahid, Wahid writes: > Then let the following command creat the skeleton and implementation files > for you: > xsd cxx-parser --generate-noop-impl --type-map library.map library.xsd When you use a type map, generated post_*() callbacks have non-void return types. Take a look, for example, at the generated catalog_pimpl class. The post_catalog() callback has the following signature: virtual library::catalog post_catalog (); If you look at the generated implementation for this callback, you will see: library::catalog catalog_pimpl:: post_catalog () { // TODO // // return ... ; } As you can see, the comment even tells you that you must remember to return the value from this function! In more general terms, the generated implementations are just stubs that you must fill with actual code. When type maps are not used, the generated implementations will run as is (though won't do anything useful). If, however, you are using type maps, then you will need to fill in the implementations to at least return something. Boris From boris at codesynthesis.com Mon Mar 12 07:16:10 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 12 07:10:27 2012 Subject: [xsd-users] Re: Trying to generate a WSDL parser using xsd code synthesis In-Reply-To: <608EE7F1-7D55-4B4C-8634-66CD699D8501@me.com> References: <608EE7F1-7D55-4B4C-8634-66CD699D8501@me.com> Message-ID: Hi Stefan, Stefan Pantos writes: > Firstly, in this version I forgot to make line 4 'definitions = > wsdl::definitions(inputfile, ::xml_schema::flags::keep_dom);' You also need to remember to initialize Xerces-C++ yourself since you are using both keep_dom and --generate-wildcard. See documentation for these features for details. > I still don't understand all the validation errors, if anyone is able > to enlighten me Yes, see Q 2.1 in the C++/Tree Mapping FAQ: http://wiki.codesynthesis.com/Tree/FAQ > and I'm still wondering what the best way is to go about parsing XSD > files for my own use. Yes, that would be the next big question. Using data binding to parse WSDL files is definitely an interesting idea. However, as far as I remember, WSDL files can contain embedded XML Schema fragments (that describe messages). Unfortunately, XML Schema doesn't have a usable specification of itself (there is XMLSchema.xsd, but, funnily enough, it is not valid; good example of the "do as I say, not as I do" principle). Maybe it is possible to "fix it up" so that it is at least usable for data binding, if not validation. Other than that, your other options are: 1. Handle it as raw XML (e.g., using DOM). 2. Use Xerces-C++ schema representation. Not very easy to use though. However, you get error checking of the schema. 3. Use libxsd-frontend. This is an XML Schema compiler frontend that is used by both XSD and XSD/e. It provides a semantic graph of the schema model plus visitor-like traversal of this graph. Built on top of Xerces-C++. http://www.codesynthesis.com/projects/libxsd-frontend/ Boris From d922qg at me.com Mon Mar 12 11:41:33 2012 From: d922qg at me.com (Stefan Pantos) Date: Mon Mar 12 15:08:06 2012 Subject: [xsd-users] Trying to generate a WSDL parser using xsd code synthesis In-Reply-To: References: <608EE7F1-7D55-4B4C-8634-66CD699D8501@me.com> Message-ID: Thanks for the pointer about initialzing xerces-C++. After sending the second email I had another google and had found Q 2.1. I don't know how I missed it the first time. Sorry about that. Thanks for the advice about parsing the xsd. Exactly what I was looking for. I'll have a look at libxsd. Thanks once again, Stefan On 12 Mar 2012, at 11:16, Boris Kolpackov wrote: > Hi Stefan, > > Stefan Pantos writes: > >> Firstly, in this version I forgot to make line 4 'definitions = >> wsdl::definitions(inputfile, ::xml_schema::flags::keep_dom);' > > You also need to remember to initialize Xerces-C++ yourself since you > are using both keep_dom and --generate-wildcard. See documentation for > these features for details. > > >> I still don't understand all the validation errors, if anyone is able >> to enlighten me > > Yes, see Q 2.1 in the C++/Tree Mapping FAQ: > > http://wiki.codesynthesis.com/Tree/FAQ > > >> and I'm still wondering what the best way is to go about parsing XSD >> files for my own use. > > Yes, that would be the next big question. Using data binding to parse > WSDL files is definitely an interesting idea. However, as far as I > remember, WSDL files can contain embedded XML Schema fragments (that > describe messages). Unfortunately, XML Schema doesn't have a usable > specification of itself (there is XMLSchema.xsd, but, funnily enough, > it is not valid; good example of the "do as I say, not as I do" > principle). Maybe it is possible to "fix it up" so that it is at least > usable for data binding, if not validation. > > Other than that, your other options are: > > 1. Handle it as raw XML (e.g., using DOM). > > 2. Use Xerces-C++ schema representation. Not very easy to use though. > However, you get error checking of the schema. > > 3. Use libxsd-frontend. This is an XML Schema compiler frontend that > is used by both XSD and XSD/e. It provides a semantic graph of the > schema model plus visitor-like traversal of this graph. Built on > top of Xerces-C++. > > http://www.codesynthesis.com/projects/libxsd-frontend/ > > Boris From hamishagi at yahoo.com Mon Mar 12 23:00:55 2012 From: hamishagi at yahoo.com (Wahid) Date: Tue Mar 13 01:45:23 2012 Subject: [xsd-users] segmentation fault in the simplified library example(C++/Parser) In-Reply-To: Message-ID: <1331607655.82935.YahooMailClassic@web160902.mail.bf1.yahoo.com> Hi Boris, thank you it worked as you suggested. vahid --- On Mon, 3/12/12, Boris Kolpackov wrote: From: Boris Kolpackov Subject: Re: [xsd-users] segmentation fault in the simplified library example(C++/Parser) To: "Wahid" Cc: xsd-users@codesynthesis.com Date: Monday, March 12, 2012, 4:25 PM Hi Wahid, Wahid writes: > Then let the following command creat the skeleton and implementation files > for you: > xsd cxx-parser --generate-noop-impl --type-map library.map library.xsd When you use a type map, generated post_*() callbacks have non-void return types. Take a look, for example, at the generated catalog_pimpl class. The post_catalog() callback has the following signature: virtual library::catalog post_catalog (); If you look at the generated implementation for this callback, you will see: library::catalog catalog_pimpl:: post_catalog () { ? // TODO ? // ? // return ... ; } As you can see, the comment even tells you that you must remember to return the value from this function! In more general terms, the generated implementations are just stubs that you must fill with actual code. When type maps are not used, the generated implementations will run as is (though won't do anything useful). If, however, you are using type maps, then you will need to fill in the implementations to at least return something. Boris From bhartsb at gmail.com Wed Mar 14 19:45:44 2012 From: bhartsb at gmail.com (B Hart) Date: Wed Mar 14 19:45:53 2012 Subject: [xsd-users] Accessing elements in sequence of choices. Elements are complex types Message-ID: Given: The procedures performed on the patient with the complex types defined as: How do I check if a choice of the three above procedures is reported in the corresponding XML, and then access it's elements? A snippet of the corresponding XML looks like: 1 89.701 1 38.992 Thank you! From boris at codesynthesis.com Thu Mar 15 09:25:08 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 15 09:19:34 2012 Subject: [xsd-users] Re: Accessing elements in sequence of choices. Elements are complex types In-Reply-To: References: Message-ID: Hi, B Hart writes: > How do I check if a choice of the three above procedures is reported in the > corresponding XML, and then access it's elements? I don't know what "reported in the corresponding XML" means. For more information on how to access particles in various compositors in C++/Tree, see Chapter 4, "Working with Object Models" in the C++/Tree Mapping Getting Strated Guide: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#4 Boris From bhartsb at gmail.com Thu Mar 15 12:46:16 2012 From: bhartsb at gmail.com (B Hart) Date: Thu Mar 15 12:46:24 2012 Subject: [xsd-users] Re: Accessing elements in sequence of choices. Elements are complex types In-Reply-To: References: Message-ID: Sorry I didn't reply all so here it is again (with some extra editing): What I mean by "reported in the corresponding XML" is that each procedure is reported using an element which is itself a complex type having sub elements included by reference. For example ProcedurePTA (PTA means procedure performed prior to Emergency Medical Services arrival). ProcedurePTA includes by reference two child elements E19_01 and E19_03. E19_03 is to hold the code for the procedure. Another procedure I showed above is 89.701 (this is the code for an assessment procedure), and it includes by reference sub elements E19_01, E19_02, E19_03 and E19_09. The XML file, used for reporting procedure data, will include data for one or more procedures performed, by enclosing within the E19_01_0 elements, procedure elements. In the above example, I showed two procedures (both a "ProcedurePTA") being reported. Based on certain criteria I want to be able to check if a procedure was reported or not. For example I might want to see that at least one assessment procedure was performed. The problem that I'm having is that while I can get an E19_01_0 iterator I can't figure out how to access the individual procedure elements with the E19_01_0 element. XSD generated a class for each procedure, so for example there is a class P89_701, however I can't find the right syntax to gain access to an instance of it. In other words, I want to iterate through all the E19_01_0 elements, check for the presence of a given procedure such as 89.701. Do I have to do this via the DOM, or can I just check if P89_701 is present? Or alternately since every procedure has an element 19_03 (which somewhat redundantly contains the procedure code), can I access that element and check? Make sense? Thanks. On Thu, Mar 15, 2012 at 5:25 AM, Boris Kolpackov wrote: > Hi, > > B Hart writes: > > > How do I check if a choice of the three above procedures is reported in > the > > corresponding XML, and then access it's elements? > > I don't know what "reported in the corresponding XML" means. For more > information on how to access particles in various compositors in C++/Tree, > see Chapter 4, "Working with Object Models" in the C++/Tree Mapping > Getting Strated Guide: > > http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#4 > > Boris > From erik.sjolund at gmail.com Thu Mar 15 13:33:49 2012 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Thu Mar 15 13:33:57 2012 Subject: [xsd-users] Re: Accessing elements in sequence of choices. Elements are complex types In-Reply-To: References: Message-ID: If understand you correctly you, Codesynthesis XSD has probably generated the function const P89_701_optional& P89_701 () const; (Take a look in the generated header file) You could use it like this if (object.P89_701().present()) { const P89_701 &var = object.P89_701().get(); } cheers, Erik Sj?lund From bhartsb at gmail.com Thu Mar 15 14:21:49 2012 From: bhartsb at gmail.com (B Hart) Date: Thu Mar 15 14:21:58 2012 Subject: [xsd-users] Re: Accessing elements in sequence of choices. Elements are complex types In-Reply-To: References: Message-ID: Hi Erik, There is a function just as you mention, but could you explain the "object" part? Is object a root element in the DOM, or something else? If I put the code snippet in I get errors. I can declare a variable like: SBC::P89_701 var; without generating errors. On Thu, Mar 15, 2012 at 9:33 AM, Erik Sj?lund wrote: > If understand you correctly you, Codesynthesis XSD has probably > generated the function > > const P89_701_optional& P89_701 () const; > > (Take a look in the generated header file) > > You could use it like this > > if (object.P89_701().present()) { > const P89_701 &var = object.P89_701().get(); > } > > cheers, > Erik Sj?lund > > From bhartsb at gmail.com Thu Mar 15 14:35:16 2012 From: bhartsb at gmail.com (B Hart) Date: Thu Mar 15 14:35:25 2012 Subject: [xsd-users] Re: Accessing elements in sequence of choices. Elements are complex types In-Reply-To: References: Message-ID: Here is what the actual iterating code looks like: for (E19::E19_01_0_iterator itemp ((*iC)->E19().E19_01_0().begin()); itemp != ((*iC)->E19().E19_01_0().end()); ++itemp) { // I want to access each instance of E19_01_0 (*itemp), to look for and further access P89_701 (if it exists) } Thanks. On Thu, Mar 15, 2012 at 10:21 AM, B Hart wrote: > Hi Erik, > > There is a function just as you mention, but could you explain the > "object" part? Is object a root element in the DOM, or something else? > > If I put the code snippet in I get errors. I can declare a variable like: > > SBC::P89_701 var; > > without generating errors. > > On Thu, Mar 15, 2012 at 9:33 AM, Erik Sj?lund wrote: > >> If understand you correctly you, Codesynthesis XSD has probably >> generated the function >> >> const P89_701_optional& P89_701 () const; >> >> (Take a look in the generated header file) >> >> You could use it like this >> >> if (object.P89_701().present()) { >> const P89_701 &var = object.P89_701().get(); >> } >> >> cheers, >> Erik Sj?lund >> >> > From erik.sjolund at gmail.com Sat Mar 17 07:21:11 2012 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Sat Mar 17 07:21:19 2012 Subject: [xsd-users] Re: Accessing elements in sequence of choices. Elements are complex types In-Reply-To: References: Message-ID: On Thu, Mar 15, 2012 at 7:21 PM, B Hart wrote: > Hi Erik, > > There is a function just as you mention, but could you explain the "object" > part?? Is object a root element in the DOM, or something else? > "object" was not from DOM, instead "object" was the variable name of an object of the generated class corresponding to the xsd element "E19_01_0". Maybe this works? for (E19::E19_01_0_iterator itemp ((*iC)->E19().E19_01_0().begin()); itemp != ((*iC)->E19().E19_01_0().end()); ++itemp) { if (itemp->P89_701().present()) { P89_701 &var = itemp->P89_701().get(); } } Another tip: The library example examples/cxx/tree/library/driver.cxx is an example of how to access an object model. cheers Erik Sj?lund From hamishagi at yahoo.com Sun Mar 18 22:40:34 2012 From: hamishagi at yahoo.com (Wahid) Date: Mon Mar 19 05:40:00 2012 Subject: [xsd-users] Sending arguments down the Hierarchy Message-ID: <1332124834.89280.YahooMailClassic@web160902.mail.bf1.yahoo.com> Hello, I am using C++/parser in my project. I am working in "type map"s to delegate information/arguments between the parsers. Here is a scenario that I made it very clear and simple to understand: (scenario is a bit lengthy but the question is VERY small) My XML: ??????????? ????????????????????? ?????????????????????????????????????????? ???????????????????????????????????????????????? ????????????????????????????????????????????????? ........... one of my classes: (pertaining to the above element) class RoadNetwork { ?????????????? ........ ?????????????? std::vector links;??? ????????????? ........... } Now a portion of my map file: ....... ?links Link* Link; ?link_t Link Link; ...... After generating skel and pimpl files, I declare a variable for the above class in the generated "RoadNetwork_t_pimpl" class: class RoadNetwork_t_pimpl: public virtual RoadNetwork_t_pskel ? { ..... ??? private: ??? RoadNetwork RN; ? }; As you can see RN has a member called "links" which is a vector of "link"s . Right? And you agree that the order of call backs is as follows: SimMobility_t_pimpl:: pre () ??? GeoSpatial_t_pimpl:: pre () ???? RoadNetwork_t_pimpl:: pre () ?????????????????????????? Links_pimpl::pre() ????????????????????????????? link_t_pimpl::pre() ????????????????? ? ? ? ? ? ? ........ ????????????????????????? Links_pimpl::Link (Link link) ????????????????????????? ... ... right? :) I can almost shoot my question now: I update RoadNetwork_t_pimpl::RN in RoadNetwork_t_pimpl:: pre ()? referencing to my RoadNetwork singleton: ? void RoadNetwork_t_pimpl:: ? pre () ? { ??? ? RN=..........::GetInstance().getNetwork(); //RN is a vecor of "link"s ? } and as the "link" information are read in the xml, I would like to create "link" objects in link_t_pimpl::pre() .Later, after I updated the object, I would like to push it to RN. QUESTION is: I don't know how to send RN as a variable from RoadNetwork_t_pimpl? to link_t_pimpl. more explanation: map file allows me to send argument only in Inside "Links_pimpl::Link(Link link)" which is a few calls after link_t_pimpl::pre() while, I guess, I need the argument at my disposal when the control is calling "link_t_pimpl::pre()" itself. Any suggestions please? May be i am writing my program in an inefficient way. In that case also help me please. Many thanks vahid From hamishagi at yahoo.com Mon Mar 19 01:54:59 2012 From: hamishagi at yahoo.com (Wahid) Date: Mon Mar 19 05:40:00 2012 Subject: [xsd-users] =?utf-8?q?expected_unqualified-id_before_=E2=80=98vo?= =?utf-8?b?aWTigJk=?= Message-ID: <1332136499.24171.YahooMailClassic@web160901.mail.bf1.yahoo.com> Hi every one, Kindly consider the following map file: namespace http://www.smart.mit.edu/geo sim_mob { ?include "Link.hpp"; ?include "RoadNetwork.hpp"; ? ?RoadNetwork_t void Link*; ?Links Link* Link; ?link_t Link; } The first type mapping states that? RoadNetwork_t will not want anything to return during its post_? function. however since the namespace has specified sim_mob as the c++-namespace, in the generated code we get: sim_mob::void could you help me how to avoid this problem? thank you vahid From boris at codesynthesis.com Mon Mar 19 10:06:24 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 19 10:01:00 2012 Subject: [xsd-users] Re: Sending arguments down the Hierarchy In-Reply-To: <1332124834.89280.YahooMailClassic@web160902.mail.bf1.yahoo.com> References: <1332124834.89280.YahooMailClassic@web160902.mail.bf1.yahoo.com> Message-ID: Hi Wahid, Wahid writes: > I would like to create "link" objects in link_t_pimpl::pre(). Later, after > I updated the object, I would like to push it to RN. The recommended way to do this is to return the link object from link_t_pimpl::post() which will then be passed to Links_pimpl::Link() where you can then add it to the vector. If you still want to pass the information "in" (instead of "out"), then you will need to organize this yourself by, for example, passing references in parser's constructors (e.g., you could pass a reference to Links_pimpl to the link_t_pimpl::link_t_pimpl()). Boris From boris at codesynthesis.com Mon Mar 19 10:21:54 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 19 10:16:30 2012 Subject: [xsd-users] Re: expected unqualified-id =?utf-8?b?YmVmb3JlIOKAmHZvaWTigJk=?= In-Reply-To: <1332136499.24171.YahooMailClassic@web160901.mail.bf1.yahoo.com> References: <1332136499.24171.YahooMailClassic@web160901.mail.bf1.yahoo.com> Message-ID: Hi Wahid, Wahid writes: > namespace http://www.smart.mit.edu/geo sim_mob { > > RoadNetwork_t void Link*; > > } > > The first type mapping states that RoadNetwork_t will not want anything > to return during its post_ function. however since the namespace has > specified sim_mob as the c++-namespace, in the generated code we get: > sim_mob::void Yes, this is a bug in XSD which we will try to fix for the next release. For now if you want to specify void, then you will need to qualify each name individually: namespace http://www.smart.mit.edu/geo { RoadNetwork_t void sim_mob::Link*; } Boris From hamishagi at yahoo.com Mon Mar 19 22:58:29 2012 From: hamishagi at yahoo.com (Wahid) Date: Tue Mar 20 08:18:51 2012 Subject: [xsd-users] =?utf-8?q?Re=3A_expected_unqualified-id_before_?= =?utf-8?b?4oCYdm9pZOKAmQ==?= In-Reply-To: Message-ID: <1332212309.14482.YahooMailClassic@web160901.mail.bf1.yahoo.com> Hi, Yes, this can work. we can have different namespaces defined in the map file. However,this will cause another different challenge that i will bring it up in another post. vahid --- On Mon, 3/19/12, Boris Kolpackov wrote: From: Boris Kolpackov Subject: Re: expected unqualified-id before ?void? To: "Wahid" Cc: xsd-users@codesynthesis.com Date: Monday, March 19, 2012, 7:51 PM Hi Wahid, Wahid writes: > namespace http://www.smart.mit.edu/geo sim_mob { > > RoadNetwork_t void Link*; > > } > > The first type mapping states that RoadNetwork_t will not want anything > to return during its post_ function. however since the namespace has > specified sim_mob as the c++-namespace, in the generated code we get: > sim_mob::void Yes, this is a bug in XSD which we will try to fix for the next release. For now if you want to specify void, then you will need to qualify each name individually: namespace http://www.smart.mit.edu/geo { RoadNetwork_t void sim_mob::Link*; } Boris From hamishagi at yahoo.com Mon Mar 19 23:10:19 2012 From: hamishagi at yahoo.com (Wahid) Date: Tue Mar 20 08:18:52 2012 Subject: [xsd-users] argument mismatch in the generated code Message-ID: <1332213019.51318.YahooMailClassic@web160903.mail.bf1.yahoo.com> Hello everyone, suppose that I have a XML shema with the following hierarchy: ??????????????????? ??????????????????????????? I define a type map file as : namespace http://www.smart.mit.edu/geo { include "Link.hpp"; Link void sim_mob::Link*; } this means that the ONLY desirable modification in the generated code is RoadNetwork_t::Links() to get One argument: RoadNetwork_t::Links(sim_mob::Link*) before i continue, is this a valid expectation at all? or I have a wrong assumption!?) I generate the code using the following command: xsd cxx-parser? --generate-print-impl --generate-test-driver --root-element-last --type-map geoConverter.map? simple.xsd when I compile the code using gcc? -I.../lib? -c *.cxx I get the following error: simple-pskel.cpp: In member function ?virtual bool geo::RoadNetwork_t_pskel::_end_element_impl(const ro_string&, const ro_string&)?: simple-pskel.cpp:211:22: error: no matching function for call to ?geo::RoadNetwork_t_pskel::Links()? simple-pskel.cpp:211:22: note: candidate is: simple-pskel.cpp:166:8: note: virtual void geo::RoadNetwork_t_pskel::Links(sim_mob::Link*) simple-pskel.cpp:166:8: note:?? candidate expects 1 argument, 0 provided Could you please help me why I am getting this, and how to solve it? thank you vahid From boris at codesynthesis.com Tue Mar 20 08:35:05 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Mar 20 08:29:44 2012 Subject: [xsd-users] Re: argument mismatch in the generated code In-Reply-To: <1332213019.51318.YahooMailClassic@web160903.mail.bf1.yahoo.com> References: <1332213019.51318.YahooMailClassic@web160903.mail.bf1.yahoo.com> Message-ID: Hi Wahid, Wahid writes: > I define a type map file as : > > Link void sim_mob::Link*; > > > this means that the ONLY desirable modification in the generated code > is RoadNetwork_t::Links() to get One argument: > RoadNetwork_t::Links(sim_mob::Link*) > before i continue, is this a valid expectation at all? or I have a wrong > assumption!?) The above map file fragment doesn't make much sense. The two C++ types that you specify are the return type from the *_post() callback and the argument type to the element/attribute callback. XSD/e "connects" the two by first calling the *_post() callback and then passing the returned value to the element/attribute callback. In your case it will be something along these lines: ret_type r = Links_parser_->Links_post (); RoadNetwork_t_parser_->Links (r); I think from this it should be clear that you cannot have the return type void while the argument type void. They either both have to be void or both non-void. If they are both void, then XSD/e generated the following calls instead: Links_parser_->Links_post (); RoadNetwork_t_parser_->Links (); Boris From hamishagi at yahoo.com Wed Mar 21 04:48:10 2012 From: hamishagi at yahoo.com (Wahid) Date: Wed Mar 21 05:55:30 2012 Subject: [xsd-users] Multi-threading and thread safety in C++/Parser Message-ID: <1332319690.89348.YahooMailClassic@web160906.mail.bf1.yahoo.com> Hi every one, If some one asked me whether multithreading in C++/Parser is possible or not, I would say NO, coz C++/Parser mapping is SAX-like parsing which take a top to bottom approach and processes data streams as the xml is read. Still, I would like to ask: 1-is it possible to distribute parsing of different elements, among some threads? (or, parse multiple occurrences of an element using more than one thread?) if yes, any psudo example? 2-is thread safety an issue to worry about while using C++/Parser in our program? Thank you Boris vahid From hamishagi at yahoo.com Wed Mar 21 04:53:32 2012 From: hamishagi at yahoo.com (Wahid) Date: Wed Mar 21 05:55:30 2012 Subject: [xsd-users] Re: argument mismatch in the generated code In-Reply-To: Message-ID: <1332320012.61989.YahooMailClassic@web160905.mail.bf1.yahoo.com> Hi Boris, Very True, when I got your answer to my question, I had already felt sorry for asking it. I should have paid more attention. It doesn't make sense to supply a return type for post_* method and expect to receive nothing(void) when catching it as an argument. Thank you vahid --- On Tue, 3/20/12, Boris Kolpackov wrote: From: Boris Kolpackov Subject: Re: argument mismatch in the generated code To: "Wahid" Cc: xsd-users@codesynthesis.com, boris@codesynthesis.com Date: Tuesday, March 20, 2012, 6:05 PM Hi Wahid, Wahid writes: > I define a type map file as : > > Link void sim_mob::Link*; > > > this means that the ONLY desirable modification in the generated code > is RoadNetwork_t::Links() to get One argument: > RoadNetwork_t::Links(sim_mob::Link*) > before i continue, is this a valid expectation at all? or I have a wrong > assumption!?) The above map file fragment doesn't make much sense. The two C++ types that you specify are the return type from the *_post() callback and the argument type to the element/attribute callback. XSD/e "connects" the two by first calling the *_post() callback and then passing the returned value to the element/attribute callback. In your case it will be something along these lines: ret_type r = Links_parser_->Links_post (); RoadNetwork_t_parser_->Links (r); I think from this it should be clear that you cannot have the return type void while the argument type void. They either both have to be void or both non-void. If they are both void, then XSD/e generated the following calls instead: Links_parser_->Links_post (); RoadNetwork_t_parser_->Links (); Boris From rlischner at proteuseng.com Wed Mar 21 07:52:41 2012 From: rlischner at proteuseng.com (Ray Lischner) Date: Wed Mar 21 08:04:15 2012 Subject: [xsd-users] Bug in containers-wildcard.hxx Message-ID: I found a bug in libxsd/cxx/tree/containers-wildcard.hxx, line 939: - : (r > 0 ? false : XMLString::compareString (an, bn)); + : (r > 0 ? false : XMLString::compareString (an, bn) < 0); Ray Lischner, Distinguished Member of Technical Staff 133 National Business Pkwy, Ste 150 t. 443.539.3448 Annapolis Junction, MD 20701 c. 410.854.5170 rlischner@proteuseng.com f. 443.539.3370 From wingforce at gmail.com Wed Mar 21 23:45:35 2012 From: wingforce at gmail.com (wingforce) Date: Wed Mar 21 23:45:42 2012 Subject: [xsd-users] Performance tuning issue Message-ID: Hi, there Our team has been stick in xsd (xsd-tree) in our project for over 2 years. It's very cool and easy for xml document parse and compose. You simply define the schema of your xml document in xsd and things rest is to wait until the compile finished. However, we are facing a critical performance issue this year after a widely spread usage through out our project and a simultaneous refactoring of the whole project. By replacing some piece of code originally implemented by xsd with several common xml library such as libxml2 and repidxml, we found that most of them beats control group in xsd-tree much great in performance test. We are wandering whether or not there are options in either compile time or runtime, or any optimization suggestions can help us resolve the performance issue. BR. From boris at codesynthesis.com Thu Mar 22 10:44:03 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 22 10:38:53 2012 Subject: [xsd-users] Bug in containers-wildcard.hxx In-Reply-To: References: Message-ID: Hi Ray, Ray Lischner writes: > I found a bug in libxsd/cxx/tree/containers-wildcard.hxx, line 939: Fixed for the next release. thanks for the report! Boris From boris at codesynthesis.com Thu Mar 22 10:50:51 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 22 10:45:37 2012 Subject: [xsd-users] Re: Multi-threading and thread safety in C++/Parser In-Reply-To: <1332319690.89348.YahooMailClassic@web160906.mail.bf1.yahoo.com> References: <1332319690.89348.YahooMailClassic@web160906.mail.bf1.yahoo.com> Message-ID: Hi Wahid, Wahid writes: > 1-is it possible to distribute parsing of different elements, among > some threads? (or, parse multiple occurrences of an element using > more than one thread?) if yes, any psudo example? No. XML parsing is difficult to parallelize because you need to parse things preceding, say, an element in order to know where this element starts and ends. > 2-is thread safety an issue to worry about while using C++/Parser in > our program? XSD-generated parser skeletons are thread-safe in the sense that you can use several instances in several threads concurrently. This is possible due to the generated code not relying on any writable global variables. Boris From boris at codesynthesis.com Thu Mar 22 11:03:30 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 22 10:58:14 2012 Subject: [xsd-users] Performance tuning issue In-Reply-To: References: Message-ID: Hi, wingforce writes: > By replacing some piece of code originally implemented by xsd with several > common xml library such as libxml2 and repidxml, we found that most of them > beats control group in xsd-tree much great in performance test. Note that XSD-generated parsing functions do more that just parse XML. In particular: 1. Perform XML Schema validation (if enabled). 2. Convert from text representation to C++ types (e.g., string representation of a number, such as "100" to C++ int value). 3. Construct the object model. Also note that RapidXML is not a real XML parser since it can only parse a subset of XML. See this post[1] for more information on this issue. Finally, note that performance is not XSD's primary goal. Rather it is primarily designed to be powerful, flexible, and easy to use. If you are looking for a high-performance C++ data binding implementation, then XSD/e[2] might be a better choice. > We are wandering whether or not there are options in either compile > time or runtime, or any optimization suggestions can help us resolve > the performance issue. Yes, there are a number of things that you can do which are discussed in Q 2.7 and 3.4 in the C++/Tree mapping FAQ: http://wiki.codesynthesis.com/Tree/FAQ The 'performance' example that is mentioned in these questions is a good example of setting up C++/Tree parsing and serialization for maximum speed. [1] http://www.codesynthesis.com/~boris/blog/2008/05/19/real-xml-parser/ [2] http://www.codesynthesis.com/products/xsde/ Boris From Alexey.Glotov at samtec.de Thu Mar 22 09:46:34 2012 From: Alexey.Glotov at samtec.de (Alexey Glotov) Date: Thu Mar 22 11:00:04 2012 Subject: [xsd-users] fatal error C1083 Message-ID: <6073A4082F6CC548B21CB5D385F37B07CDB743@exchangeserver.samtec.de> Dear sirs, i am working with CodeSynthesis_3.x and trying to compile generated code (xsd -> code). No errors were produced during cxx-tree generation. Every file is compileable. But the linker reports fatal error C1083 and points to the obj file, which is available (?!) in the specified directory. Altova XmlSpy defines the xsd as valid. I have tried to scan through your archive and found no error C1083 problems there. What could it be? I include xsd file and file with generation options, just in case. Mit freundlichen Gr?ssen/With best regards, i.A. Dr. Alexey Glotov Embedded Software --------------------------------------------------------------------- samtec automotive software & electronics GmbH Saarstr. 27, D-70794 Filderstadt - Germany - --------------------------------------------------------------------- Phone: +49-711-45809-39, Telefax: +49-711-45809-77 MailTo: alexey.glotov@samtec.de , Internet: www.samtec.de --------------------------------------------------------------------- Gesch?ftsf?hrer / Managing directors: Ewald Hartmann, Detlef Reimer, Dieter Schaller, Dr. Wolfgang Trier Handelsregister / Commercial register: Stuttgart, HRB 224968 --------------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: wwhobd_1.0.xsd Type: application/octet-stream Size: 3303 bytes Desc: wwhobd_1.0.xsd Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20120322/1527e391/wwhobd_1.0.obj -------------- next part -------------- cxx-tree --char-type wchar_t --generate-ostream --generate-intellisense --file-per-type --output-dir ..\..\wwhobdCore\wwhobd_1.0 --proprietary-license --show-sloc --generate-polymorphic --namespace-map http://www.w3.org/2001/XMLSchema=WWHOBDSchema --accessor-regex /(^.*$)/Get\u$1/ --modifier-regex /(^.*$)/Set\u$1/ ..\..\..\doc\wwhobd_1.0.xsd From boris at codesynthesis.com Thu Mar 22 11:10:08 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 22 11:04:54 2012 Subject: [xsd-users] fatal error C1083 In-Reply-To: <6073A4082F6CC548B21CB5D385F37B07CDB743@exchangeserver.samtec.de> References: <6073A4082F6CC548B21CB5D385F37B07CDB743@exchangeserver.samtec.de> Message-ID: Hi Alexey, Alexey Glotov writes: > But the linker reports fatal error C1083 ... You provided a lot of information except the most important part: what the error message says? Boris