From yartsev_mercdev at yahoo.com Mon Sep 8 04:54:11 2008 From: yartsev_mercdev at yahoo.com (Vladimir Yartsev) Date: Mon Sep 8 04:54:19 2008 Subject: [xsde-users] Support for iPhone platform Message-ID: <324118.41000.qm@web57206.mail.re3.yahoo.com> Are there statically-linked libraries of CodeSynthesis XSD/e for use with "iPhone SDK 2.0" available? Thanks, Vladimir. ________________________________________________________ ?? ??? ? Yahoo!? ????????? ??????????? ? ??????????. Yahoo! ?????! http://ru.mail.yahoo.com From boris at codesynthesis.com Tue Sep 9 11:43:04 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 9 11:44:16 2008 Subject: [xsde-users] Support for iPhone platform In-Reply-To: <324118.41000.qm@web57206.mail.re3.yahoo.com> References: <324118.41000.qm@web57206.mail.re3.yahoo.com> Message-ID: <20080909154304.GA4427@karelia> Hi Vladimir, Vladimir Yartsev writes: > Are there statically-linked libraries of CodeSynthesis XSD/e for use > with "iPhone SDK 2.0" available? No, we normally don't provide pre-compiled XSD/e runtime library mainly because there are many configuration parameters which would require us to publish tens of variants just to cover the most common cases. I looked around and it should be fairly straightforward to build the XSD/e runtime for iPhone using the SDK provided by Apple. I am going to give it a try later today or tomorrow and will get back to you with a sample config file and instructions. Also, would you like the XSD/e compiler binary for Mac OS X? Boris From ntlkhuong at tma.com.vn Wed Sep 10 04:48:31 2008 From: ntlkhuong at tma.com.vn (Khuong Nguyen Thi Lien) Date: Wed Sep 10 04:50:47 2008 Subject: [xsde-users]Get the element name In-Reply-To: <20080909154304.GA4427@karelia> References: <324118.41000.qm@web57206.mail.re3.yahoo.com> <20080909154304.GA4427@karelia> Message-ID: <006901c91322$0242fc50$828010ac@tma.com.vn> Hi Boris, Could you show me how I can get the element-name in the schema file? Thanks a lot. Regards, Khuong From boris at codesynthesis.com Wed Sep 10 05:08:31 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 10 05:09:44 2008 Subject: [xsde-users] Get the element name Message-ID: <20080910090831.GC6428@karelia> Hi Khuong, Khuong Nguyen Thi Lien writes: > Could you show me how I can get the element-name in the schema file? I am not sure what you mean by this. Can you explain what you are trying to achieve in a bit more detail? Maybe also show a schema and/or XML fragment. Boris From ntlkhuong at tma.com.vn Wed Sep 10 05:33:08 2008 From: ntlkhuong at tma.com.vn (Khuong Nguyen Thi Lien) Date: Wed Sep 10 05:35:19 2008 Subject: [xsde-users] Get the element name In-Reply-To: <20080910090831.GC6428@karelia> References: <20080910090831.GC6428@karelia> Message-ID: <007001c91328$3c60db90$828010ac@tma.com.vn> Hi Boris, Sorry for the unclear question, I have the xml fragment below, when the parsing engine reaches the element in the greeting() callback function, I would like to extract the name of the element right at this function. In this case I would like the returned name should be "greeting". Thanks, Khuong struct hello_pimpl: hello_pskel { virtual void greeting (const string& greeting) { greeting_ = greeting; } virtual void name (const string& name) { cout << greeting_ << ", " << name << "!" << endl; } private: string greeting_; }; Hello sun moon world -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, September 10, 2008 4:09 PM To: Khuong Nguyen Thi Lien Cc: xsde-users@codesynthesis.com Subject: Re: [xsde-users] Get the element name Hi Khuong, Khuong Nguyen Thi Lien writes: > Could you show me how I can get the element-name in the schema file? I am not sure what you mean by this. Can you explain what you are trying to achieve in a bit more detail? Maybe also show a schema and/or XML fragment. Boris From RobertH at microsol.ie Wed Sep 10 11:00:45 2008 From: RobertH at microsol.ie (Robert Hammond) Date: Wed Sep 10 11:00:56 2008 Subject: [xsde-users] Using Type Mapping? Message-ID: <974C3B6C9F0A4A43918BACCA33390AC237C6C32E07@mail.microsol.ie> Hi, I am trying to work my way through the "people" example to understand how the Type maps work properly. My assumption after reading the manual is that if I wanted to include my own type which was not in the schema file, that I could define it in a hxx file, include this and the parser would build the skeleton code for that type. Have I got this right? I notice in the example that the "gender" type is already specified in the Schema and then defined as an enum in the hxx file which is included from the map file. I am very new to using xml and the Xsde Parser so I may have made a wrong assumption here. Is there any way you could please clarify this? >> from Manual "The first line indicates that the generated code must include people.hxx in order to get the definition for the gender type. The second line specifies that both argument and return types for the gender XML Schema type should be the ::gender C++ enum (we use fully-qualified C++ names to avoid name clashes)." _______________________________________________________________________ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. If you have received this email in error please notify the originator of the message. This footer also confirms that this email message has been scanned for the presence of computer viruses. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Microsol. If you have received this mail in error you are requested to e-mail us (info@microsol.ie) or by telephoning Microsol on +353 14153700. Please Visit our website at http://www.microsol.com _______________________________________________________________________ This email has been scanned for all viruses. _______________________________________________________________________ From boris at codesynthesis.com Thu Sep 11 04:51:21 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 11 04:52:52 2008 Subject: [xsde-users] Get the element name In-Reply-To: <007001c91328$3c60db90$828010ac@tma.com.vn> References: <20080910090831.GC6428@karelia> <007001c91328$3c60db90$828010ac@tma.com.vn> Message-ID: <20080911085121.GB9675@karelia> Hi Khuong, Khuong Nguyen Thi Lien writes: > Sorry for the unclear question, I have the xml fragment below, when the > parsing engine reaches the element in the greeting() callback > function, I would like to extract the name of the element right at this > function. In this case I would like the returned name should be "greeting". My guess is that your schema is using substitution groups and element names act as identifiers (i.e., different substituting elements use the same type). If that's the case then I have already outlined the possible ways to achieve this in the following post: http://www.codesynthesis.com/pipermail/xsde-users/2008-July/000039.html In your case the easiest way would be to override _start_element and save the element name in a member variable. You can then access it from the greeting function: struct hello_pimpl: hello_pskel { virtual void greeting (const string& greeting) { // element_name_ contains the element name. } virtual void name (const string& name) { } virtual void _start_element (const xml_schema::ro_string& ns, const xml_schema::ro_string& name const char* type) { element_name_ = name; // Always call the base _start_element(). // hello_pskel::_start_element (ns, name, type); } private: string element_name_; }; Boris From ntlkhuong at tma.com.vn Thu Sep 11 04:58:34 2008 From: ntlkhuong at tma.com.vn (Khuong Nguyen Thi Lien) Date: Thu Sep 11 05:00:46 2008 Subject: [xsde-users] Get the element name In-Reply-To: <20080911085121.GB9675@karelia> References: <20080910090831.GC6428@karelia> <007001c91328$3c60db90$828010ac@tma.com.vn> <20080911085121.GB9675@karelia> Message-ID: <005701c913ec$923caf70$828010ac@tma.com.vn> Hi Boris , I got your idea. Thanks you so much. Khuong -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, September 11, 2008 3:51 PM To: Khuong Nguyen Thi Lien Cc: xsde-users@codesynthesis.com Subject: Re: [xsde-users] Get the element name Hi Khuong, Khuong Nguyen Thi Lien writes: > Sorry for the unclear question, I have the xml fragment below, when the > parsing engine reaches the element in the greeting() callback > function, I would like to extract the name of the element right at this > function. In this case I would like the returned name should be "greeting". My guess is that your schema is using substitution groups and element names act as identifiers (i.e., different substituting elements use the same type). If that's the case then I have already outlined the possible ways to achieve this in the following post: http://www.codesynthesis.com/pipermail/xsde-users/2008-July/000039.html In your case the easiest way would be to override _start_element and save the element name in a member variable. You can then access it from the greeting function: struct hello_pimpl: hello_pskel { virtual void greeting (const string& greeting) { // element_name_ contains the element name. } virtual void name (const string& name) { } virtual void _start_element (const xml_schema::ro_string& ns, const xml_schema::ro_string& name const char* type) { element_name_ = name; // Always call the base _start_element(). // hello_pskel::_start_element (ns, name, type); } private: string element_name_; }; Boris From boris at codesynthesis.com Thu Sep 11 05:33:50 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 11 05:35:20 2008 Subject: [xsde-users] Using Type Mapping? In-Reply-To: <974C3B6C9F0A4A43918BACCA33390AC237C6C32E07@mail.microsol.ie> References: <974C3B6C9F0A4A43918BACCA33390AC237C6C32E07@mail.microsol.ie> Message-ID: <20080911093350.GC9675@karelia> Hi Robert, Robert Hammond writes: > Hi, I am trying to work my way through the "people" example to understand > how the Type maps work properly. > > My assumption after reading the manual is that if I wanted to include my > own type which was not in the schema file, that I could define it in a > hxx file, include this and the parser would build the skeleton code for > that type. > Have I got this right? Not exactly. For each type defined in XML Schema the XSD/e compiler generates a parser skeleton. By default these parser skeletons don't return anything from their post_*() functions. You use type maps to tell the XSD/e compiler that a parser skeleton corresponding to a particular schema type should return something. Returning things from parser skeletons is useful when you need to pass information from a "child" element/attribute parser to the "parent" one. This is handy when, for example, you need to build a custom in-memory representation of the data stored in XML. Let's consider the gender type from the people example in the manual. It is defined in XML Schema like so: If we compile this schema fragment without specifying any type maps then we get the following parser skeleton: class gender_pskel: public xml_schema::string_pskel { public: gender_pskel (xml_schema::string_pskel* base_impl); virtual void pre (); virtual void post_gender (); }; As you can see, the post_gender() function returns void. This may be perfectly sufficient if, for example, all you need to do is print the gender value: class gender_pimpl: public gender_pskel { public: gender_pimpl () : gender_pskel (&base_impl_) { } virtual void post_gender () { std::string s = post_string (); cout << "gender: " << s << endl; } private: xml_schema::string_pimpl base_impl_; }; But what if you cannot process the gender value in gender_pimpl and instead needed to pass the gender value to the "parent" parser, the one generated for the person type: ... class person_pskel: public xml_schema::parser_complex_content { public: virtual void gender (); ... }; One not very clean way would be to have a global variable that is set in gender_pimpl and is examined in person_pimpl. Since passing data from "child" parsers to "parent" parsers is a fairly common requirement, XSD/e provides a mechanism for this. It allows you to specify, via type maps, the return type of the "child" parser's post_*() function (post_gender() in our case) and argument type of the "parent" parser's callback (gender() in our case). The generated code is also responsible for calling gender_pimpl::post_gender() and passing its return value to person_pimpl::gender(). In our case we can create a C++ enum corresponding to the gender type in XML Schema. We can place it, say, in gender.hxx: enum gender { male, female }; We can then create a type map for our schema, people.map: include "gender.hxx" gender ::gender ::gender In the second line the first identifier is of the schema type. The second is the return type for gender_pimpl::post_gender() and the last one is the argument type for the person_pimpl::gender() callback. Once we compile our schema with this type map, the gender_pskel and person_pskel skeletons change as follows: #include "gender.hxx" class gender_pskel: public xml_schema::string_pskel { public: gender_pskel (xml_schema::string_pskel* base_impl); virtual void pre (); virtual ::gender post_gender (); }; class person_pskel: public xml_schema::parser_complex_content { public: virtual void gender (::gender); ... }; And our implementation could look like this: class gender_pimpl: public gender_pskel { public: gender_pimpl () : gender_pskel (&base_impl_) { } virtual ::gender post_gender () { std::string s = post_string (); return s == "male" : male ? female; } private: xml_schema::string_pimpl base_impl_; }; class person_pimpl: public person_pskel { public: virtual void gender (::gender g) { // g is the gender value returned by gender_pimpl. } }; Boris From boris at codesynthesis.com Thu Sep 11 09:49:12 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 11 09:50:35 2008 Subject: [xsde-users] Support for iPhone platform In-Reply-To: <20080909154304.GA4427@karelia> References: <324118.41000.qm@web57206.mail.re3.yahoo.com> <20080909154304.GA4427@karelia> Message-ID: <20080911134912.GA10501@karelia> Hi Vladimir, I've successfully compiled the XSD/e runtime and examples for iPhoneOS 2.0 and the simulator. I also ran the examples built for the simulator. I haven't had a chance to run the examples on the actual device yet (there does not seem to be a console on iPhone so we will need to create some kind of driver for the examples). I have prepared the XSD/e package for Mac OS X (Intel) which you can download via this link: http://www.codesynthesis.com/~boris/tmp/xsde-2.1.0-i686-macosx.tar.bz2 In this package you will find the XSD/e compiler binary as well as the source code for the runtime and examples. It also contains two sample configuration files in the etc/iphone/ directory: one is for the device and one is for the simulator. You will need to copy one of these files to the config/ directory and rename it to config.make. If your iPhone SDK is installed in a location other than the default (/Developer) then you will need to adjust the paths at the beginning of the config file. You may also want to check other configuration parameters (e.g., use of iostream, STL, C++ exceptions, etc; they are all enabled by default). Once you are happy with your config file you can build the runtime library by changing to the libxsde/ directory and running make from there. Once the build is complete you will find libxsde.a in the libxsde/xsde/ directory. I assume you are using the XCode IDE to build your application. If that's the case then probably the easiest way to integrate the generated code into your project would be to change the generated source file suffix from .cxx to .mm as suggested in the answer to the "How do I enable Objective-C++ compilation?" question in the Apple FAQ: https://developer.apple.com/iphone/library/codinghowtos/Tools/index.html You can do it automatically with the '--cxx-suffix .mm' option. See the XSD/e Compiler Manual for more information: http://codesynthesis.com/projects/xsde/documentation/xsde.xhtml Other than that you will need to add the libxsde/ directory to the include directory list and link to libxsde.a found in libxsde/xsde/. Let me know if there are any problems as well as if everything is working fine. Boris From boris at codesynthesis.com Fri Sep 12 07:27:12 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 12 07:28:41 2008 Subject: [xsde-users] XSD/e 2.1.0 package for Mac OS X/iPhone available Message-ID: <20080912112712.GC13410@karelia> Hi, We have uploaded the XSD/e 2.1.0 package for Max OS X (Intel) which includes sample configuration files for iPhone OS 2.x. For more information on how to build the XSD/e runtime and examples for the iPhone device or simulator refer to the INSTALL file inside. You can download this package from the XSD/e Download page: http://www.codesynthesis.com/products/xsde/download.xhtml The SHA1 checksum for the file: 9ed03d2b3d971d8b30f79712278216550f5a1745 xsde-2.1.0-i686-macosx.tar.bz2 Boris From ntlkhuong at tma.com.vn Wed Sep 17 04:26:07 2008 From: ntlkhuong at tma.com.vn (Khuong Nguyen Thi Lien) Date: Wed Sep 17 04:28:29 2008 Subject: [xsde-users] Get the element name In-Reply-To: <20080911085121.GB9675@karelia> References: <20080910090831.GC6428@karelia> <007001c91328$3c60db90$828010ac@tma.com.vn> <20080911085121.GB9675@karelia> Message-ID: <001601c9189f$08913310$828010ac@tma.com.vn> Hi Boris, Thanks for your response, instead of using a string member variable to store the name, I would like to use the const char* to point to the name array as the way to save space for my classes and we only use in the callback and then no use anymore. So is there is there any risk by using this way? Thanks, Khuong class clearArpCacheEthernet_pimpl: public clearArpCacheEthernet_pskel { public: clearArpCacheEthernet_pimpl (); virtual void pre (); // Elements. // void clearArpCacheEthernet_pimpl:: slot (ucg::AttributePtr& slot) { slot->setName(currentElementName); data->addAttribute(slot); } void clearArpCacheEthernet_pimpl:: port (ucg::AttributePtr& port) { port->setName(currentElementName); data->addAttribute(port); } virtual ::ucg::NodePtr& post_clearArpCacheEthernet (); protected: bool _start_element_impl(const xsde::cxx::ro_string& ns, const xsde::cxx::ro_string& n, const char* s) { currentElementName = n.data(); return clearArpCacheEthernet_pskel::_start_element_impl(ns, n, s); } ::ucg::NodePtr data; const char* currentElementName; }; -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, September 11, 2008 3:51 PM To: Khuong Nguyen Thi Lien Cc: xsde-users@codesynthesis.com Subject: Re: [xsde-users] Get the element name Hi Khuong, Khuong Nguyen Thi Lien writes: > Sorry for the unclear question, I have the xml fragment below, when the > parsing engine reaches the element in the greeting() callback > function, I would like to extract the name of the element right at this > function. In this case I would like the returned name should be "greeting". My guess is that your schema is using substitution groups and element names act as identifiers (i.e., different substituting elements use the same type). If that's the case then I have already outlined the possible ways to achieve this in the following post: http://www.codesynthesis.com/pipermail/xsde-users/2008-July/000039.html In your case the easiest way would be to override _start_element and save the element name in a member variable. You can then access it from the greeting function: struct hello_pimpl: hello_pskel { virtual void greeting (const string& greeting) { // element_name_ contains the element name. } virtual void name (const string& name) { } virtual void _start_element (const xml_schema::ro_string& ns, const xml_schema::ro_string& name const char* type) { element_name_ = name; // Always call the base _start_element(). // hello_pskel::_start_element (ns, name, type); } private: string element_name_; }; Boris From boris at codesynthesis.com Wed Sep 17 06:29:45 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 17 06:32:06 2008 Subject: [xsde-users] Get the element name In-Reply-To: <001601c9189f$08913310$828010ac@tma.com.vn> References: <20080910090831.GC6428@karelia> <007001c91328$3c60db90$828010ac@tma.com.vn> <20080911085121.GB9675@karelia> <001601c9189f$08913310$828010ac@tma.com.vn> Message-ID: <20080917102945.GB19700@karelia> Hi Khuong, Khuong Nguyen Thi Lien writes: > Thanks for your response, instead of using a string member variable to store > the name, I would like to use the const char* to point to the name array as > the way to save space for my classes and we only use in the callback and > then no use anymore. So is there is there any risk by using this way? This will work in the current implementation though the char array returned by n.data() may not be 0-terminated in the general case (e.g., in the future we may add another XML parser to XSD/e which may not pass element names as 0-terminated strings to avoid copying). If you want your code to work in the general case, you will need to also store the size: currentElementName = n.data(); currentElementNameSize = n.size(); And then: slot->setName(currentElementName, currentElementNameSize); Boris From sneeraj2 at yahoo.com Wed Sep 17 08:29:10 2008 From: sneeraj2 at yahoo.com (Neeraj Seshadri) Date: Wed Sep 17 09:33:24 2008 Subject: [xsde-users] XSDE for WinCE (Microsoft Visual Studio 2005(V8.0) with Smart Devices support) Message-ID: <595042.91502.qm@web31909.mail.mud.yahoo.com> Hi, Is it possible to build a binary of XSDE for WinCE (Microsoft Visual Studio 2005(V8.0) with Smart Devices support)? I see that this is listed in the supported platforms and compiler list. However the same is not listed in the Download page. Can the binary for Windows x86(xsde-2.1.0-i686-windows.zip) be used for WinCE also? Thanks Neeraj From boris at codesynthesis.com Wed Sep 17 10:01:33 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 17 10:03:46 2008 Subject: [xsde-users] XSDE for WinCE (Microsoft Visual Studio 2005(V8.0) with Smart Devices support) In-Reply-To: <595042.91502.qm@web31909.mail.mud.yahoo.com> References: <595042.91502.qm@web31909.mail.mud.yahoo.com> Message-ID: <20080917140133.GG18097@karelia> Hi Neeraj, Neeraj Seshadri writes: > Is it possible to build a binary of XSDE for WinCE > (Microsoft Visual Studio 2005(V8.0) with Smart Devices > support)? You normally don't need to build the compiler binary for the target platform (WinCE). Usually, you run the XSD/e compiler (to generate the source code) on your host development platform (Windows in your case). What you do need to build for the target is the XSD/e runtime library. So XSD/e is distributed in the form of a precompiled binary for a host development platform (e.g., Windows, Linux, etc) as well as the source code for the runtime library and examples. This way you can use the binary to develop for any target device. WinCE with VC++ 2005 is tested and fully supported. For more information on how to build the XSD/e runtime for this platform download xsde-2.1.0-i686-windows.zip and refer to the INSTALL file inside. Boris From boris at codesynthesis.com Fri Sep 19 11:59:38 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 19 12:02:10 2008 Subject: [xsde-users] Re: [xsd-users] XSDE support for element 'any' In-Reply-To: <278881.46404.qm@web31911.mail.mud.yahoo.com> References: <278881.46404.qm@web31911.mail.mud.yahoo.com> Message-ID: <20080919155938.GC11775@karelia> Hi Neeraj, In the future please send questions about XSD/e to the xsde-users mailing list instead of xsd-users. I have switched to this mailing list in my reply. Neeraj Seshadri writes: > Does the XSDE code generation support the element of > form any as shown below > > > Yes, it does. Please see the 'wildcard' examples in the examples/cxx/tree/ and examples/cxx/parser/ directories. > When I tried to use this in my schema I am getting the > following error. > > :0:0: error: Complex type '__AnonC1' violates the > Unique Particle Attribution rule in its components > 'targetName' and '##any' This error message indicates that your schema violates the Unique Particle Attribution (UPA) rule. The specification states that the XML Schema validator should be able to uniquely attribute an element being validated to an XML Schema declaration. Consider this example: This fragment violates the UPA rule because when a validator sees the 'bar' element in an XML document, it can validate it in two ways: it can attribute 'bar' to the element declaration or it can assume the element declaration is not present (minOccurs="0") and attribute 'bar' to the any wildcard. For more information refer to Section 3.8.6, "Constraints on Model Group Schema Components" in the XML Schema specification: http://www.w3.org/TR/xmlschema-1/#coss-modelGroup Boris From mark63 at azurebell.co.nz Mon Sep 22 23:23:35 2008 From: mark63 at azurebell.co.nz (Mark Easton) Date: Mon Sep 22 23:19:47 2008 Subject: [xsde-users] Newbie - How to traverse my data structures? Message-ID: <01eb01c91d2b$c3906830$0601010a@markdevelope> Hi, I have started on using xsde today and am struggling a little. My problem is quite basic I think, so I just need a stear in the right direction. I have a site and that site has many areas. What I cant understand is if I do an area_next() in my site_simpl class, how my area_simple class knows what area record to refer to?? ie I have xml_schema::int_simpl int_s; xml_schema::string_simpl string_s; area_simpl area_s; site_simpl site_s; site_s.area_serializer (area_s); area_s.serializers(int_s, string_s); xml_document_simpl doc_s(site_s, "site"); std::ostringstream os; site_s.pre(); doc_s.serialize(os); site_s.post(); So when in site_simpl I do an area_next(), how does area_simple know which area record to refer to?? TIA Mark From mark63 at azurebell.co.nz Mon Sep 22 23:44:29 2008 From: mark63 at azurebell.co.nz (Mark Easton) Date: Mon Sep 22 23:40:36 2008 Subject: [xsde-users] Newbie - How to traverse my data structures? In-Reply-To: <01eb01c91d2b$c3906830$0601010a@markdevelope> References: <01eb01c91d2b$c3906830$0601010a@markdevelope> Message-ID: <01f501c91d2e$af124100$0601010a@markdevelope> Duhh, sorry. I just realised that from my site_serializer I can access my area_serializer and therefore tell it which record to use. I guess that is the right way to do it. I found that I had to cast area_serializer to (area_simpl)area_serializer. > -----Original Message----- > From: xsde-users-bounces@codesynthesis.com > [mailto:xsde-users-bounces@codesynthesis.com] On Behalf Of Mark Easton > Sent: Tuesday, September 23, 2008 3:24 PM > To: xsde-users@codesynthesis.com > Subject: [xsde-users] Newbie - How to traverse my data structures? > > Hi, > > I have started on using xsde today and am struggling a > little. My problem is quite basic I think, so I just need a > stear in the right direction. > > I have a site and that site has many areas. > > What I cant understand is if I do an area_next() in my > site_simpl class, how my area_simple class knows what area > record to refer to?? > > ie I have > > xml_schema::int_simpl int_s; > xml_schema::string_simpl string_s; > > area_simpl area_s; > site_simpl site_s; > > site_s.area_serializer (area_s); > area_s.serializers(int_s, string_s); > > xml_document_simpl doc_s(site_s, "site"); std::ostringstream os; > > site_s.pre(); > doc_s.serialize(os); > site_s.post(); > > > So when in site_simpl I do an area_next(), how does > area_simple know which area record to refer to?? > > > TIA > Mark > From boris at codesynthesis.com Tue Sep 23 03:43:29 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Sep 23 03:46:32 2008 Subject: [xsde-users] Newbie - How to traverse my data structures? In-Reply-To: <01f501c91d2e$af124100$0601010a@markdevelope> References: <01eb01c91d2b$c3906830$0601010a@markdevelope> <01f501c91d2e$af124100$0601010a@markdevelope> Message-ID: <20080923074329.GA15064@karelia> Hi Mark, Mark Easton writes: > Duhh, sorry. I just realised that from my site_serializer I can access my > area_serializer and therefore tell it which record to use. I guess that is > the right way to do it. > > I found that I had to cast area_serializer to (area_simpl)area_serializer. You can definitely do it this way, however, there is a mechanism that allows you to pass custom data from "parent" serializers (site_serializer in your case) to "child" serializers (area_serializer in your case). This mechanism is explained in Chapter 4, "Type Maps" in the Embedded C++/Serializer Mapping Getting Started Guide: http://codesynthesis.com/projects/xsde/documentation/cxx/serializer/guide/#4 In particular, note how people_simpl passes individual person records to person_simpl. You may also want to read the previous Chapter 3, "Serializer Skeletons" since that's where the schema used in Chapter 4 is introduced. Boris From mark63 at azurebell.co.nz Tue Sep 23 04:15:15 2008 From: mark63 at azurebell.co.nz (Mark Easton) Date: Tue Sep 23 04:11:22 2008 Subject: [xsde-users] Newbie - How to traverse my data structures? In-Reply-To: <20080923074329.GA15064@karelia> References: <01eb01c91d2b$c3906830$0601010a@markdevelope> <01f501c91d2e$af124100$0601010a@markdevelope> <20080923074329.GA15064@karelia> Message-ID: <025701c91d54$82a32c80$0601010a@markdevelope> Oh, ok. Many thanks Boris! I had read chapter three quite quickly, but had not got on to chapter four yet. Will study that tonight and change my code tomorrow. Great tool! > -----Original Message----- > From: Boris Kolpackov [mailto:boris@codesynthesis.com] > Sent: Tuesday, September 23, 2008 7:43 PM > To: Mark Easton > Cc: xsde-users@codesynthesis.com > Subject: Re: [xsde-users] Newbie - How to traverse my data structures? > > Hi Mark, > > Mark Easton writes: > > > Duhh, sorry. I just realised that from my site_serializer I > can access > > my area_serializer and therefore tell it which record to > use. I guess > > that is the right way to do it. > > > > I found that I had to cast area_serializer to > (area_simpl)area_serializer. > > You can definitely do it this way, however, there is a > mechanism that allows you to pass custom data from "parent" > serializers (site_serializer in your case) to "child" > serializers (area_serializer in your case). > > This mechanism is explained in Chapter 4, "Type Maps" in the Embedded > C++/Serializer Mapping Getting Started Guide: > > http://codesynthesis.com/projects/xsde/documentation/cxx/seria > lizer/guide/#4 > > In particular, note how people_simpl passes individual person > records to person_simpl. You may also want to read the > previous Chapter 3, "Serializer Skeletons" since that's where > the schema used in Chapter > 4 is introduced. > > Boris > From mark63 at azurebell.co.nz Thu Sep 25 22:36:48 2008 From: mark63 at azurebell.co.nz (Mark Easton) Date: Fri Sep 26 04:00:36 2008 Subject: [xsde-users] Parsing - Getting Super Data In-Reply-To: <20080923074329.GA15064@karelia> References: <01eb01c91d2b$c3906830$0601010a@markdevelope> <01f501c91d2e$af124100$0601010a@markdevelope> <20080923074329.GA15064@karelia> Message-ID: <03fd01c91f80$b996c2f0$0601010a@markdevelope> Great tool. Got the serializers working great to produce a number of xml documents from my data. So now working on the parsers to load the data in to my server database. But I cant work out how to access super data items. I have a site which is made up of areas. I.e. SO have a site type and an area type. 1 Auckland 1 Onehunga So in my areapimpl class how do I access the id from sitepimpl (ie I need the site_id for my area record)? I have used the type map, but it only seems to be used to pass values from area up to site. Ie. class site-pskel has virtual void area(int siteid). So that is the area-pskel class calling my site-pskel class. I need it the other way around. Help Cheers Mark From mark63 at azurebell.co.nz Thu Sep 25 23:13:06 2008 From: mark63 at azurebell.co.nz (Mark Easton) Date: Fri Sep 26 04:00:59 2008 Subject: [xsde-users] RE: Parsing - Getting Super Data References: <01eb01c91d2b$c3906830$0601010a@markdevelope> <01f501c91d2e$af124100$0601010a@markdevelope> <20080923074329.GA15064@karelia> Message-ID: <040d01c91f85$cb979470$0601010a@markdevelope> The only solution I can think of is to change my serialised data to be as follows: 1 Auckland 1 1 Onehunga So, add in the extra tag. Isn't this duplicated data? With so much data to transmit this will add to the size of the serialized xml document substantially. Do I really have to do this? > -----Original Message----- > From: Mark Easton [mailto:mark63@azurebell.co.nz] > Sent: Friday, September 26, 2008 2:37 PM > To: 'xsde-users@codesynthesis.com' > Subject: Parsing - Getting Super Data > > Great tool. Got the serializers working great to produce a > number of xml documents from my data. > > So now working on the parsers to load the data in to my > server database. But I cant work out how to access super data items. > > I have a site which is made up of areas. I.e. SO have a site > type and an area type. > > > 1 > Auckland > > 1 > Onehunga > > > > > So in my areapimpl class how do I access the id from > sitepimpl (ie I need the site_id for my area record)? I have > used the type map, but it only seems to be used to pass > values from area up to site. Ie. class site-pskel has virtual > void area(int siteid). So that is the area-pskel class > calling my site-pskel class. I need it the other way around. > > Help > > Cheers > Mark > From boris at codesynthesis.com Fri Sep 26 04:18:53 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 26 04:22:21 2008 Subject: [xsde-users] Parsing - Getting Super Data In-Reply-To: <03fd01c91f80$b996c2f0$0601010a@markdevelope> References: <01eb01c91d2b$c3906830$0601010a@markdevelope> <01f501c91d2e$af124100$0601010a@markdevelope> <20080923074329.GA15064@karelia> <03fd01c91f80$b996c2f0$0601010a@markdevelope> Message-ID: <20080926081853.GA24097@karelia> Hi Mark, Mark Easton writes: > I have a site which is made up of areas. I.e. SO have a site type > and an area type. > > > 1 > Auckland > > 1 > Onehunga > > > > > So in my areapimpl class how do I access the id from sitepimpl (ie I > need the site_id for my area record)? There is no built-in mechanism for this kind of access since the data normally flows from inner parsers to the outer ones. The recommended way to handle this is to propagate the information from inner parsers to the point where you have all the parts necessary to process it. In your case, to handle area you need the area data itself as well as the site id. The place where all this information can be made conveniently available is the site_pimpl::area() callback. Here is an outline of the site_pimpl class: // In the type map, map XML Schema type for area to this struct. // // struct area_data { int id; string name; }; struct site_pimpl: size_pskel { virtual void id (int v) { site_id = v; } virtual void area (const area_data& ad) { // ad and site_id contain all the information we need. } private: int site_id; }; struct area_pimpl: area_pskel { virtual void id (int v) { ad.id = v; } virtual void name (const string& s) { ad.name = s; } virtual area_data post_area () { return ad; } private: area_data ad; }; Another alternative which is not as clean but can be useful if you can't afford to copy, say, the name string to a temporary struct is to arrange a connection between site_pimpl and area_pimpl: struct site_pimpl: size_pskel { virtual void id (int v) { site_id = v; } int site_id; }; struct area_pimpl: area_pskel { area_pimpl (site_pimpl& s) : site_p (s) { } virtual void id (int v) { // site_p.site_id conatins site id } virtual void name (const string& s) { // site_p.site_id conatins site id } private: site_pimpl& site_p; }; Boris From mark63 at azurebell.co.nz Sat Sep 27 06:56:25 2008 From: mark63 at azurebell.co.nz (Mark Easton) Date: Sat Sep 27 06:52:33 2008 Subject: [xsde-users] Parsing - Getting Super Data In-Reply-To: <20080926081853.GA24097@karelia> References: <01eb01c91d2b$c3906830$0601010a@markdevelope> <01f501c91d2e$af124100$0601010a@markdevelope> <20080923074329.GA15064@karelia> <03fd01c91f80$b996c2f0$0601010a@markdevelope> <20080926081853.GA24097@karelia> Message-ID: <02c301c9208f$af932cc0$0601010a@markdevelope> Many thanks Boris, I think I will follow through on the first technique and put the data in to data structures and then process these at the site level. Cheers Mark > -----Original Message----- > From: Boris Kolpackov [mailto:boris@codesynthesis.com] > Sent: Friday, September 26, 2008 8:19 PM > To: Mark Easton > Cc: xsde-users@codesynthesis.com > Subject: Re: [xsde-users] Parsing - Getting Super Data > > Hi Mark, > > Mark Easton writes: > > > I have a site which is made up of areas. I.e. SO have a > site type and > > an area type. > > > > > > 1 > > Auckland > > > > 1 > > Onehunga > > > > > > > > > > So in my areapimpl class how do I access the id from > sitepimpl (ie I > > need the site_id for my area record)? > > There is no built-in mechanism for this kind of access since > the data normally flows from inner parsers to the outer ones. > The recommended way to handle this is to propagate the > information from inner parsers to the point where you have > all the parts necessary to process it. In your case, to > handle area you need the area data itself as well as the site > id. The place where all this information can be made > conveniently available is the site_pimpl::area() callback. > Here is an outline of the site_pimpl class: > > // In the type map, map XML Schema type for area to this struct. > // > // > struct area_data > { > int id; > string name; > }; > > > struct site_pimpl: size_pskel > { > > virtual void id (int v) > { > site_id = v; > } > > virtual void area (const area_data& ad) > { > // ad and site_id contain all the information we need. > } > > private: > int site_id; > }; > > struct area_pimpl: area_pskel > { > > virtual void id (int v) > { > ad.id = v; > } > > virtual void name (const string& s) > { > ad.name = s; > } > > virtual area_data post_area () > { > return ad; > } > > private: > area_data ad; > }; > > Another alternative which is not as clean but can be useful if you > can't afford to copy, say, the name string to a temporary struct > is to arrange a connection between site_pimpl and area_pimpl: > > > struct site_pimpl: size_pskel > { > virtual void id (int v) > { > site_id = v; > } > > int site_id; > }; > > struct area_pimpl: area_pskel > { > area_pimpl (site_pimpl& s) > : site_p (s) > { > } > > virtual void id (int v) > { > // site_p.site_id conatins site id > } > > virtual void name (const string& s) > { > // site_p.site_id conatins site id > } > > private: > site_pimpl& site_p; > }; > > Boris >