From mgerber at junisphere.net Tue Nov 3 03:48:20 2009 From: mgerber at junisphere.net (Marco Gerber) Date: Tue Nov 3 03:48:52 2009 Subject: [xsd-users] preserve newlines in xs:string while serialization Message-ID: Hello everybody My xml schema has an element which contains a script (bash/perl ...) as formatted text. As discussed in [1], my element is also of type xs:string without any whitespace restrictions. While serialization, I also set noskipws on my ofstream os. While using the xsd generated tree serialization method (serializeInventory(os, m_xml_inventory, map, "ISO8859-1")), all newlines are replaced by a space. The same happens when I set whiteSpace restriction to 'preserve'. What am I doing wrong? [1] http://www.codesynthesis.com/pipermail/xsd-users/2009-October/002535.htm l From boris at codesynthesis.com Tue Nov 3 04:19:00 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 3 04:16:16 2009 Subject: [xsd-users] preserve newlines in xs:string while serialization In-Reply-To: References: Message-ID: Hi Marco, Marco Gerber writes: > My xml schema has an element which contains a script (bash/perl ...) as > formatted text. As discussed in [1], my element is also of type > xs:string without any whitespace restrictions. > > > > While serialization, I also set noskipws on my ofstream os. While using > the xsd generated tree serialization method (serializeInventory(os, > m_xml_inventory, map, "ISO8859-1")), all newlines are replaced by a > space. Hm, this should actually work. Are you creating the tree from scratch or is it parsed from an XML document? If it is the latter, then can you check whether the newlines are there right after parsing by printing the element's value? If this doesn't help solve the problem, I will need a test case that reproduces this (you can send it to me directly). Also, can you let me know which platform and C++ compiler you are using as well as the Xerces-C++ version? Boris From mgerber at junisphere.net Tue Nov 3 06:11:42 2009 From: mgerber at junisphere.net (Marco Gerber) Date: Tue Nov 3 06:11:57 2009 Subject: AW: [xsd-users] preserve newlines in xs:string while serialization References: Message-ID: Thanks Boris It was my fault. I wrote a test case, working with vim and found out, that all newlines are correctly written to the serialized xml file, while before, I always used Firefox to show the generated xml file. However, Firfox's xml preview replaces all newlines with a space. So, all is going ok. Thank you for the conversation :-) Marco -----Urspr?ngliche Nachricht----- Von: Marco Gerber Gesendet: Dienstag, 3. November 2009 11:44 An: 'Boris Kolpackov' Betreff: AW: [xsd-users] preserve newlines in xs:string while serialization Thanks Boris It was my fault. I wrote a test case, working with vim and found out, that all newlines are correctly written to the serialized xml file, while before, I always used Firefox to show the generated xml file. However, Firfox's xml preview replaces all newlines with a space. So, all is going ok. Thank you for the conversation :-) Marco -----Urspr?ngliche Nachricht----- Von: Boris Kolpackov [mailto:boris@codesynthesis.com] Gesendet: Dienstag, 3. November 2009 10:19 An: Marco Gerber Cc: xsd-users@codesynthesis.com Betreff: Re: [xsd-users] preserve newlines in xs:string while serialization Hi Marco, Marco Gerber writes: > My xml schema has an element which contains a script (bash/perl ...) as > formatted text. As discussed in [1], my element is also of type > xs:string without any whitespace restrictions. > > > > While serialization, I also set noskipws on my ofstream os. While using > the xsd generated tree serialization method (serializeInventory(os, > m_xml_inventory, map, "ISO8859-1")), all newlines are replaced by a > space. Hm, this should actually work. Are you creating the tree from scratch or is it parsed from an XML document? If it is the latter, then can you check whether the newlines are there right after parsing by printing the element's value? If this doesn't help solve the problem, I will need a test case that reproduces this (you can send it to me directly). Also, can you let me know which platform and C++ compiler you are using as well as the Xerces-C++ version? Boris From boris at codesynthesis.com Thu Nov 5 09:02:23 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Nov 5 09:00:07 2009 Subject: [xsd-users] dealing with xml written/read on-the-fly In-Reply-To: <4ADC98E3.5040704@kestrel.ws> References: <4AD06CA1.5030602@kestrel.ws> <4AD574C6.4020503@kestrel.ws> <4AD64A06.4070205@kestrel.ws> <4ADAD958.4000905@kestrel.ws> <4ADC98E3.5040704@kestrel.ws> Message-ID: Hi Cerion, Cerion Armour-Brown writes: > > What actually happens is this: if the raw character buffer has less > > than 100 bytes when Xerces-C++ tries to transcode the next batch of > > characters, then it will try to read some more. There is actually a > > technical reason for this other than efficiency (it has to do with > > multi-byte encodings and the buffer containing only some of the bytes > > constituting a code point). > > Indeed. > > > Because Xerces-C++ won't keep trying to read more if the stream returned > > less than 100 bytes, one way to mitigate this would be to return the > > data from InputSource::readBytes() in small chunks. If you return it > > one byte at a time, there will be no buffering at all. > > Eugh - that's horrible! :-) A quick update: I have fixed this issue for the upcoming Xerces-C++ 3.1.0 (should be out in about a month). Now it is possible to change this "low water mark" for each parser instance. Setting it to 0 disables buffering altogether. For details, see: https://issues.apache.org/jira/browse/XERCESC-1607 Boris From ssak22 at gmail.com Thu Nov 5 14:47:51 2009 From: ssak22 at gmail.com (ss ak) Date: Fri Nov 6 08:08:24 2009 Subject: [xsd-users] xsd cxx-tree Message-ID: <467867bb0911051147w34af2ac0g5f5881ddf0c771e0@mail.gmail.com> Generated the code using the below command xsd cxx-tree --generate-serialization --generate-ostream --generate-default-ctor --root-element Event --generate-xml-schema --generate-from-base-ctor c:\Event.xsd this worked well..when i didnt have namespcae in xsd...now i have a seg fault errors... here is the code i m using to make an xml from object and back to xml as string... is there any other way i cna do it.....please let me know what is wrong here... when i use a debugger...b*reaks here --->>>>>>>>>>\cxx\tree\serialization.txx * printf("\n XML string "); bool validxml=true; string xsd = "Event.xsd"; xml_schema::namespace_infomap map; map[""].name = "http://www.mycompany.com/event"; map[""].schema = xsd.c_str(); try { std::ostringstream oss; printf("\n inside try 000000 <%s> ",var.CustomerName()->c_str()); DMPEvent_(oss, varevent, map); printf("\n inside try 11111"); *--------->I DONT GET THIS PRINTF * std::string xml(oss.str ()); printf("\n inside try 222222"); std::istringstream iss (xml); xml_schema::properties props; props.no_namespace_schema_location(xsd.c_str()); Event_(iss, xml_schema::flags::keep_dom,props); printf("\n XML %s",xml.c_str()); } catch (const xml_schema::exception& e) { //log(0,"PImer",strcat("XML INVALID ",e.what())); fail(strcat("XML INVALID ",e.what())); //exit(0); } any help is great... Thanks,ss From boris at codesynthesis.com Fri Nov 6 08:16:12 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Nov 6 08:14:10 2009 Subject: [xsd-users] Re: xsd cxx-tree In-Reply-To: <467867bb0911051147w34af2ac0g5f5881ddf0c771e0@mail.gmail.com> References: <467867bb0911051147w34af2ac0g5f5881ddf0c771e0@mail.gmail.com> Message-ID: Hi, I don't see anything that would cause this behavior in the code fragment you showed. Though the other parts of your program that are not shown may cause this (e.g., varevent might be invalid). If you can send me (off list) a test case that reproduces this problem, I can take a look and try to figure out what's going on. ss ak writes: > props.no_namespace_schema_location(xsd.c_str()); If your schema is using namespaces, then you should probably use schema_location() instead of no_namespace_schema_location(). Boris From dkekel at gmail.com Fri Nov 6 10:48:37 2009 From: dkekel at gmail.com (Dmitry Kekelidze) Date: Fri Nov 6 11:06:58 2009 Subject: [xsd-users] problem with comiping expat cxx-parser Message-ID: Good day! I have such problem. I've generated xsd-code with expat parser (with option --xml-parser expat) and when I'm compiling it, I've got 4 errors: g++ -W -Wall -O3 -o sample-description-driver sample-description-driver.o hepml-pimpl.o hepml-pskel.o lcg-hepml-pimpl.o lcg-hepml-pskel.o lha1-pimpl.o lha1-pskel.o sample-description-pimpl.o sample-description-pskel.o types-pimpl.o types-pskel.o -lexpat sample-description-driver.o(.gnu.linkonce.t._ZN3xsd3cxx6parser5expat8documentIcE26translate_schema_exceptionERKNS1_16schema_exceptionIcEE+0x75): In function `xsd::cxx::parser::expat::document::translate_schema_exception(xsd::cxx::parser::schema_exception const&)': : undefined reference to `XML_StopParser' sample-description-driver.o(.gnu.linkonce.t._ZN3xsd3cxx6parser5expat8documentIcE11characters_EPKcj+0x16): In function `xsd::cxx::parser::expat::document::characters_(char const*, unsigned int)': : undefined reference to `XML_GetParsingStatus' sample-description-driver.o(.gnu.linkonce.t._ZN3xsd3cxx6parser5expat8documentIcE12end_element_EPKc+0x1d): In function `xsd::cxx::parser::expat::document::end_element_(char const*)': : undefined reference to `XML_GetParsingStatus' sample-description-driver.o(.gnu.linkonce.t._ZN3xsd3cxx6parser5expat8documentIcE14start_element_EPKcPS6_+0x26): In function `xsd::cxx::parser::expat::document::start_element_(char const*, char const**)': : undefined reference to `XML_GetParsingStatus' collect2: ld returned 1 exit status make: *** [sample-description-driver] Error 1 I'm using expat library 2.0.1. I've looked in elements.txx and found nothing wrong for XML_GetParsingStatus and XML_StopParser reference. If I comment those lines, the compilation passes without errors, but when I start the driver file with xml file as parametr, I got nothing... I've tested --xml-parser expat option also with hello example and got the same problems... Hope for Your help! From boris at codesynthesis.com Fri Nov 6 11:26:01 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Nov 6 11:23:59 2009 Subject: [xsd-users] problem with comiping expat cxx-parser In-Reply-To: References: Message-ID: Hi Dmitry, Dmitry Kekelidze writes: > Good day! > > I have such problem. I've generated xsd-code with expat parser (with option > --xml-parser expat) and when I'm compiling it, I've got 4 errors: > > : undefined reference to `XML_StopParser' I tried with expat-2.0.1 on my Debian box, in both 32 and 64-bit mode, and everything links and works without any problems. Can you make sure that your libexpat.so (or .a) actually has these symbols. For example, if I run: nm ./libexpat.so | grep XML_StopParser On my box, I get: 000027d0 T XML_StopParser Do you see something similar? If this does not help, can you let me know more about your environment, in particular: OS version, g++ version, and the configure options used to build Expat? Thanks Boris From boris at codesynthesis.com Fri Nov 6 14:06:00 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Nov 6 14:03:59 2009 Subject: [xsd-users] problem with comiping expat cxx-parser In-Reply-To: References: Message-ID: Hi Dmitry, [I've CC'ed xsd-users in case someone else has a similar problem in the future.] Dmitry Kekelidze writes: > I've tride the line that You said, it returned > > 000029e0 T XML_StopParser > > Also tried with XML_GetParsingStatus, and the answer was > > 00002b40 T XML_GetParsingStatus. I did some googling and it appears to be a somewhat common problem. The cause seems to be the expat.h header from an older version of Expat (e.g., 1.95.2) lurking in /usr/include/. You probably installed the newer version of Expat into /usr/local/ but the compiler picks up headers from /usr/include/ before /usr/local/include/. Can you try to add explicit -I/usr/local/include (or the path where you installed the Expat headers) to your g++ command line and see if it helps? Boris From nano.he at msn.com Sat Nov 7 22:23:36 2009 From: nano.he at msn.com (HE NANO) Date: Mon Nov 9 07:01:24 2009 Subject: [xsd-users] Hello Project Compiler Successfully, But runtime error. Newbie Need Help. Message-ID: Hello All, Gooday. When i get start my CodeSynthesis learning. I followed the wiki guide step by step. Now i could build Hello Example successuflly. But when i click run the project. runtime error... ///////////////////// CODE //////////////////////////////////// int main (int argc, char* argv[]) { if (argc != 2) // 1st Error. My code will step into the below block and return 1; then exit main fun. { cerr << "usage: " << argv[0] << " hello.xml" << endl; return 1; } ..... ///////////////////// CODE //////////////////////////////////// int main (int argc, char* argv[]) { argc = 2; // i assigned the value 2 to argc temporary for continue debug running. if (argc != 2) { cerr << "usage: " << argv[0] << " hello.xml" << endl; return 1; } ...... ...... hello_p.pre (); doc_p.parse (argv[1]); // 2nd runtime error happened here. hello_p.post_hello (); ////////////////////// CODE ////////////////////////////// I attached the snapshot for the 2nd runtime error. thanks in advance. BR! Nano HE C Newbie from China _________________________________________________________________ Windows Live: Keep your friends up to date with what you do online. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010 -------------- next part -------------- A non-text attachment was scrubbed... Name: xmlError.JPG Type: image/jpeg Size: 65124 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20091108/44ab4787/xmlError-0001.jpe From boris at codesynthesis.com Mon Nov 9 07:31:27 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Nov 9 07:30:07 2009 Subject: [xsd-users] Hello Project Compiler Successfully, But runtime error. Newbie Need Help. In-Reply-To: References: Message-ID: Hi Nano, Please do not send images with screenshots of errors. Instead, describe what happened in the email. See the Posting Guidelines for more information: http://www.codesynthesis.com/support/posting-guidelines.xhtml HE NANO writes: > if (argc != 2) // 1st Error. My code will step into the below block and return 1; then exit main fun. You need to pass the name of the XML file as a command line argument. Open the Project Properties dialog, select the Debug tab and enter hello.xml into the Program Arguments field. > argc = 2; // i assigned the value 2 to argc temporary for continue // debug running. argc contains the number of elements in the argv array. The program crashes because you increased this value while the array still contains the same number of elements. > C Newbie from China Note that this mailing list is not for C++ or VC++ questions. If you need help with these subjects, I suggest that you try one of the Microsoft's VC++ forums or newsgroups. Boris From ian.durkan at progeny.net Wed Nov 11 10:48:08 2009 From: ian.durkan at progeny.net (Durkan, Ian) Date: Wed Nov 11 10:48:20 2009 Subject: [xsd-users] Substitution groups & determining run-time type Message-ID: <3F87AA6367687C43A854B8E7073CDF8C0E18A4@es-108a.paxriver.progeny.net> Greetings, Using XSD-Tree: I'm in a situation where I need to determine the type of an element at runtime, when the element may be any of a substitution group. I understand how to use dynamic_cast to determine the run-time type of the element object, but I'm concerned about the performance of this method vs. accessing the DOMElement behind the object and calling its getTagName function and performing a string comparison. Does anyone have information about which approach would yield better performance? I appreciate any help or insights given. Ian Durkan ian . durkan progeny . net From boris at codesynthesis.com Wed Nov 11 12:03:59 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Nov 11 12:03:09 2009 Subject: [xsd-users] Substitution groups & determining run-time type In-Reply-To: <3F87AA6367687C43A854B8E7073CDF8C0E18A4@es-108a.paxriver.progeny.net> References: <3F87AA6367687C43A854B8E7073CDF8C0E18A4@es-108a.paxriver.progeny.net> Message-ID: Hi Ian, Durkan, Ian writes: > I'm in a situation where I need to determine the type of an element at > runtime, when the element may be any of a substitution group. I > understand how to use dynamic_cast to determine the run-time type of > the element object, but I'm concerned about the performance of this > method vs. accessing the DOMElement behind the object and calling its > getTagName function and performing a string comparison. Does anyone > have information about which approach would yield better performance? I am pretty sure dynamic_cast is going to be faster. I made a little test which I compiled with g++ 4.3.4 with -O3 and ran on 2.2Ghz Nahalem Xeon (E5520). Here are the results: virtual call : 0.0026 microseconds/call dynamic cast : 0.0104 microseconds/call strcmp : 0.0244 microseconds/call So dynamic_cast (from base to derived) is about 4 times as expensive as a virtual function call. And string comparison is about 2 times as expensive as dynamic_cast. This is not taking into account the time it will take to get the string from DOMElement (an additional virtual function call). You may also want to check Technical Report on C++ Performance[1], section 5.3.8. In particular, it mentions a C++ compiler implementation with this dynamic_cast case and a virtual function call taking the same time. So it also depends on the compiler. But, overall, I think the times for all three cases are negligible on modern hardware. I had to run the test loop 100,000,000 times -- anything less was rounded to 0. The two test files are attached. If you want to run the test, check the assembly code first to make sure your C++ compiler didn't optimize anything important away. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/TR18015.pdf Boris From boris at codesynthesis.com Wed Nov 11 12:23:50 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Nov 11 12:22:59 2009 Subject: [xsd-users] Re: accessing parsed values In-Reply-To: References: Message-ID: Hi Dmitry, In the future please send technical questions like these to the xsd-users mailing list (which I've CC'ed) instead of to me directly. This way other developers who may have experienced a similar problem can provide you with a solution. Plus questions and answers will be archived and available to others with similar problems. See also the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Dmitry Kekelidze writes: > I'm writing a class to use parsed values from xml. How can I access them? > For example in print imp I have such code: > void samplesDescriptionType_pimpl:: > documentId (const ::std::string& documentId) > { > std::cout << "documentId: " << documentId << std::endl; > } > and I need to acces documentId directly. Can You help me with this? The C++/Parser mapping that you are using does not store the data that is extracted from XML so the callback functions are the only place where the data is available. Depending on your requirements, you may want to store the data in your own data structure. The mapping provides a mechanism for assembling such an "object model" from the XML document as it is being parsed. See Chapter 4, "Type Maps" in the C++/Parser Getting Started Guide for more information on how to do this: http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#4 Alternatively, you may want to consider using an in-memory mapping, such as C++/Tree, that automatically creates the object model which can then be accessed directly. Boris From boris at codesynthesis.com Wed Nov 11 12:31:36 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Nov 11 12:30:44 2009 Subject: [xsd-users] Substitution groups & determining run-time type In-Reply-To: References: <3F87AA6367687C43A854B8E7073CDF8C0E18A4@es-108a.paxriver.progeny.net> Message-ID: And here comes the test. Boris Kolpackov writes: > The two test files are attached. If you want to run the test, check the > assembly code first to make sure your C++ compiler didn't optimize > anything important away. -------------- next part -------------- A non-text attachment was scrubbed... Name: f.cxx Type: text/x-c++src Size: 193 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20091111/bd131ff5/f.cxx -------------- next part -------------- A non-text attachment was scrubbed... Name: test.cxx Type: text/x-c++src Size: 389 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20091111/bd131ff5/test.cxx From js.homer at yahoo.com Wed Nov 11 22:54:15 2009 From: js.homer at yahoo.com (Homer J S) Date: Wed Nov 11 22:54:22 2009 Subject: [xsd-users] xml_schema::expected_element exception during DOM-Tree stage Message-ID: <6124.30031.qm@web45607.mail.sp1.yahoo.com> Hi, since the DOM-Tree stage reports error conditions exclusively by throwing exceptions my program stops cold whenever the xml_schema::expected_element exception is raised by the parser. What could I do to get the parser to continue parsing even when encountering this condition (I dont have much control over the contents of the xml string to be parsed). Many thanks, JS From boris at codesynthesis.com Thu Nov 12 08:18:00 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Nov 12 08:17:17 2009 Subject: [xsd-users] xml_schema::expected_element exception during DOM-Tree stage In-Reply-To: <6124.30031.qm@web45607.mail.sp1.yahoo.com> References: <6124.30031.qm@web45607.mail.sp1.yahoo.com> Message-ID: Hi, Homer J S writes: > Hi, since the DOM-Tree stage reports error conditions exclusively by > throwing exceptions my program stops cold whenever the > xml_schema::expected_element exception is raised by the parser. > What could I do to get the parser to continue parsing even when > encountering this condition (I dont have much control over the > contents of the xml string to be parsed). The C++/Tree generated code performs a subset of XML Schema validation to make sure the resulting object model is consistent. Without such checks, for example, you could get an object model with a missing required element value. Since there is no way to check whether such a require element value was actually set, accessing this object model will lead to an application crash. The only way to work around this that I can see would be to "fix up" the otherwise invalid XML in DOM (before passing it on to the DOM-Tree stage) by making sure that all the required elements and attributes are present. Boris From Andre.Vidigal at nav.pt Mon Nov 16 10:44:12 2009 From: Andre.Vidigal at nav.pt (Andre Vidigal) Date: Mon Nov 16 11:39:27 2009 Subject: [xsd-users] binary for OS/2 platform (IBM compiler) Message-ID: <80CB525C17447042A73D87B7B09AC92F0D0BCA61@pantera.nav.priv> Hello, I'm using IBM OS/2. Is it possible to have the XSD compiler for OS/2 eCommStation 1.2 R? Thank you, Andr? Vidigal From boris at codesynthesis.com Mon Nov 16 12:45:54 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Nov 16 12:46:10 2009 Subject: [xsd-users] binary for OS/2 platform (IBM compiler) In-Reply-To: <80CB525C17447042A73D87B7B09AC92F0D0BCA61@pantera.nav.priv> References: <80CB525C17447042A73D87B7B09AC92F0D0BCA61@pantera.nav.priv> Message-ID: Hi Andre, Andre Vidigal writes: > I'm using IBM OS/2. Is it possible to have the XSD compiler for > OS/2 eCommStation 1.2 R? We didn't try to build such a binary and, while I am not familiar with eCommStation, I think it won't be easy. However, you can always compile your schemas on another box (e.g., Linux or Windows) and then copy the generated code over to eCommStation. This is how we normally support "legacy" operating systems such as OpenVMS, z/OS, etc. The more important question is whether the C++ compiler that you plan to use to compile the generated code is modern enough. It seems IBM discontinued their VisualAge C++ for OS/2 around version 3 which is quite old. I don't think this compiler is conforming enough. There seems to be a port of GCC available for eCommStation and I think you have a better chance with this compiler. Boris From Stephen.James at genband.com Tue Nov 17 07:21:32 2009 From: Stephen.James at genband.com (Stephen James) Date: Tue Nov 17 07:27:17 2009 Subject: [xsd-users] Empty enumeration results in cxx value Message-ID: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> I want to be able to limit the values in the element, but also allow the empty element. My values end up being - enum value { cxx, busy, free }; I understand that there is no name for "" but is the value cxx controllable? Stephen James Sr. Software Engineer GENBAND Inc. 3605 E. Plano Parkway Plano, TX 75074 USA office??????????? +1.972-521-5858 mobile???????? +1.214-686-8754 stephen.james@genband.com ? From boris at codesynthesis.com Tue Nov 17 07:44:01 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 17 07:37:23 2009 Subject: [xsd-users] Empty enumeration results in cxx value In-Reply-To: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> References: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> Message-ID: Hi Stephen, Stephen James writes: > > > > > > > > > My values end up being - > > enum value > { > cxx, > busy, > free > }; > > I understand that there is no name for "" but is the value cxx controllable? Yes, you can change enumerator names with the --enumerator-regex option. For example, if add: --enumerator-regex //empty_value/ when compiling the above schema fragment, I get: enum value { empty_value, busy, free }; For more information on this option, see the NAMING CONVENTION section in the XSD Compiler Command Line Manual: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml Boris From Stephen.James at genband.com Tue Nov 17 09:26:34 2009 From: Stephen.James at genband.com (Stephen James) Date: Tue Nov 17 10:07:17 2009 Subject: [xsd-users] Empty enumeration results in cxx value In-Reply-To: References: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> Message-ID: <21F3A5EA2F1A8047A6EA370227C942B202C04ADD@gbplamail.genband.com> I get and error when I try what is suggested. ../xsd-3.2.0-sparc-solaris/bin/xsd cxx-tree --cxx-suffix .cc --hxx-suffix .h --enumerator-regex //empty_value/ acbtcap.xsd error: invalid enumerator name regex: '': Empty expression -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, November 17, 2009 6:44 AM To: Stephen James Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Empty enumeration results in cxx value Hi Stephen, Stephen James writes: > > > > > > > > > My values end up being - > > enum value > { > cxx, > busy, > free > }; > > I understand that there is no name for "" but is the value cxx controllable? Yes, you can change enumerator names with the --enumerator-regex option. For example, if add: --enumerator-regex //empty_value/ when compiling the above schema fragment, I get: enum value { empty_value, busy, free }; For more information on this option, see the NAMING CONVENTION section in the XSD Compiler Command Line Manual: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml Boris From boris at codesynthesis.com Tue Nov 17 12:34:53 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 17 12:28:13 2009 Subject: [xsd-users] Empty enumeration results in cxx value In-Reply-To: <21F3A5EA2F1A8047A6EA370227C942B202C04ADD@gbplamail.genband.com> References: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C04ADD@gbplamail.genband.com> Message-ID: Hi Stephen, Stephen James writes: > I get and error when I try what is suggested. > > ../xsd-3.2.0-sparc-solaris/bin/xsd cxx-tree --cxx-suffix .cc > --hxx-suffix .h --enumerator-regex //empty_value/ acbtcap.xsd > error: invalid enumerator name regex: '': Empty expression Sorry, I was using the development build of XSD which uses a newer version of the Boost regex library. The following equivalent expression works for me with the 3.2.0 binaries: --enumerator-regex '/^$/empty_value/' Boris From PaquetP at navcanada.ca Tue Nov 17 17:45:17 2009 From: PaquetP at navcanada.ca (Paquette, Patrick) Date: Tue Nov 17 17:45:24 2009 Subject: [xsd-users] Sort of XML "reflection" Message-ID: <474534909BE4064E853161350C47578E09C56C88@ncrmail1.corp.navcan.ca> I'm trying to think of the best way to do this, any input would be appreciated. I have a complex type T which has a sequence of elements, each of which have any cardinality. I know that each of these elements are an extension of a base type B. As an argument, a caller will be passing a string representing the name of one of these elements of the complex type T. I'd like to determine if such an element exists, and if it does, get a reference to all occurences of them to a sequence of B& I do not have the DOM association yet, as the object type was created programatically, to be serialized later. Short of serializing to a DOMDocument, parsing it to a new instance of T, and navigating the DOM tree, is there a better way of doing this? Thanks in advance, Patrick Paquette Senior Software Developer Nav Canada - Flight Inspection Engineering Technical Systems Center 280 Hunt Club Road Ottawa, ON K1V 1C1 (613) 248-6939 From boris at codesynthesis.com Wed Nov 18 10:02:57 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Nov 18 09:56:12 2009 Subject: [xsd-users] Sort of XML "reflection" In-Reply-To: <474534909BE4064E853161350C47578E09C56C88@ncrmail1.corp.navcan.ca> References: <474534909BE4064E853161350C47578E09C56C88@ncrmail1.corp.navcan.ca> Message-ID: Hi Patrick, Paquette, Patrick writes: > I'm trying to think of the best way to do this, any input would be > appreciated. > > I have a complex type T which has a sequence of elements, each of which > have any cardinality. I know that each of these elements are an > extension of a base type B. > > As an argument, a caller will be passing a string representing the name > of one of these elements of the complex type T. I'd like to determine > if such an element exists, and if it does, get a reference to all > occurences of them to a sequence of B& > > I do not have the DOM association yet, as the object type was created > programatically, to be serialized later. > > Short of serializing to a DOMDocument, parsing it to a new instance of > T, and navigating the DOM tree, is there a better way of doing this? If this is just one type T and one type B (or, maybe a few such types, as opposed to the whole object model), then you can customize T to contain a multimap of, say, element names to instances and customize B to register on its container. In case of B, the container node is specified in via c-tors or via the virtual _container() function (defined in xml_schema::type). You will need to override it to do the registration. The only issue with this approach is that B (or T) would need to know the element name in order to register on T. One way to do this would be to have a static map of std::type_info to element name in T which is manually populated with all the derivations of B and their element names (assuming each type is used for one element name). We will actually need something similar in order to support native XPath/ XQuery execution on the object model. In fact, once it is implemented, you could use use one of these languages to implement this. But this is still some time away (a month or two). Boris From PaquetP at navcanada.ca Wed Nov 18 10:26:37 2009 From: PaquetP at navcanada.ca (Paquette, Patrick) Date: Wed Nov 18 10:27:00 2009 Subject: [xsd-users] Sort of XML "reflection" Message-ID: <474534909BE4064E853161350C47578E09C56C8A@ncrmail1.corp.navcan.ca> Hi Boris, Boris writes: > If this is just one type T and one type B (or, maybe a few such types, > as opposed to the whole object model), then you can customize T to > contain a multimap of, say, element names to instances and customize > B to register on its container. In case of B, the container node is > specified in via c-tors or via the virtual _container() function > (defined in xml_schema::type). You will need to override it to do the > registration. The only issue with this approach is that B (or T) would > need to know the element name in order to register on T. One way to do > this would be to have a static map of std::type_info to element name > in T which is manually populated with all the derivations of B and > their element names (assuming each type is used for one element name). > > We will actually need something similar in order to support > native XPath/ > XQuery execution on the object model. In fact, once it is > implemented, > you could use use one of these languages to implement this. But this > is still some time away (a month or two). > Good to know on Xpath/Xquery. This solution, unfortunately, isn't generic enough for me. Someone doing maintenance on the software in the future is going to add a new element of type B to a T and wonder why this portion of the program isn't working, to find out they forgot to add to this static list. I'll look into serializing to a DOMDocument, and deserialize back to T, so that I can go find it. Might not be too efficient...I'm doing this on somewhere around 10-20 T's, 10 times a second on relatively small xml fragments of type T, hopefully my target platform can do this fast enough. Thanks for answering, Patrick From bpringle at sympatico.ca Wed Nov 18 11:52:01 2009 From: bpringle at sympatico.ca (Bill Pringlemeir) Date: Wed Nov 18 10:38:18 2009 Subject: [xsd-users] Sort of XML "reflection" In-Reply-To: <474534909BE4064E853161350C47578E09C56C88@ncrmail1.corp.navcan.ca> (Patrick Paquette's message of "Tue, 17 Nov 2009 17:45:17 -0500") References: <474534909BE4064E853161350C47578E09C56C88@ncrmail1.corp.navcan.ca> Message-ID: <87ws1nojwu.fsf@sympatico.ca> On 17 Nov 2009, PaquetP@navcanada.ca wrote: > I have a complex type T which has a sequence of elements, each of which > have any cardinality. I know that each of these elements are an > extension of a base type B. > As an argument, a caller will be passing a string representing the name > of one of these elements of the complex type T. I'd like to determine > if such an element exists, and if it does, get a reference to all > occurences of them to a sequence of B& I think that you could add virtual functionality to the base class. You can do this by wrapping the XSD generated base and all of the derived classes. The method would be something like, virtual boolean amI(std::string type) = 0; That would be elegant in that adding new types would not require the base to know about them. However, you can also create the same thing with a mapping of typeid and strings. This can be a completely static method. static boolean isKind(base * ptr, std::string); You then need a map of all derived types to the matching string (or the string could be the typeid() name). struct { char * class_name; char * given_name; } animal_map[] = { { typeid(elephant).name, "elephant" }, { typeid(mole).name, "mole" }, { typeid(monkey).name, "monkey" }, { typeid(porpoise).name, "porpoise" }, { typeid(zebra).name, "zebra } }; // get animal map index matching given name. return strcmp(typeid(*ptr).name,animal_map[index].class_name) == 0; This doesn't require as many XSD wrappers, but is less fool-proof to addition of derived classes. In both cases, the predicate functions can be used to run through a collection to 'filter' your desired targets. btw, I think this is a C++ question as opposed to XSD? fwiw, Bill Pringlemeir. From PaquetP at navcanada.ca Wed Nov 18 12:20:39 2009 From: PaquetP at navcanada.ca (Paquette, Patrick) Date: Wed Nov 18 12:32:22 2009 Subject: [xsd-users] Sort of XML "reflection" Message-ID: <474534909BE4064E853161350C47578E09C56C8B@ncrmail1.corp.navcan.ca> Hi Bill, Bill writes: > > I think that you could add virtual functionality to the base class. > You can do this by wrapping the XSD generated base and all of the > derived classes. The method would be something like, > > virtual boolean amI(std::string type) = 0; > > That would be elegant in that adding new types would not require the > base to know about them. However, you can also create the same thing > with a mapping of typeid and strings. This can be a completely static > method. > > static boolean isKind(base * ptr, std::string); > > You then need a map of all derived types to the matching string (or > the string could be the typeid() name). > > struct { > char * class_name; > char * given_name; > } animal_map[] = { > { typeid(elephant).name, "elephant" }, > { typeid(mole).name, "mole" }, > { typeid(monkey).name, "monkey" }, > { typeid(porpoise).name, "porpoise" }, > { typeid(zebra).name, "zebra } > }; > > // get animal map index matching given name. > return strcmp(typeid(*ptr).name,animal_map[index].class_name) == 0; > I'm actually not trying to map types, I'm trying to map elements. Quoting myself: "a caller will be passing a string representing the name of one of these ELEMENTS of the complex type T. I'd like to determine if such an ELEMENT exists, and if it does, get a reference to all occurences of them to a sequence of B&". The sequence of B& is because I know all elements will be at least type B. > This doesn't require as many XSD wrappers, but is less fool-proof to > addition of derived classes. > > In both cases, the predicate functions can be used to run through a > collection to 'filter' your desired targets. > > btw, I think this is a C++ question as opposed to XSD? My goal here is to reflect on the class generated by XSD to see if it contains a function to access an element whos name is a string that is provided as an argument, and if so, get a class of type at least B that references that element. I'm aware that C++ has a limited reflection capability, but I figured I can do this if I had access to the DOM association, but I do not because I created the instance of T without calling the parser (I called the default constructor to the generated class that binds to the complex type T). I was hoping that because I'm using the XSD compiler, I get a sort of reflection API in C++ for free (perhaps there was some sort of flag in the XSD compiler I missed that creates the DOM associated elements when instances of the binding classes are created from the constructors, which by default was off). Right now, it takes a bit of work to do it, but with support for Xpath coming, you get something like reflection in all classes generated by XSD. I'm now exploring the idea of creating a DOMDocument first at the point when I know all element names that need to be accessed this way (which I know already from a top level function that has this list of names), and when I create an instance of T, I won't call the default constructor, I pass it the DOMDocument, with the keep_dom flag set. > > fwiw, Thanks for your input Bill, Patrick From bpringle at sympatico.ca Wed Nov 18 15:57:41 2009 From: bpringle at sympatico.ca (Bill Pringlemeir) Date: Wed Nov 18 14:43:55 2009 Subject: [xsd-users] Sort of XML "reflection" References: <474534909BE4064E853161350C47578E09C56C8B@ncrmail1.corp.navcan.ca> Message-ID: <87lji3o8je.fsf@sympatico.ca> On 18 Nov 2009, PaquetP@navcanada.ca wrote: > I'm actually not trying to map types, I'm trying to map elements. > Quoting myself: "a caller will be passing a string representing the name > of one of these ELEMENTS of the complex type T. I'd like to determine > if such an ELEMENT exists, and if it does, get a reference to all > occurences of them to a sequence of B&". > The sequence of B& is because I know all elements will be at least type > B. > My goal here is to reflect on the class generated by XSD to see if it > contains a function to access an element whos name is a string that is > provided as an argument, and if so, get a class of type at least B that > references that element. I'm aware that C++ has a limited reflection > capability, but I figured I can do this if I had access to the DOM > association, but I do not because I created the instance of T without > calling the parser (I called the default constructor to the generated > class that binds to the complex type T). Hmm. I think I see, but your question was somewhat wrong. The 'ELEMENT' you emphasized is really the 'elements XML name'. Each element also has a class. I was assuming a complex element, not a simple one; which they all must be as they are derived from a base class? > a string representing the name of one of these ELEMENTS of the > complex type T > a string representing the name of one of these elements IN the > complex type T I am sure you knew what you meant, but you might see why I had trouble? ;-) This if the type of reflection you are after, to see if T has a specific element? I think that the IDREF mechanism of XSD might also be worth a look although I don't know if it will map to your problem, it is similar. And now I understand your question is XSD specific. Thanks, Bill Pringlemeir. -- Remember, if you smoke after sex you're doing it too fast. - Woody Allen From Stephen.James at genband.com Wed Nov 18 16:25:00 2009 From: Stephen.James at genband.com (Stephen James) Date: Thu Nov 19 07:13:42 2009 Subject: [xsd-users] Empty enumeration results in cxx value In-Reply-To: References: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C04ADD@gbplamail.genband.com> Message-ID: <21F3A5EA2F1A8047A6EA370227C942B202C5E382@gbplamail.genband.com> So this does do what I need, except that when I serialize using the empty enumerator I get instead of . The latter is what I would prefer limiting the size of the xml, which is included in messages. -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, November 17, 2009 11:35 AM To: Stephen James Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Empty enumeration results in cxx value Hi Stephen, Stephen James writes: > I get and error when I try what is suggested. > > ../xsd-3.2.0-sparc-solaris/bin/xsd cxx-tree --cxx-suffix .cc > --hxx-suffix .h --enumerator-regex //empty_value/ acbtcap.xsd > error: invalid enumerator name regex: '': Empty expression Sorry, I was using the development build of XSD which uses a newer version of the Boost regex library. The following equivalent expression works for me with the 3.2.0 binaries: --enumerator-regex '/^$/empty_value/' Boris From boris at codesynthesis.com Thu Nov 19 08:01:41 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Nov 19 07:54:50 2009 Subject: [xsd-users] Empty enumeration results in cxx value In-Reply-To: <21F3A5EA2F1A8047A6EA370227C942B202C5E382@gbplamail.genband.com> References: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C04ADD@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C5E382@gbplamail.genband.com> Message-ID: Hi Stephen, Stephen James writes: > So this does do what I need, except that when I serialize using the > empty enumerator I get instead of . The latter is what > I would prefer limiting the size of the xml, which is included in > messages. Hm, it is surprising nobody complained about this before. Thanks for reporting this! I have fixed this and you can get the update for XSD 3.2.0 via these links: http://www.codesynthesis.com/~boris/tmp/xsd-3.2.0-empty-element.tar.gz http://www.codesynthesis.com/~boris/tmp/xsd-3.2.0-empty-element.zip Simply replace the file in your standard XSD 3.2.0 distribution with the one provided in the archive. Boris From Stephen.James at genband.com Thu Nov 19 09:51:40 2009 From: Stephen.James at genband.com (Stephen James) Date: Thu Nov 19 12:08:46 2009 Subject: [xsd-users] Empty enumeration results in cxx value In-Reply-To: References: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C04ADD@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C5E382@gbplamail.genband.com> Message-ID: <21F3A5EA2F1A8047A6EA370227C942B202C5E6AF@gbplamail.genband.com> Without going to zero white space, is there a medium pretty print (fair print)? Multiple lines without all the spaces, i.e. no indents, or indents with \t? -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, November 19, 2009 7:02 AM To: Stephen James Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Empty enumeration results in cxx value Hi Stephen, Stephen James writes: > So this does do what I need, except that when I serialize using the > empty enumerator I get instead of . The latter is what > I would prefer limiting the size of the xml, which is included in > messages. Hm, it is surprising nobody complained about this before. Thanks for reporting this! I have fixed this and you can get the update for XSD 3.2.0 via these links: http://www.codesynthesis.com/~boris/tmp/xsd-3.2.0-empty-element.tar.gz http://www.codesynthesis.com/~boris/tmp/xsd-3.2.0-empty-element.zip Simply replace the file in your standard XSD 3.2.0 distribution with the one provided in the archive. Boris From boris at codesynthesis.com Thu Nov 19 12:22:46 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Nov 19 12:15:54 2009 Subject: [xsd-users] Empty enumeration results in cxx value In-Reply-To: <21F3A5EA2F1A8047A6EA370227C942B202C5E6AF@gbplamail.genband.com> References: <21F3A5EA2F1A8047A6EA370227C942B202C04A2A@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C04ADD@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C5E382@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B202C5E6AF@gbplamail.genband.com> Message-ID: Hi Stephen, Stephen James writes: > Without going to zero white space, is there a medium pretty print (fair > print)? Multiple lines without all the spaces, i.e. no indents, or > indents with \t? No, there is either the standard pretty-printing (provided by Xerces-C++) or no pretty-printing. Boris From greg at permedia.ca Fri Nov 20 12:46:14 2009 From: greg at permedia.ca (Greg Carter) Date: Fri Nov 20 12:46:22 2009 Subject: [xsd-users] Compiling to multiple DLLs, duplicate symbols problem In-Reply-To: References: Message-ID: Hello Boris, Unfortunately this problem seems to have exposed itself again. I recently upgraded to VS 2008 SP1 (I was using 2005 previously). When I upgraded and rebuilt everything went OK. Today I moved one XSD file (and the corresponding .cxx/hxx) from my dependant dll into my base dll project. Did a clean/rebuild on both and when I attempt to link the dependant dll I get the duplicate symbols problem: 1>geocosmxmllibbasecpp.lib(geocosmxmllibbasecpp.dll) : error LNK2005: "public: class xsd::cxx::tree::sequence & __thiscall xsd::cxx::tree::sequence::operator=(class xsd::cxx::tree::sequence const &)" (??4?$sequence@H$00@tree@cxx@xsd@@QAEAAV0123@ABV0123@@Z) already defined in Compaction_custom.obj 1>geocosmxmllibbasecpp.lib(geocosmxmllibbasecpp.dll) : error LNK2005: "public: __thiscall xsd::cxx::tree::sequence::~sequence(void)" (??1?$sequence@H$00@tree@cxx@xsd@@QAE@XZ) already defined in Illite_custom.obj If I build in release mode the link error goes away. In the above error message the Compaction_custom and Illite_custom are in the dependant dll being linked, geocosmxmllibbasecpp.dll is the base dll. What is odd is that the XSD file I moved is not even referenced by either of the two files that trigger the duplicate symbol error. I've double checked that the options passed to the file I moved are correct. Have done multiple cleans/manual deletes, no luck. I'm using version xsd-3.3.0.a5-i686-windows. Any ideas? I could probably package the projects up if you needed to see the error first hand. Greg. Greg Carter wrote: > Hello Boris, > > That did the trick. I did need to add the -hxx-prologue option but I > guess that is implied with the --export-symbol option. > > Thanks! > Greg. > > Boris Kolpackov wrote: >> Hi Greg, >> >> >> The solution for this problem is to export symbols for the built-in >> types from the "base" DLL and import them in all dependant DLLs and >> executables. >> To automate this we added a new option, --export-xml-schema, for the >> next >> release of XSD. You can give it a try by downloading this pre-release >> binary: >> >> http://www.codesynthesis.com/~boris/tmp/xsd-3.3.0.a5-i686-windows.zip >> >> In your case, you will need to add >> --export-xml-schema --export-symbol GEOCOSMXMLBASE_SYMBOL_DECL >> >> when generating the code for the XML Schema namespace (i.e., "compiling" >> XSDBaseXmlSchema.xsd). >> >> Let me know if this works for you. >> >> Boris >> >> > From boris at codesynthesis.com Mon Nov 23 09:15:13 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Nov 23 09:08:53 2009 Subject: [xsd-users] Compiling to multiple DLLs, duplicate symbols problem In-Reply-To: References: Message-ID: Hi Greg, Greg Carter writes: > Did a clean/rebuild on both and when I attempt to link the dependant > dll I get the duplicate symbols problem: > > 1>geocosmxmllibbasecpp.lib(geocosmxmllibbasecpp.dll) : error LNK2005: > "public: class xsd::cxx::tree::sequence & __thiscall > xsd::cxx::tree::sequence::operator=(class > xsd::cxx::tree::sequence const &)" > (??4?$sequence@H$00@tree@cxx@xsd@@QAEAAV0123@ABV0123@@Z) already defined > in Compaction_custom.obj > 1>geocosmxmllibbasecpp.lib(geocosmxmllibbasecpp.dll) : error LNK2005: > "public: __thiscall > xsd::cxx::tree::sequence::~sequence(void)" > (??1?$sequence@H$00@tree@cxx@xsd@@QAE@XZ) already defined in > Illite_custom.obj This doesn't look good. It won't be easy to fix with the simple symbol export that was used before since this is a sequence template instantiation and there could be tons of them, with different types. > I could probably package the projects up if you needed to see the error > first hand. Yes, that would be great (you can send it to me off list). I think I will have to talk to the Microsoft folks about this. Boris From vladimir.vasilyev at mobile-mir.com Mon Nov 23 14:25:40 2009 From: vladimir.vasilyev at mobile-mir.com (Vladimir Vasilyev) Date: Mon Nov 23 14:25:49 2009 Subject: [xsd-users] Customizing generated code: Renaming classes, fields and functions. Message-ID: <07a876f35516b1fa9ac9810f4cc36834-EhVcX15AQgdcRx4VCggJSxsKNG5dVUNdXEZbA1xYR0JQOl8AQVt0H1dUVEFeRkRtXlhcSVhVXAtbXw==-webmailer2@server03.webmailer.hosteurope.de> Hello, i am new to the xsd tool and could not find the corresponding documentation myself... So please help me. 1. How can I rename the getters and setters using prefixes, suffixes and/or other standard operations? For a field "name" I want to have a getter "GetName" and setters "SetName", and not "const string& name" and "void name". 2. How can I rename the getter using my own algorithm? For a field "NS_FIELDNAMEFROMXSDWHICHCANNOTBEMODIFIED" i want to make getter and setter with something like "GetFieldName" and "SetFieldName", and not "const Type& NS_FIELDNAMEFROMXSDWHICHCANNOTBEMODIFIED" and "void NS_FIELDNAMEFROMXSDWHICHCANNOTBEMODIFIED". 3. How can I rename the member fields from "name_" to "m_name"? Our coding style is different and should not be modified... 4. How can I rename classes using my own algorithm? For a field "NS_SOMECLASSFROMXSDWHICHCANNOTBEMODIFIED" i want to make "SomeClass". Thank you in advance! Best regards, Vladimir. From vladimir.vasilyev at mobile-mir.com Mon Nov 23 14:27:52 2009 From: vladimir.vasilyev at mobile-mir.com (Vladimir Vasilyev) Date: Mon Nov 23 14:28:00 2009 Subject: [xsd-users] Controling the registration of the polymorphic types. Message-ID: <302e63d402671141fc40055910e73f72-EhVcX15AQgdcRx4VCggJSxsKNG5dVUNdXEZbA1xYR0JQOl8AQVt0H1dUVEFeRkRtXlhcSVhVXAxYXQ==-webmailer2@server03.webmailer.hosteurope.de> Hello, i am still new to the xsd tool and could not find out how to customize the handling of polymorphic types... So i am begging for help. How can i control the registration of the polymorphic types? I want to be able to register the type on demand (for instance when the dll is being loaded) and not by a static variable. How can i remove static variables and generate a [global] function with several calls to type_factory_map_instance.register_type? Best regards, Vladimir. From boris at codesynthesis.com Tue Nov 24 05:58:10 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 24 05:51:31 2009 Subject: [xsd-users] Customizing generated code: Renaming classes, fields and functions. In-Reply-To: <07a876f35516b1fa9ac9810f4cc36834-EhVcX15AQgdcRx4VCggJSxsKNG5dVUNdXEZbA1xYR0JQOl8AQVt0H1dUVEFeRkRtXlhcSVhVXAtbXw==-webmailer2@server03.webmailer.hosteurope.de> References: <07a876f35516b1fa9ac9810f4cc36834-EhVcX15AQgdcRx4VCggJSxsKNG5dVUNdXEZbA1xYR0JQOl8AQVt0H1dUVEFeRkRtXlhcSVhVXAtbXw==-webmailer2@server03.webmailer.hosteurope.de> Message-ID: Hi Vladimir, Vladimir Vasilyev writes: > 1. How can I rename the getters and setters using prefixes, suffixes > and/or other standard operations? > For a field "name" I want to have a getter "GetName" and setters > "SetName", and not "const string& name" and "void name". See Section "NAMING CONVENTION" in the XSD Compiler Command Line Manual: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml You could have used the 'java' function naming convention except that the name would start with a lower case letter instead of the upper case as you need. So you will probably need to provide your own regular expressions. > 2. How can I rename the getter using my own algorithm? You can provide your own regular expressions to transform the function names. See the above mentioned documentation for details. > 3. How can I rename the member fields from "name_" to "m_name"? > Our coding style is different and should not be modified... You currently cannot do this except by customizing the compiler. Note, however, that these variables are private so the hand-written code will never reference such names directly. > 4. How can I rename classes using my own algorithm? You can provide your own regular expressions to transform the type names. See the above mentioned documentation for details. Boris From boris at codesynthesis.com Tue Nov 24 11:07:47 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 24 11:01:11 2009 Subject: [xsd-users] Controling the registration of the polymorphic types. In-Reply-To: <302e63d402671141fc40055910e73f72-EhVcX15AQgdcRx4VCggJSxsKNG5dVUNdXEZbA1xYR0JQOl8AQVt0H1dUVEFeRkRtXlhcSVhVXAxYXQ==-webmailer2@server03.webmailer.hosteurope.de> References: <302e63d402671141fc40055910e73f72-EhVcX15AQgdcRx4VCggJSxsKNG5dVUNdXEZbA1xYR0JQOl8AQVt0H1dUVEFeRkRtXlhcSVhVXAxYXQ==-webmailer2@server03.webmailer.hosteurope.de> Message-ID: Hi Vladimir, Vladimir Vasilyev writes: > How can i control the registration of the polymorphic types? There is not much you can control at the moment. The types are registered automatically during static initialization. > I want to be able to register the type on demand (for instance when the > dll is being loaded) and not by a static variable. This will happen automatically with the current registration model. On Windows if you have your type hierarchy spread over multiple DLLs and/or executable, then you will need to export the polymorphic type maps from the "base" DLL and import them from all the other DLLs and the executable using the --export-maps/--import-maps options (see the documentation for more information). The only thing that is not supported in XSD 3.2.0 is de-registration of the types when DLLs are unloaded. This has been fixed for the next release of XSD and an update is available for XSD 3.2.0: http://www.codesynthesis.com/~boris/tmp/xsd-3.2.0-map-unregister.zip > How can i remove static variables and generate a [global] function with > several calls to type_factory_map_instance.register_type? There is no way to do this at the moment. It will also be difficult to implement since there could be multiple schema files each of which is translated to a separate C++ source file (or, in the file-per-type mode, to multiple C++ files). So there is no way to provide a central function which performs all the registration. Can you explain why you want to do the registration manually? Boris From Monte.Jones.ctr at peterson.af.mil Tue Nov 24 11:38:55 2009 From: Monte.Jones.ctr at peterson.af.mil (Jones, Monte J CTR USAF AFSPC SLG/WML) Date: Wed Nov 25 01:39:18 2009 Subject: [xsd-users] Help for User Defined Types Message-ID: I am attempting to parse an XML with user defined data types. I am using these because some of these data types appear in multiple places in the XML document. For example one of the types I have is a location which is defined as indicated below. I use this for many assets, each with different other parameters. Here is the example of how I am using my type in the xsd. The schema validates, and the parser code compiles but does not link. I think the problem comes in the Location contains no actual data, only the definitions of data. The auto generated -pskel and -pimpl files have shells for parsing Location data, but then I am having trouble with the use for different assets because I do not have a defined implementation for the shell. We have used Xerces-C and Code Synthesis XSD a lot, but none of the previous implementations contained user defined types. I really think this is a misunderstanding on my part about what to do, not a product problem. Can anyone point me in the right direction for including, using, and parsing user defined types? Monte J. Jones, Contractor Colorado Professional Resources SMC/SLG/WMLE 1050 E Stewart Ave Colorado Springs, CO 80914 719-556-9903 This electronic message contains information from Colorado Professional Resources, LLC and is confidential or privileged. The information is intended solely for the use of the individual(s) or entity(ies) named above. If you are not the intended recipient, be aware that any disclosure, copying, distribution, or use of the contents of this message is prohibited. If you have received this email in error, please notify us immediately by telephone at (719) 599-1353, or by email and then immediately delete this message. From ian.durkan at progeny.net Wed Nov 25 10:11:43 2009 From: ian.durkan at progeny.net (Durkan, Ian) Date: Wed Nov 25 10:11:51 2009 Subject: [xsd-users] Reading of Schemas at Validation? Message-ID: <3F87AA6367687C43A854B8E7073CDF8C0E19B7@es-108a.paxriver.progeny.net> Greetings, I'm curious about how a C++/Tree-generated API goes about validating input documents for parsing against schema(s). I'm specifying the location of a schema (on a local disk) via a properties object, and re-using the same schema to parse a large number of documents. Which option describes how the schema is stored in memory? 1. Generated functions read in the schema file (and the files it includes) only the first time a parsing function is called with a particular schema, and then a representation of the schema is held in memory until our program is terminated. 2. Schema file(s) are read each time a parsing call is made. If the second option is true, is there a way to reuse the schema-in-memory for every parsing call? Ian Durkan ian . durkan progeny . net From boris at codesynthesis.com Wed Nov 25 10:58:43 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Nov 25 10:52:24 2009 Subject: [xsd-users] Help for User Defined Types In-Reply-To: References: Message-ID: Hi Monte, Jones, Monte J CTR USAF AFSPC SLG/WML writes: > I am attempting to parse an XML with user defined data types. I am > using these because some of these data types appear in multiple places > in the XML document. For example one of the types I have is a location > which is defined as indicated below. I use this for many assets, each > with different other parameters. > > > > > > > > > > > > > > > > > > > > > > > > > > Here is the example of how I am using my type in the xsd. > > > > > The schema validates, and the parser code compiles but does not link. What kind of link errors do you get? > I think the problem comes in the Location contains no actual data, only > the definitions of data. The auto generated -pskel and -pimpl files > have shells for parsing Location data, but then I am having trouble with > the use for different assets because I do not have a defined > implementation for the shell. My understanding is that you have generated sample parser implementations (either using the --generate-noop-impl or --generate-print-impl) and the problem is how to "return" the parsed location information to the various parsers that have elements of the Location type so that they can do something useful with it. This is similar to how, say, the built-in xml_schema::float_pimpl parser implementation returns a float value. The cleanest way would be to define a data structure that represents the location information, for example: // location.h // struct Location { float lat; float lon; float alt; }; Then use the C++/Parser type map mechanism to tell the XSD compiler that the Location XML Schema type is mapped to this struct and also map the anonymous types for the Latitude, Longitude, and Altitude elements to float: // type-map.map // include "location.h"; Location ::Location; Latitude float; Longitude float; Altitude float; This will result in the Location parser skeleton having the following interface: struct Location_pskel { virtual void Latitude (float); virtual void Longitude (float); virtual void Altitude (float); virtual ::Location post_Location (); }; Then we can provide the following implementation: struct Location_pimpl: Location_pskel { virtual void Latitude (float v) { loc_.lat = v; } virtual void Longitude (float v) { loc_.lon = v; } virtual void Altitude (float v) { loc_.alt = v; } virtual ::Location post_Location () { return loc_; } ::Location loc_; }; We will also need to provide the following implementations for the Latitude, Longitude, and Altitude parsers (only Latitude is shown): struct Latitude_pimpl: Latitude_pskel, xml_schema::float_pimpl { virtual float post_Latitude () { return post_float (); } }; For a more detailed discussion of type maps and the parser return mechanism, see Chapter 4, "Type Maps", in the C++/Parser Mapping Getting Started Guide: http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#4 Boris From boris at codesynthesis.com Wed Nov 25 11:10:03 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Nov 25 11:03:38 2009 Subject: [xsd-users] Reading of Schemas at Validation? In-Reply-To: <3F87AA6367687C43A854B8E7073CDF8C0E19B7@es-108a.paxriver.progeny.net> References: <3F87AA6367687C43A854B8E7073CDF8C0E19B7@es-108a.paxriver.progeny.net> Message-ID: Hi Ian, Durkan, Ian writes: > Which option describes how the schema is stored in memory? > > 1. Generated functions read in the schema file (and the files it > includes) only the first time a parsing function is called with a > particular schema, and then a representation of the schema is held in > memory until our program is terminated. > > 2. Schema file(s) are read each time a parsing call is made. If you are using the generated parsing functions then it is (2). These functions are stateless so they create a new XML parser, load the schemas, parse the XML document and then destroy the parser. > If the second option is true, is there a way to reuse the schema-in- > memory for every parsing call? Yes, you can pre-load and reuse the schemas along with the XML parser to parse multiple XML documents. See the 'caching' example in the examples/cxx/tree/ directory of the XSD distribution for more information on how to do this. It is also possible to pre-compile the schemas into a binary representation and even embed them into the application. While there is no example that shows how to do this in XSD 3.2.0, we have created such an example for the next release of XSD. Let me know if you are interested and I will send it to you. Boris From bpringle at sympatico.ca Wed Nov 25 17:35:45 2009 From: bpringle at sympatico.ca (Bill Pringlemeir) Date: Wed Nov 25 16:21:02 2009 Subject: [xsd-users] Reading of Schemas at Validation? References: <3F87AA6367687C43A854B8E7073CDF8C0E19B7@es-108a.paxriver.progeny.net> Message-ID: <87zl6az0zi.fsf@sympatico.ca> On 25 Nov 2009, ian.durkan@progeny.net wrote: > 1. Generated functions read in the schema file (and the files it > includes) only the first time a parsing function is called with a > particular schema, and then a representation of the schema is held in > memory until our program is terminated. http://wiki.codesynthesis.com/Tree/FAQ#How_can_I_speed_up_parsing.3F > 2. Schema file(s) are read each time a parsing call is made. > If the second option is true, is there a way to reuse the > schema-in-memory for every parsing call? This is the default as far as I know. Otherwise the schema caching wouldn't be too useful. There is also, http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3.2 Note the flag "xml_schema::flags::dont_validate". This turns off validation in a strict sense. Complete non-sense will be un-parsable and give some error. hth, Bill Pringlemeir.