From jelari at gmail.com Tue Mar 4 06:48:28 2008 From: jelari at gmail.com (Ramprakash Jelari thinakaran) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] API? Message-ID: Hi ALL Is there any API exists for CodeSynthesis?.. Given an .xsd file i should be able to generate related c++ code just by calling a function() which can be intergrated into any programing language?.. Kindly reply to me as i have not registered in the mailing list. -- Regards, Ramprakash Jelari From boris at codesynthesis.com Tue Mar 4 07:26:41 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] API? In-Reply-To: References: Message-ID: <20080304122641.GA12960@karelia> Hi Ramprakash, Ramprakash Jelari thinakaran writes: > Is there any API exists for CodeSynthesis?.. Given an .xsd file i should be > able to generate related c++ code just by calling a function() which can be > intergrated into any programing language?.. No, there is no such API. You can, however, modify the compiler's source code to provide such a functionality (see the xsd.cxx file to start). Alternatively, you could simply execute the compiler as another process from your application. Boris From lvkun2006 at gmail.com Tue Mar 4 20:56:26 2008 From: lvkun2006 at gmail.com (kun lv) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Serialization Problem with namespace Message-ID: <32b74eaf0803041756x623bce1aq4f538b83d4754b76@mail.gmail.com> Hi ALL Now I am able to output some string with the code generated by XSD. They look like: ------ how can I get the string without the namespace. like: thank you :) From boris at codesynthesis.com Wed Mar 5 02:15:22 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Serialization Problem with namespace In-Reply-To: <32b74eaf0803041756x623bce1aq4f538b83d4754b76@mail.gmail.com> References: <32b74eaf0803041756x623bce1aq4f538b83d4754b76@mail.gmail.com> Message-ID: <20080305071522.GC17118@karelia> Hi, kun lv writes: > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" > http://ContentImport ContentDefine"> > > [...] > > how can I get the string without the namespace. like: > > If the schema that defines the ContentDefine element has target namespace then you will need to get rid of that first. Then, in your code, you have a fragment that looks like this and which you need to remove: map[""].name = "http://ContentImport "; map[""].schema = "ContentDefine"; If this does not help then send the code sample that shows how you perform the serialization. Boris From boris at codesynthesis.com Wed Mar 5 04:37:06 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Serialization Problem with namespace In-Reply-To: <32b74eaf0803050019j6c2658afq63dc9c94de5cf443@mail.gmail.com> References: <32b74eaf0803041756x623bce1aq4f538b83d4754b76@mail.gmail.com> <20080305071522.GC17118@karelia> <32b74eaf0803050019j6c2658afq63dc9c94de5cf443@mail.gmail.com> Message-ID: <20080305093706.GA18147@karelia> Hi, In the future please keep your replies CC'ed to the xsd-users mailing list. This way other developers who may have experienced a similar problem can provide you with a solution. Plus questions and answers will be archived and available to others with similar problems. kun lv writes: > But if i remove these code??I will get exception: > xsd::cxx::tree::no_namespace_mapping This means your schema has a target namespace. If you want your XML to not have any 'xmlns' attributes then the only way to do it is to get rid of the target namespace in your schema (remove the targetNamespace attribute). Boris From tdninh at tma.com.vn Wed Mar 5 21:22:55 2008 From: tdninh at tma.com.vn (Ninh Tran Dang) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Parsing for the substitutionGroup In-Reply-To: <20080214135953.GD1502@karelia> References: <002b01c86f0a$ed78c450$768010ac@tdninh> <20080214135953.GD1502@karelia> Message-ID: <000301c87f30$fd3b7870$768010ac@tdninh> Hi Boris, I tried the XSD for the substitutionGroup defintion, and I got another problem when parsing the elements in the substitutionGroup with the same element type (not the derived type as the example of 5.4 section - http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5. 4). Please see the schema below, the "startup", "candidate", and "running" defined with the same configNameType type. Could you please help me answer this? Thanks, Ninh -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, February 14, 2008 9:00 PM To: Ninh Tran Dang Cc: xsde-users@codesynthesis.com; dangninhtran@vnn.vn Subject: Re: [xsde-users] Parsing for the substitutionGroup Hi Ninh Tran, Ninh Tran Dang writes: > I currently use the XSDe as a part of my program. I have difficulty with > parsing the NETCONF schema using the substitutionGroup definition. XML Schema polymorphism (xsi:type and substitution groups) are not yet supported in XSD/e though we are planning to add this support in the next release which is scheduled for the end of April. Another alternative would be to use XSD instead of XSD/e. The C++/Parser mapping in XSD supports polymorphism, see Section 5.4, "Support for Polymorphism" in the C++/Parser Getting Started Guide: http://codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.4 Yet another alternative would be for us to implement support for polymorphism in XSD/e and provide you with a custom binary before the official release (this shouldn't take more than a few weeks). This option is only available on the commercial basis with a proprietary license or priority support contract for XSD/e. Boris From boris at codesynthesis.com Thu Mar 6 02:41:27 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Parsing for the substitutionGroup In-Reply-To: <000301c87f30$fd3b7870$768010ac@tdninh> References: <002b01c86f0a$ed78c450$768010ac@tdninh> <20080214135953.GD1502@karelia> <000301c87f30$fd3b7870$768010ac@tdninh> Message-ID: <20080306074127.GB22989@karelia> Hi Ninh, Ninh Tran Dang writes: > I tried the XSD for the substitutionGroup defintion, and I got another > problem when parsing the elements in the substitutionGroup with the same > element type (not the derived type as the example of 5.4 section - > http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5. > 4). I've tested same-type substitution groups and they work fine for me. Here is the test case I used: http://www.codesynthesis.com/~boris/tmp/same-type.tar.gz If this still does not work for you, can you be more specific about the problem you are experiencing? Boris From tdninh at tma.com.vn Thu Mar 6 04:16:22 2008 From: tdninh at tma.com.vn (Ninh Tran Dang) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Parsing for the substitutionGroup In-Reply-To: <20080306074127.GB22989@karelia> References: <002b01c86f0a$ed78c450$768010ac@tdninh> <20080214135953.GD1502@karelia> <000301c87f30$fd3b7870$768010ac@tdninh> <20080306074127.GB22989@karelia> Message-ID: <002801c87f6a$beefd9f0$768010ac@tdninh> Thanks Boris. I got problem when using Tree mapping to the configNameType below. When parsing with the elements in the "config-name" substitutionGroup like: startup, candidate, running, I received the same object of configNameType for startup, candidate and running. So how to differentiate and get the correct element in this case? The most important thing is how to know the incoming element name (startup, candidate, or running) when they are defined to the same type of configNameType. Thanks, Ninh -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, March 06, 2008 2:41 PM To: Ninh Tran Dang Cc: xsd-users@codesynthesis.com; dangninhtran@vnn.vn Subject: Re: [xsd-users] Parsing for the substitutionGroup Hi Ninh, Ninh Tran Dang writes: > I tried the XSD for the substitutionGroup defintion, and I got another > problem when parsing the elements in the substitutionGroup with the same > element type (not the derived type as the example of 5.4 section - > http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5. > 4). I've tested same-type substitution groups and they work fine for me. Here is the test case I used: http://www.codesynthesis.com/~boris/tmp/same-type.tar.gz If this still does not work for you, can you be more specific about the problem you are experiencing? Boris From boris at codesynthesis.com Thu Mar 6 04:26:06 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Parsing for the substitutionGroup In-Reply-To: <002801c87f6a$beefd9f0$768010ac@tdninh> References: <002b01c86f0a$ed78c450$768010ac@tdninh> <20080214135953.GD1502@karelia> <000301c87f30$fd3b7870$768010ac@tdninh> <20080306074127.GB22989@karelia> <002801c87f6a$beefd9f0$768010ac@tdninh> Message-ID: <20080306092606.GA25720@karelia> Hi Ninh, Ninh Tran Dang writes: > I got problem when using Tree mapping to the configNameType below. When > parsing with the elements in the "config-name" substitutionGroup like: > startup, candidate, running, I received the same object of configNameType > for startup, candidate and running. So how to differentiate and get the > correct element in this case? > > The most important thing is how to know the incoming element name (startup, > candidate, or running) when they are defined to the same type of > configNameType. Ok, so you are using C++/Tree, not C++/Parser. Since all your elements are of the same type, the only thing that differentiates them is the element name. This makes the whole idea somewhat pointless: it would be much more straightforward to add an attribute to configNameType that holds this information instead of encoding it into element's names. Element names are not preserved in the object model. So the only way to access them is via DOM. There are several way to do this: 1. If the startup, candidate, etc., elements are document roots then you can split the XML-to-object model parsing into two stages: XML-to-DOM and DOM-to-object model. This will allow you to determine which element is used. For more information on this approach, see the 'multiroot' example. 2. Using the DOM association feature you can obtain a corresponding DOM element from an object model node and then query the element's name. For more information, see the "DOM Association" section in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#5.1 This method will work for both root and non-root elements. 3. For non-root elements, you can also customize the parsing constructor of the type which includes the config-name element and query the element name there. For more information on this approach see the 'wildcard' example in the examples/cxx/tree/custom/ directory as we all the C++/Tree Mapping Customization Guide: http://wiki.codesynthesis.com/Tree/Customization_guide Boris From sbalasub at qualcomm.com Thu Mar 6 18:42:41 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] xsd:ref problem Message-ID: Hi, I am using the xsd:ref and I am have some issues. Here is the use case with some psedo-xsd. I will send actual ones if this is confusing. core.xsd => namespace = types FeatureX.xsd => namespace = types Application.xsd=> namespace = app Include core.xsd Include FeatureX.xsd When CS generate the code, reference to X is found but not Y. Any ideas why? Why cannot I have two elements in different files in the same namespace? Thanks, Shiva From sbalasub at qualcomm.com Thu Mar 6 19:18:35 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] RE: xsd:ref problem Message-ID: I am resending this email with complete example, I have simplified the contents. Core.xsd looks like below Mtl.xsd HTH, Shiva ________________________________ From: Balasubramanyam, Shivakumar Sent: Thursday, March 06, 2008 3:43 PM To: 'xsd-users@codesynthesis.com' Subject: xsd:ref problem Hi, I am using the xsd:ref and I am have some issues. Here is the use case with some psedo-xsd. I will send actual ones if this is confusing. core.xsd => namespace = types FeatureX.xsd => namespace = types Application.xsd=> namespace = app Include core.xsd Include FeatureX.xsd When CS generate the code, reference to X is found but not Y. Any ideas why? Why cannot I have two elements in different files in the same namespace? Thanks, Shiva From sbalasub at qualcomm.com Thu Mar 6 19:28:29 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] RE: xsd:ref problem In-Reply-To: References: Message-ID: I came out of a memory lapse. Boris has explained this very well that it is not doable. I guess I can have only one import with unique namespace/schemaLocation Thanks, Shiva ________________________________ From: Balasubramanyam, Shivakumar Sent: Thursday, March 06, 2008 4:19 PM To: Balasubramanyam, Shivakumar; xsd-users@codesynthesis.com Subject: RE: xsd:ref problem I am resending this email with complete example, I have simplified the contents. Core.xsd looks like below Mtl.xsd HTH, Shiva ________________________________ From: Balasubramanyam, Shivakumar Sent: Thursday, March 06, 2008 3:43 PM To: 'xsd-users@codesynthesis.com' Subject: xsd:ref problem Hi, I am using the xsd:ref and I am have some issues. Here is the use case with some psedo-xsd. I will send actual ones if this is confusing. core.xsd => namespace = types FeatureX.xsd => namespace = types Application.xsd=> namespace = app Include core.xsd Include FeatureX.xsd When CS generate the code, reference to X is found but not Y. Any ideas why? Why cannot I have two elements in different files in the same namespace? Thanks, Shiva From sbalasub at qualcomm.com Thu Mar 6 22:09:41 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Elements of same time in different heirarchy Message-ID: Hi, I noticed that an element X cannot be repeated even if it is present in a different hierarchy. For example, FileOne.xsd FileTwo.xsd When I compile each as FileOne.o and FileTwo.o and finally link to a single executable, I would get multiple declaration error. Is this CS limitation? Thanks, Shiva From boris at codesynthesis.com Fri Mar 7 01:29:42 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Elements of same time in different heirarchy In-Reply-To: References: Message-ID: <20080307062942.GA27771@karelia> Hi Shiva, Balasubramanyam, Shivakumar writes: > I noticed that an element X cannot be repeated even if it is present in > a different hierarchy. > > > When I compile each as FileOne.o and FileTwo.o and finally link to a > single executable, I would get multiple declaration error. I would need to see a real schema to say for sure what's going on here. Generally, if two schemas with the same namespace (or with different schema namespaces which are mapped to the same C++ namespace) have any global type definitions or element declarations, then you will get conflicting symbols. This is, however, pretty easy to resolve: just put the generated code for one of the schemas into a different C++ namespace (--namespace-map option). Boris From uri at hyperroll.com Sun Mar 9 08:30:13 2008 From: uri at hyperroll.com (Uri Karagila) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] xsd 3.1.0 does not work on Windows 2003 Server on Itanium (IA64) platform Message-ID: <783879783B65E44995520FEF376C453847D60D@ilexch1.int.hyperroll.com> Hi, xsd 3.1.0 does not work on Windows 2003 Server on Itanium (IA64) platform The same binary with the same input files works OK on 32-bit Windows XP SP2. --- C:\users\alexey\wk\hr\512\src\main\hdx>c:\cygwin\bin\make LP64=ia64 1 "c:\buildtools/Windows/xsd/bin/xsd" \ cxx-tree --generate-default-ctor \ --show-sloc --root-element-all --namespace-map =hdxns \ --generate-serialization --generate-polymorphic \ --hxx-epilogue-file "Application.h" \ --cxx-epilogue-file "Application.cpp" \ HyperRoll-Application.xsd make: *** [HyperRoll-Application.cxx] Error 5 C:\users\alexey\wk\hr\512\src\main\hdx>c:\buildtools\Windows\xsd\bin\xsd cxx-tree HyperRoll-Application.xsd C:\users\alexey\wk\hr\512\src\main\hdx>echo %ERRORLEVEL% -1073741819 C:\users\alexey\wk\hr\512\src\main\hdx>echo %PROCESSOR_ARCHITECTURE% IA64 C:\users\alexey\wk\hr\512\src\main\hdx>ver Microsoft Windows [Version 5.2.3790] C:\users\alexey\wk\hr\512\src\main\hdx> --- Please advice Regards Uri From boris at codesynthesis.com Sun Mar 9 08:38:49 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] xsd 3.1.0 does not work on Windows 2003 Server on Itanium (IA64) platform In-Reply-To: <783879783B65E44995520FEF376C453847D60D@ilexch1.int.hyperroll.com> References: <783879783B65E44995520FEF376C453847D60D@ilexch1.int.hyperroll.com> Message-ID: <20080309123849.GA14959@karelia> Hi Uri, Uri Karagila writes: > xsd 3.1.0 does not work on Windows 2003 Server on Itanium (IA64) > platform The same binary with the same input files works OK on > 32-bit Windows XP SP2. Not a big surprise here; the binary is x86 while the platform is IA64, and, as far as I know, there is no implicit emulation for x86 on IA64 Windows. You have two options: 1. Gnereta the code on another box (e.g., x86 Windows) and copy it to your IA64. 2. Build the IA64 binary yourself. We don't have access to Windows on IA64 so we can't do this for you. The instructions are here: http://www.codesynthesis.com/projects/xsd/extras/build-windows.xhtml Boris From fredrik at elestedt.com Mon Mar 10 06:40:07 2008 From: fredrik at elestedt.com (Fredrik Elestedt) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Parsing namespace problem Message-ID: Hi, I have a bit of a parsing problem for which I cannot find any solution online :( Hopefully someone here can help me. When I try to parse a message that I receive on a socket I get the following error: no mapping provided for namespace ''. All occurences of are the same... this is verified already. This is how I parse: * 105 auto_ptr message; 106 ::xml_schema::properties schema; 107 schema.schema_location("", "./schema.xsd"); 108 const xml_schema::flags validate(0); 109 try 110 { 111 fprintf(stderr, "ClientCmi:: About to handle:\n%s\n", m_xmlBuffer.c_str()); 112 message = ctcif::GeneralMessage_(xml, validate, schema); 113 handleMessage(*message); 114 } 115 catch (const xml_schema::no_namespace_mapping& e) 116 { 117 fprintf(stderr, "ClientCmi:: bad xml: %s\n%s\n", e.namespace_().c_str(), boost::lexical_cast(e).c_str()); 118 } * And the XML which I try to parse starts with: * ... * The xsd starts with: ** I've tried to add *schema.no_namespace_schema_location("./schema.xsd");* to the parsing, then I get this error: *Schema in ./schema.xsd has a different target namespace from the one specified in the instance document .* Anyone have any idea of what I'm doing wrong here? Or what is wrong in the xml I'm trying to parse? Any help is much appriciated. // Fredrik From boris at codesynthesis.com Mon Mar 10 07:55:12 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Parsing namespace problem In-Reply-To: References: Message-ID: <20080310115512.GD17046@karelia> Hi Fredrik, Fredrik Elestedt writes: > no mapping provided for namespace ''. This message is produced by the no_namespace_mapping exception which is only thrown during serialization. Are you sure you get this message during parsing? If you get it during serialization, then the most likely cause of this is that you don't provide the namespace-prefix mapping for '' via the namespace_infomap. To correct this add the following line to your serialization code: map[""].name = ""; Where map is the instance of xml_schema::namespace_infomap. Boris From johns at lanl.gov Tue Mar 11 02:36:31 2008 From: johns at lanl.gov (Russell C. Johns) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Roundtrip errors with CXX-Tree Message-ID: <1175.128.165.253.74.1205217391.squirrel@webmail.lanl.gov> Hi- I have been attempting to round trip a document from memory to XML to memory and I am getting tripped up on the parsing. the document serializes the regular serialization routines with validation not disaabled as well as passes the validation in Altova XMLspy, but I get the following error when I try to load it: system> ./XMLtest inpTest.xml inpTest.out terminate called after throwing an instance of 'xsd::cxx::tree::parsing' what(): instance document parsing failed Aborted the main routine is: if (argc < 2) { std::cerr << "usage: " << argv[0] << "< txt or XML inp file> < XML/txt out file>"; exit(1); } // perform Global Initialization; TEST::initializeElements(); // load input file std::string inpFile(argv[1]); std::string outFile(argv[2]); if (inpFile.compare(inpFile.size()-4,4,".xml",4)==0) { // read XML file xml_schema::properties props; props.schema_location("http://schema.domain.com/TEST/input","TEST-input.xsd"); std::auto_ptr tif (TEST::input::TEST_input(argv[1],0,props)); } else { //read Txt-- output XML TxtInputFile *inp = new TxtInputFile(argv[1]); //inp->printAllBlocks(); TxtModel model(*inp); TEST::input::TestInput ti(model.createTestInputModel()); try { xml_schema::namespace_infomap map; map[""].name= "http://schema.domain.com/TEST/input"; map[""].schema= "TEST-input.xsd"; std::ofstream fout(argv[2]); TEST::input::TEST_input(fout , si, map); } catch (const xml_schema::exception& e) { std::cerr << e << std::endl; } } so if you run it with a txt file it generates a corresponding XML file, or with an XML file it should eventually produce the matching txt file. I have tried this on windows and linux, with versions 2.3, 3.0, and 3.1 all produce the same error... is there an error in the parsing design? -Russ Johns From boris at codesynthesis.com Tue Mar 11 02:43:16 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Roundtrip errors with CXX-Tree In-Reply-To: <1175.128.165.253.74.1205217391.squirrel@webmail.lanl.gov> References: <1175.128.165.253.74.1205217391.squirrel@webmail.lanl.gov> Message-ID: <20080311064316.GA10325@karelia> Hi Russell, Russell C. Johns writes: > terminate called after throwing an instance of > 'xsd::cxx::tree::parsing' > what(): instance document parsing failed Try to catch this exception and print it as you did with the serialization case: try { std::auto_ptr tif (TEST::input::TEST_input(argv[1],0,props)); } catch (const xml_schema::exception& e) { std::cerr << e << std::endl; } This way you will get more information about the error. > I have tried this on windows and linux, with versions 2.3, 3.0, and 3.1 > all produce the same error... > > is there an error in the parsing design? There might be, or it could be the way you construct the object model from the text format (note also that XMLSpy is famous for successfully parsing invalid XML documents and schemas). If printing the error does not shed any new light, we will need a compilable test case to debug. Boris From gkr at as-guides.com Tue Mar 11 07:20:23 2008 From: gkr at as-guides.com (Gordon Kramer) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 32, Issue 14 serialization without pretty print In-Reply-To: <200802161700.m1GH0MsQ001728@codesynthesis.com> References: <200802161700.m1GH0MsQ001728@codesynthesis.com> Message-ID: <1205234423.9078.18.camel@asdtvg-desktop-server> Hi, I am also interested in switching off pretty print dynamically. > > One tiny question/wish: streaming out xml with std::ofstream created > > an extra carriage return symbol after each element: > > > > > > Hello > > > > its me > > > > > > > > How to drop it? > > XSD uses DOMWriter provided by Xerces-C++ to serialize to XML. > It turns the format-pretty-print feature on by default which produces > the result you see (BTW, I believe it adds extra new lines only for > element that are directly under the root so real documents with several > nesting levels actually look better with these extra newlines than > without them). > > You only other option is to turn pretty-printing off altogether in which > case you will get unformatted XML. To do this you will need to set the > DOM-to-XML serialization stage yourself and switch the > format-pretty-print feature off on the DOMWriter object. For more > information see Q3.2 in the C++/Tree Mapping FAQ: > > http://wiki.codesynthesis.com/Tree/FAQ > > As well as the Xerces-C++ DOMWriter documentation: > > http://xerces.apache.org/xerces-c/program-dom.html#DOMWriterFeatures > > Boris > having had a look at the code it doesn't look too complicated by introducing another serialisation flag no_pretty_print. please find attached a patch for this proposal I did not add a test for this feature yet. Gordon -------------- next part -------------- A non-text attachment was scrubbed... Name: xsd_no_pretty_print.patch Type: text/x-patch Size: 2225 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20080311/2094cf3d/xsd_no_pretty_print.bin From johns at lanl.gov Tue Mar 11 10:59:43 2008 From: johns at lanl.gov (Russ Johns) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Roundtrip errors with CXX-Tree In-Reply-To: <20080311064316.GA10325@karelia> References: <1175.128.165.253.74.1205217391.squirrel@webmail.lanl.gov> <20080311064316.GA10325@karelia> Message-ID: <1205247583.23317.49.camel@desperado.lanl.gov> Thanks for the prompt reply- it seems that it did not find the schema, though on Windows I made sure it was there- when I switched to linux I added the schema::properties coding, but apparently forgot to copy the schema to the new development directory. Maybe there was a typo in the spelling of the schema filename on windows... I'll check. It works fine now... at least in Linux on xsd 3.1... On Tue, 2008-03-11 at 08:43 +0200, Boris Kolpackov wrote: > Hi Russell, > > Russell C. Johns writes: > > > terminate called after throwing an instance of > > 'xsd::cxx::tree::parsing' > > what(): instance document parsing failed > > Try to catch this exception and print it as you did with the > serialization case: > > try > { > std::auto_ptr tif > (TEST::input::TEST_input(argv[1],0,props)); > } > catch (const xml_schema::exception& e) > { > std::cerr << e << std::endl; > } > > This way you will get more information about the error. > > > > I have tried this on windows and linux, with versions 2.3, 3.0, and 3.1 > > all produce the same error... > > > > is there an error in the parsing design? > > There might be, or it could be the way you construct the object model > from the text format (note also that XMLSpy is famous for successfully > parsing invalid XML documents and schemas). If printing the error does > not shed any new light, we will need a compilable test case to debug. FYI- I was thinking my parsing design rather than yours. but I figured that XSD's/ Xerces serialization validation would be as strong as it's parsing validation. There are one or two holes in XSD/ Xerces validation, though they are not particularly problematic. On one test element that was restricted by ennumeration, it did not catch that I had added a new value to the ennumeration without updating the Schema. Other than that I have not observed any errors... -Russ > > Boris From Ryan.Prather at peterson.af.mil Tue Mar 11 12:17:50 2008 From: Ryan.Prather at peterson.af.mil (Prather, Ryan C SSgt USAF AFSPC SYAG/SED) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Suggestion Message-ID: <86AF6975D6C51A4BA20AB2C6E924450021B2EF@enpefrml50.frontrange.afspc.ds.af.mil> Boris, Just a suggestion about XSD. I would suggest some additional options to run. Mostly these would help with coders that have standards by which their offices require they code it. If you were to provide some of these options it would make their jobs much easier. --max-line-length - the maximum length of a line of code. --always-use-brackets - this would always put "{" and "}" for conditional and iterative code segments --add-blank-line - this would add a blank space before and after the "{" and "}" --indent-interval - this is the multiplier by which the coder wishes to indent nested statements Just a couple suggestions. I don't know if any other coders have any ideas that you might be interested in entertaining. Thanks. Ryan From petry at itwm.fhg.de Tue Mar 11 12:56:11 2008 From: petry at itwm.fhg.de (Alexander Petry) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] [Q] XSD in combination with Apache Xml Security Message-ID: <20080311165611.GE30720@bench.jakalx.net> Hello list! I am currently working on a project that is going to use XML in combination with the XML security specifications ([1] and [2]). The Apache Foundation implemented both specs (XML Digital Signature and XML Encryption) in the XML Security Library ([3]). Under Debian this library can be installed via apt-get install libxml-security-c{12,-dev}. The problem I am facing right now is how to combine the xsd-generated classes with this library. My document structure looks something like that: ... ... ... Building and parsing of simple "xbe:message" objects works, but I don't know how I am supposed to integrate the 'dsig:Signature' part correctly, the examples in [3] are not that obvious (at least to me). The steps I tried so far have been: 1. create the in-memory representation of a 'xbe:message' 2. serialize the message to a DOMDocument 3. find the 'xbe:header' element 4. create a Signature object (via library calls) and append it to the header element 5. sign the document 6. write the (signed) document to a file 7. read the file and validate the signature (fails!) Did somebody already implement something like that and is able to share the code? Is there a known procedure how to integrate other libraries that modify the DOM tree with xsd? I am grateful for any hints. Best regards, Alex References: [1] http://www.w3.org/TR/xmldsig-core/ [2] http://www.w3.org/TR/xmlenc-core/ [3] http://santuario.apache.org/index.html From beddoes at intient.com Tue Mar 11 17:16:21 2008 From: beddoes at intient.com (Bradley Beddoes) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] [Q] XSD in combination with Apache Xml Security In-Reply-To: <20080311165611.GE30720@bench.jakalx.net> References: <20080311165611.GE30720@bench.jakalx.net> Message-ID: <47D6F6A5.5090905@intient.com> Hi Alexander, Yes we have. Take a look at http://esoeproject.org in particular our saml2cpp library. This does exactly what your talking about (though obviously for the SAML specification but its still just ds:signature blocks). Hope that helps. regards, Bradley Alexander Petry wrote: > Hello list! > > I am currently working on a project that is going to use XML in > combination with the XML security specifications ([1] and [2]). The Apache > Foundation implemented both specs (XML Digital Signature and XML > Encryption) in the XML Security Library ([3]). Under Debian this library > can be installed via apt-get install libxml-security-c{12,-dev}. > > The problem I am facing right now is how to combine the xsd-generated > classes with this library. My document structure looks something like > that: > > > > ... > > ... > > > > > ... > > > > Building and parsing of simple "xbe:message" objects works, but I don't > know how I am supposed to integrate the 'dsig:Signature' part correctly, > the examples in [3] are not that obvious (at least to me). The steps I > tried so far have been: > > 1. create the in-memory representation of a 'xbe:message' > 2. serialize the message to a DOMDocument > 3. find the 'xbe:header' element > 4. create a Signature object (via library calls) and append it to the > header element > 5. sign the document > 6. write the (signed) document to a file > 7. read the file and validate the signature (fails!) > > Did somebody already implement something like that and is able to share > the code? Is there a known procedure how to integrate other libraries that > modify the DOM tree with xsd? I am grateful for any hints. > > Best regards, > Alex > > References: > [1] http://www.w3.org/TR/xmldsig-core/ > [2] http://www.w3.org/TR/xmlenc-core/ > [3] http://santuario.apache.org/index.html > From boris at codesynthesis.com Wed Mar 12 11:07:10 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Suggestion In-Reply-To: <86AF6975D6C51A4BA20AB2C6E924450021B2EF@enpefrml50.frontrange.afspc.ds.af.mil> References: <86AF6975D6C51A4BA20AB2C6E924450021B2EF@enpefrml50.frontrange.afspc.ds.af.mil> Message-ID: <20080312150710.GB14668@karelia> Hi Ryan, Prather, Ryan C SSgt USAF AFSPC SYAG/SED writes: > Mostly these would help with coders that have standards by which their > offices require they code it. If you were to provide some of these > options it would make their jobs much easier. > > --max-line-length - the maximum length of a line of > code. > --always-use-brackets - this would always put "{" and "}" for > conditional and iterative code segments > --add-blank-line - this would add a blank space before and after > the "{" and "}" > --indent-interval - this is the multiplier by which > the coder wishes to indent nested statements Thanks for the suggestions. While I understand your requirements the problem with handling it using command line options is that there are as many different coding standards as there are organizations. For example, you need blank lines before and after "{" and "}" while someone else would want "{" to start on the same line as functions signature, 'if', 'while', etc. While yet someone else would want it to start on the same line except for functions. If we start supporting each such requirement as a separate command line option, we will quickly get hundreds of them. There is an alternative approach which, while require a bit more effort from your side, is also much more flexible: In XSD we don't indent generated code manually with spaces, etc. Instead, the code generators output roughly unformatted code which then goes through an indenter whose job is to add newlines after ';', '{', '}', etc., as well as indent the code. The indenter basically does a hight-level C++ parsing to recognize which construct is being parsed and how to format it. The alternative solution to your problem would then be for you to modify this C++ indenter in order to produce the code formatted in accordance with your standards. The C++ indenter code is in the libbackend-elements/backend-elements/indentation/cxx.* files. You can use it as a base to create your own. The indenters are set up in xsd/cxx/tree/generator.cxx for C++/Tree and xsd/cxx/parser/generator.cxx for C++/Parser. The only inconvenience of this approach is that you will need to modify and build the XSD compiler yourself. Boris From boris at codesynthesis.com Wed Mar 12 11:25:26 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] [Q] XSD in combination with Apache Xml Security In-Reply-To: <20080311165611.GE30720@bench.jakalx.net> References: <20080311165611.GE30720@bench.jakalx.net> Message-ID: <20080312152526.GC14668@karelia> Hi Alexander, Alexander Petry writes: > Is there a known procedure how to integrate other libraries that > modify the DOM tree with xsd? As Bradly mentioned in his reply, he did exactly what you are trying to achieve and I suggest that you check his project. On a more general note, XSD-generated code for the C++/Tree mapping extracts/saves the data from/to Xerces-C++ DOM. While some parsing (serialization) functions encapsulate both the XML-to-DOM (DOM-to-XML) and DOM-to-object model (object model-to-DOM) stages, you can also perform the XML-to-DOM (DOM-to-XML) stage yourself and pass DOM to parsing and serialization functions. This allows you to perform additional intermediate DOM processing (e.g., verify a digital signature, remove encapsulating markup, etc.) that your application might require. For more information, see chapters 3, "Parsing" and 4, "Serialization": http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/ The C++/Tree Mapping FAQ: http://wiki.codesynthesis.com/Tree/FAQ As well as the 'multiroot' example in the XSD distribution. Boris From boris at codesynthesis.com Wed Mar 12 11:28:38 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] serialization without pretty print In-Reply-To: <1205234423.9078.18.camel@asdtvg-desktop-server> References: <200802161700.m1GH0MsQ001728@codesynthesis.com> <1205234423.9078.18.camel@asdtvg-desktop-server> Message-ID: <20080312152838.GD14668@karelia> Hi Gordon, Gordon Kramer writes: > having had a look at the code it doesn't look too complicated by > introducing another serialisation flag no_pretty_print. > please find attached a patch for this proposal The patch looks good, thanks. I will apply it for the next release of XSD. Boris From boris at codesynthesis.com Fri Mar 14 06:38:23 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] Xerces-C++ 3.0.0 beta 1 released Message-ID: <20080314103823.GD10450@karelia> Hi, The first beta for the upcoming Xerces-C++ 3.0.0 release is available for download: http://people.apache.org/builds/xerces/c/ If you are planning to upgrade to 3.0.0 once the final version is out, I suggest that you give this beta a try and report any problems so that they can be fixed before the final release. Here are some of the reasons why you may want to upgrade: - Better build system (autotools) for UNIX/Linux platforms - Project files for VC 9 - Support for the ICU transcoder in VC 7.1, 8, and 9 project files - libcurl-based net accessor - Support for XInclude - Support for a subset of XPath - Conformance to the final DOM Level 3 interface specification - Ability to provide custom DOM memory manager - Better 64-bit support - Cleaned up error messages - Better tested, including against W3C XML Schema test suite - Removal of the deprecated code For more details on this beta see the official announcement: http://marc.info/?l=xerces-c-users&m=120541881312475&w=2 XSD 3.1.0 has all the necessary support for Xerces-C++ 3.0.0 and was tested with this beta. Boris From sbalasub at qualcomm.com Thu Mar 20 20:32:25 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] #define problem. Message-ID: Hi, I am generating the code for ABC.xsd which translates to macros like, #ifndef ABC_H #define ABC_H #endif The target namespace actually is types:ABC. How do you make XSD to generate like, #ifndef types_ABC_H #define types_ABC_H #endif The problem is I have ABC.h elsewhere that is conflicting with this. Thanks, Shiva From sbalasub at qualcomm.com Thu Mar 20 20:40:57 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] #define problem. In-Reply-To: References: Message-ID: I am using 3.0 version -----Original Message----- From: xsd-users-bounces@codesynthesis.com [mailto:xsd-users-bounces@codesynthesis.com] On Behalf Of Balasubramanyam, Shivakumar Sent: Thursday, March 20, 2008 5:32 PM To: xsd-users@codesynthesis.com Subject: [xsd-users] #define problem. Hi, I am generating the code for ABC.xsd which translates to macros like, #ifndef ABC_H #define ABC_H #endif The target namespace actually is types:ABC. How do you make XSD to generate like, #ifndef types_ABC_H #define types_ABC_H #endif The problem is I have ABC.h elsewhere that is conflicting with this. Thanks, Shiva From sbalasub at qualcomm.com Thu Mar 20 20:48:38 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] #define problem. In-Reply-To: References: Message-ID: Hi, I found out that xsd 3.1 has a --guard-prefix option. Is there a word around for 3.0 ? Thanks, Shiva -----Original Message----- From: Balasubramanyam, Shivakumar Sent: Thursday, March 20, 2008 5:41 PM To: Balasubramanyam, Shivakumar; xsd-users@codesynthesis.com Subject: RE: [xsd-users] #define problem. I am using 3.0 version -----Original Message----- From: xsd-users-bounces@codesynthesis.com [mailto:xsd-users-bounces@codesynthesis.com] On Behalf Of Balasubramanyam, Shivakumar Sent: Thursday, March 20, 2008 5:32 PM To: xsd-users@codesynthesis.com Subject: [xsd-users] #define problem. Hi, I am generating the code for ABC.xsd which translates to macros like, #ifndef ABC_H #define ABC_H #endif The target namespace actually is types:ABC. How do you make XSD to generate like, #ifndef types_ABC_H #define types_ABC_H #endif The problem is I have ABC.h elsewhere that is conflicting with this. Thanks, Shiva From boris at codesynthesis.com Fri Mar 21 02:30:09 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] #define problem. In-Reply-To: References: Message-ID: <20080321063009.GA17391@karelia> Hi Shiva, Balasubramanyam, Shivakumar writes: > Is there a word around for 3.0 ? I see a few options: 1. Rename the schema file (e.g, types_ABC.xsd). 2. Write a small script to post-process the include guards in the generated ABC.hxx 3. In 3.0.0 and earlier versions the guard name is derived from the header name. So one option would be to rename the generated header file with the --hxx-regex option to generate, say, types_ABC.hxx instead of ABC.hxx: --hxx-regex '/^ABC.xsd$/types_ABC.hxx/' You can also create the ABC.hxx header which simply includes the generated one so that your code doesn't not need to know about this work around: #include "types_ABC.hxx" Boris From sbalasub at qualcomm.com Fri Mar 21 15:11:48 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] serialization output format (namespace related) Message-ID: Hi, I have elements in a namespace, lets say CS understands this format and parses the code correctly. Now when I serialize this out, I need to provide a mapping like. Xml_schema::namespace_infomap ns_map; Ns_map["NS"] = "http://www.someurl.com/NS"; The xml output looks like this, Though this is perfectly valid, is it possible to serialize in the first format as well? It is just more readable. Thanks, Shiva From boris at codesynthesis.com Sat Mar 22 07:35:35 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:01 2009 Subject: [xsd-users] serialization output format (namespace related) In-Reply-To: References: Message-ID: <20080322113535.GA32255@karelia> Hi Shiva, Balasubramanyam, Shivakumar writes: > Though this is perfectly valid, is it possible to serialize in the > first format as well? Yes, sure. Just use the empty string as namespace prefix: Ns_map[""] = "http://www.someurl.com/NS"; Boris From gpmnlxdw at gmail.com Tue Mar 25 02:25:35 2008 From: gpmnlxdw at gmail.com (=?GB2312?B?uN/Fyg==?=) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] RE: I can't compile smil schema Message-ID: <104cb51a0803242325w2badae5cv7ce522f4462c874b@mail.gmail.com> Hi everybody! I'm wondering if that my another email box is blocked,so I send this email again. And I hope this will not bother you. Sorry && Thanks. ========================================================================== and --anonymous-regex '/.* transitionFilterPrototype/calcMode2/' will get the same result ======================================= Hi! I read the emails before and found this link: http://wiki.codesynthesis.com/Schemas/SMIL Then I compile the schemas that I download from this link with xsd,but it still doesn't work.what can I do? Thanks! [clgao@paradise smil-2.0-schemas-split]$ xsd --version CodeSynthesis XSD XML Schema to C++ compiler 3.1.0 Copyright (C) 2005-2008 Code Synthesis Tools CC This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [clgao@paradise smil-2.0-schemas-split]$ xsd cxx-tree --namespace-regex '/.*22-rdf-syntax-ns#/smil::rdf/' --generate-polymorphic --anonymous-regex '/.*transitionFilterPrototype/calcMode2/' *.xsd smil20-transitions-base.xsd:95:69: error: attribute name 'transitionFilterPrototype/calcMode' creates an unstable conflict when used as a type name smil20-animate-base.xsd:84:25: info: conflicting type is defined here smil20-transitions-base.xsd:95:69: info: use --anonymous-regex to resolve this conflict smil20-transitions-base.xsd:95:69: info: and don't forget to pass the same option when translating 'smil20-transitions-base.xsd' and all the schemas that refer to it [clgao@paradise smil-2.0-schemas-split]$ From boris at codesynthesis.com Tue Mar 25 02:43:14 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] RE: I can't compile smil schema In-Reply-To: <104cb51a0803242325w2badae5cv7ce522f4462c874b@mail.gmail.com> References: <104cb51a0803242325w2badae5cv7ce522f4462c874b@mail.gmail.com> Message-ID: <20080325064314.GA21846@karelia> Hi, gpmnlxdw@gmail.com writes: > Then I compile the schemas that I download from this link with xsd,but it > still doesn't work.what can I do? > > Thanks! > > [clgao@paradise smil-2.0-schemas-split]$ xsd cxx-tree --namespace-regex > '/.*22-rdf-syntax-ns#/smil::rdf/' --generate-polymorphic --anonymous-regex > '/.*transitionFilterPrototype/calcMode2/' *.xsd The anonymous type regex that is given on the Wiki page appears to be invalid. Here is the correct one that should work: --anonymous-regex "%.* transitionFilterPrototype/calcMode%calcMode2%" Thanks for reporting this! Boris From timothy.k.lenz at lmco.com Tue Mar 25 11:45:57 2008 From: timothy.k.lenz at lmco.com (Lenz, Timothy K) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] "Unable to open in read mode" using --namespace-regex Message-ID: <12B3A4921563764788269D1B5ED153C01699D929@emss04m04.us.lmco.com> Hello! I've only recently started using Code Synthesis XSD for a medium-scale application. We are in the process of trying multiple XML/C++ binding tools to find one that best fits our needs. In that light, I am pretty new to most of this stuff (XML namespaces and schemas, Perl regular expressions, etc), so be gentle. This could be an entirely simple issue, but I can't find out how to fix it. Basically, I have multiple XML schemas from a 3rd party which include multiple namespaces in the format "Foo:bar" (note the single colon). These don't translate to valid C++ namespaces, so I need to replace all of those single colons with double colons. However, every time I try, I get the error "Unable to open in read mode". I have tried various permutations of the following command: /usr/bin/xsd cxx-tree --namespace-regex "%(\w):{1}(\w)%\$1::\$2%" myfile.xsd I have used double quotes, single quotes, and no quotes. I have used %, /, and ^ as delimiters. I have even tried putting the regular expression in its own file and using the filename as the argument to the namespace-regex parameter. Then I get something along the lines of invalid file structure. I got the same "read mode" error when using the simplistic replacement: /usr/bin/xsd cxx-tree --namespace-regex "%foo%bar%" myfile.xsd I am able to continue using the --namespace-map, but considering there are numerous different cases following the same structure (e.g. "Foo:bar", "Foo:man", "Foo:choo"), doing so is not remotely desirable. How do I use this? The "man" pages were pretty useless on this point (no actual example using namespace-regex). I found a hit on these threads that gave an example of usage, but I'm using it right (based on those examples) and still no joy. Anything anyone could provide would be much appreciated. Thanks! Tim Lenz From boris at codesynthesis.com Tue Mar 25 17:06:17 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] "Unable to open in read mode" using --namespace-regex In-Reply-To: <12B3A4921563764788269D1B5ED153C01699D929@emss04m04.us.lmco.com> References: <12B3A4921563764788269D1B5ED153C01699D929@emss04m04.us.lmco.com> Message-ID: <20080325210617.GA13244@karelia> Hi Timothy, Lenz, Timothy K writes: > I've only recently started using Code Synthesis XSD for a medium-scale > application. We are in the process of trying multiple XML/C++ binding > tools to find one that best fits our needs. In that light, I am pretty > new to most of this stuff (XML namespaces and schemas, Perl regular > expressions, etc), so be gentle. This could be an entirely simple > issue, but I can't find out how to fix it. No problem, welcome aboard! > These don't translate to valid C++ namespaces, so I need to replace all > of those single colons with double colons. However, every time I try, I > get the error "Unable to open in read mode". This error would normally mean that the input schema file does not exist. One cause of this might be that you don't put a regular expression with spaces in "" or '' but it seems that all your expressions are in "". > I have tried various permutations of the following command: > > /usr/bin/xsd cxx-tree --namespace-regex "%(\w):{1}(\w)%\$1::\$2%" myfile.xsd There are a couple of problems with this expression: 1. The format string is in the form " " where filename is the name of the schema file being processed. It is empty for the file name being translated (myfile.xsd in your case). This is all described in the man pages. Also, the --namespace-regex-trace option is often useful when trying to figure why your expression are not working. 2. The part that is matching words should allow for multiple characters, not just one. In the end I successfully used the following expression on a schema that has "foo:bar" as target namespace: --namespace-regex "/.* (\w+):(\w+)/\$1::\$2/" Also, you may want to use '' instead of "" to quote regular expressions on Linux/UNIX since then you don't need to escape $: --namespace-regex '/.* (\w+):(\w+)/$1::$2/' > How do I use this? The "man" pages were pretty useless on this point > (no actual example using namespace-regex). Hm, that's strange. Here is the documentation for the --namespace-regex option from the man pages: --namespace-regex regex Add regex to the list of regular expressions used to translate XML Schema namespace names to C++ namespace names. regex is a perl-like regular expression in the form /pattern/replacement/. Any character can be used as a delimiter instead of /. Escaping of the delimiter character in pattern or replacement is not supported. All regular expressions are pushed into a stack with the last specified expression considered first. The first match that succeeds is used. Regular expressions are applied to a string in the form filename namespace For example, XMLSchema.xsd http://www.w3.org/2001/XMLSchema The filename for the current translation unit is empty. For example, if you have file hello.xsd with namespace http://example.com/hello and you run xsd on this file, then the string in question would be: http://example.com/hello Note the leading space. The following three steps are performed for each regular expression until the match is found: 1. The expression is applied and if the result is empty the next expression is considered. 2. All / are replaced with ::. 3. The result is verified to be a valid C++ scope name (e.g., foo::bar). If this test succeeds, the result is used as a C++ namespace name. As an example, the following expression maps XML Schema namespaces in the form http://example.com/foo/bar to C++ namespaces in the form foo::bar: %.* http://example.com/(.+)%$1% Boris From gpmnlxdw at gmail.com Tue Mar 25 21:07:38 2008 From: gpmnlxdw at gmail.com (=?GB2312?B?uN/Fyg==?=) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] RE: I can't compile smil schema In-Reply-To: <20080325064314.GA21846@karelia> References: <104cb51a0803242325w2badae5cv7ce522f4462c874b@mail.gmail.com> <20080325064314.GA21846@karelia> Message-ID: <104cb51a0803251807r2464663amd583e34caca7ecff@mail.gmail.com> Yeah,Thanks! 2008/3/25, Boris Kolpackov : > > Hi, > > > gpmnlxdw@gmail.com writes: > > > Then I compile the schemas that I download from this link with xsd,but > it > > still doesn't work.what can I do? > > > > Thanks! > > > > > [clgao@paradise smil-2.0-schemas-split]$ xsd cxx-tree --namespace-regex > > '/.*22-rdf-syntax-ns#/smil::rdf/' --generate-polymorphic > --anonymous-regex > > '/.*transitionFilterPrototype/calcMode2/' *.xsd > > > The anonymous type regex that is given on the Wiki page appears to be > invalid. Here is the correct one that should work: > > --anonymous-regex "%.* transitionFilterPrototype/calcMode%calcMode2%" > > Thanks for reporting this! > > > Boris > From uri at hyperroll.com Wed Mar 26 02:50:20 2008 From: uri at hyperroll.com (Uri Karagila) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] getting the xs:schema version value Message-ID: <783879783B65E44995520FEF376C453847DACE@ilexch1.int.hyperroll.com> Hi, The versioning approach implemented in our xsd files, is managing the (internal) schema version attribute (e.g., . The issue is that the "version" attribute is not being "reflected" in the generated code, and therefore can not be retrieved. What can be done? Regards Uri From boris at codesynthesis.com Wed Mar 26 04:50:57 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] getting the xs:schema version value In-Reply-To: <783879783B65E44995520FEF376C453847DACE@ilexch1.int.hyperroll.com> References: <783879783B65E44995520FEF376C453847DACE@ilexch1.int.hyperroll.com> Message-ID: <20080326085057.GC14352@karelia> Hi Uri, Uri Karagila writes: > . > > The issue is that the "version" attribute is not being "reflected" in > the generated code, and therefore can not be retrieved. What can be > done? You can include this version information into the generated header file using the prologue/epilogue mechanism (see the --hxx-prologue-* options). For example as a constant: const unsigned int schema_version = 11; You can extract the version information manually (in which case you will need to update your build scripts/makefiles every time the version changes) or you can create a small program or script that parses your schema as XML and automatically extracts the version information. This program/script can generate the above version constant into a file which can then be included into the generated header with the --hxx-prologue-file option. Boris From timothy.k.lenz at lmco.com Wed Mar 26 09:09:40 2008 From: timothy.k.lenz at lmco.com (Lenz, Timothy K) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] "Unable to open in read mode" using --namespace-regex In-Reply-To: <20080325210617.GA13244@karelia> References: <12B3A4921563764788269D1B5ED153C01699D929@emss04m04.us.lmco.com> <20080325210617.GA13244@karelia> Message-ID: <12B3A4921563764788269D1B5ED153C016A0264A@emss04m04.us.lmco.com> Boris: Thanks for the reply! First, I see your point with the ".* " at the beginning of the query. I had read that in the man pages and eventually tried it yesterday afternoon, but it didn't change the outcome of my attempt. I neglected to put that in my original email... I tried the regular expression you provided (which is actually very close to some of the later variations I had tried) and still got the same problem. Here is the error message I get when running --namespace-regex-trace: %.* (\w+):(\w+)%$1::$2%: error: '%.* (\w+):(\w+)%$1::$2%': error: unable to open in read mode The error makes no mention of the xsd file. I've verified the file I am passing in exists and is readable. My initial attempts were using wildcards in another directory (e.g. /foo/bar/*.xsd) as the target, but I even copied one of the files to the current directory and ran it on that exclusively. Same error every time. PS: I definitely read the section about this namespace-regex stuff in the man pages. What I meant in my previous post was there was no full example of a command line using this functionality (I wanted to make sure I had everything in the right place, syntactically correct, etc). There was only an example regular expression, not an example command. Tim Lenz -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, March 25, 2008 5:06 PM To: Lenz, Timothy K Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] "Unable to open in read mode" using --namespace-regex Hi Timothy, Lenz, Timothy K writes: > I've only recently started using Code Synthesis XSD for a medium-scale > application. We are in the process of trying multiple XML/C++ binding > tools to find one that best fits our needs. In that light, I am pretty > new to most of this stuff (XML namespaces and schemas, Perl regular > expressions, etc), so be gentle. This could be an entirely simple > issue, but I can't find out how to fix it. No problem, welcome aboard! > These don't translate to valid C++ namespaces, so I need to replace all > of those single colons with double colons. However, every time I try, I > get the error "Unable to open in read mode". This error would normally mean that the input schema file does not exist. One cause of this might be that you don't put a regular expression with spaces in "" or '' but it seems that all your expressions are in "". > I have tried various permutations of the following command: > > /usr/bin/xsd cxx-tree --namespace-regex "%(\w):{1}(\w)%\$1::\$2%" myfile.xsd There are a couple of problems with this expression: 1. The format string is in the form " " where filename is the name of the schema file being processed. It is empty for the file name being translated (myfile.xsd in your case). This is all described in the man pages. Also, the --namespace-regex-trace option is often useful when trying to figure why your expression are not working. 2. The part that is matching words should allow for multiple characters, not just one. In the end I successfully used the following expression on a schema that has "foo:bar" as target namespace: --namespace-regex "/.* (\w+):(\w+)/\$1::\$2/" Also, you may want to use '' instead of "" to quote regular expressions on Linux/UNIX since then you don't need to escape $: --namespace-regex '/.* (\w+):(\w+)/$1::$2/' > How do I use this? The "man" pages were pretty useless on this point > (no actual example using namespace-regex). Hm, that's strange. Here is the documentation for the --namespace-regex option from the man pages: --namespace-regex regex Add regex to the list of regular expressions used to translate XML Schema namespace names to C++ namespace names. regex is a perl-like regular expression in the form /pattern/replacement/. Any character can be used as a delimiter instead of /. Escaping of the delimiter character in pattern or replacement is not supported. All regular expressions are pushed into a stack with the last specified expression considered first. The first match that succeeds is used. Regular expressions are applied to a string in the form filename namespace For example, XMLSchema.xsd http://www.w3.org/2001/XMLSchema The filename for the current translation unit is empty. For example, if you have file hello.xsd with namespace http://example.com/hello and you run xsd on this file, then the string in question would be: http://example.com/hello Note the leading space. The following three steps are performed for each regular expression until the match is found: 1. The expression is applied and if the result is empty the next expression is considered. 2. All / are replaced with ::. 3. The result is verified to be a valid C++ scope name (e.g., foo::bar). If this test succeeds, the result is used as a C++ namespace name. As an example, the following expression maps XML Schema namespaces in the form http://example.com/foo/bar to C++ namespaces in the form foo::bar: %.* http://example.com/(.+)%$1% Boris From boris at codesynthesis.com Wed Mar 26 09:10:04 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] "Unable to open in read mode" using --namespace-regex In-Reply-To: <12B3A4921563764788269D1B5ED153C016A0264A@emss04m04.us.lmco.com> References: <12B3A4921563764788269D1B5ED153C01699D929@emss04m04.us.lmco.com> <20080325210617.GA13244@karelia> <12B3A4921563764788269D1B5ED153C016A0264A@emss04m04.us.lmco.com> Message-ID: <20080326131004.GA22152@karelia> Hi Timothy, Lenz, Timothy K writes: > Here is the error message I get when running --namespace-regex-trace: > > %.* (\w+):(\w+)%$1::$2%: error: '%.* (\w+):(\w+)%$1::$2%': error: unable > to open in read mode Can you post the exact command line that you are using? The option to which you pass regex should be --namespace-regex, not --namespace-regex-trace. --namespace-regex-trace is just a flag that turns on namespace regex tracing. In other words, your command line should look something like this: $ xsd cxx-tree --namespace-regex '%.* (\w+):(\w+)%$1::$2%' file.xsd Or, if you also want regex tracing, like this: $ xsd cxx-tree --namespace-regex-trace --namespace-regex '%.* (\w+):(\w+)%$1::$2%' file.xsd Boris From timothy.k.lenz at lmco.com Wed Mar 26 09:55:04 2008 From: timothy.k.lenz at lmco.com (Lenz, Timothy K) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] "Unable to open in read mode" using --namespace-regex In-Reply-To: <20080326131004.GA22152@karelia> References: <12B3A4921563764788269D1B5ED153C01699D929@emss04m04.us.lmco.com> <20080325210617.GA13244@karelia> <12B3A4921563764788269D1B5ED153C016A0264A@emss04m04.us.lmco.com> <20080326131004.GA22152@karelia> Message-ID: <12B3A4921563764788269D1B5ED153C016A02774@emss04m04.us.lmco.com> Hey Boris: When I first started trying this, I was using --namespace-regex and it wasn't working (with my inadequate regular expressions), so I started using the -trace version until it was fixed. I've been using -trace ever since to see what the errors are, assuming I'd get no errors once it worked. I ran the command again using the regular version (no trace) with your suggested regular expression changes and it seems to work now. For some reason, every single time I run it with -trace, I get that "unable to open in read mode" error, even if it works without the -trace. Makes --namespace-regex-trace worthless to me. I'm having some other issues now, but I think they're more with the XSD files themselves and not the binder. Thanks for your help. Tim Lenz -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, March 26, 2008 9:10 AM To: Lenz, Timothy K Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] "Unable to open in read mode" using --namespace-regex Hi Timothy, Lenz, Timothy K writes: > Here is the error message I get when running --namespace-regex-trace: > > %.* (\w+):(\w+)%$1::$2%: error: '%.* (\w+):(\w+)%$1::$2%': error: unable > to open in read mode Can you post the exact command line that you are using? The option to which you pass regex should be --namespace-regex, not --namespace-regex-trace. --namespace-regex-trace is just a flag that turns on namespace regex tracing. In other words, your command line should look something like this: $ xsd cxx-tree --namespace-regex '%.* (\w+):(\w+)%$1::$2%' file.xsd Or, if you also want regex tracing, like this: $ xsd cxx-tree --namespace-regex-trace --namespace-regex '%.* (\w+):(\w+)%$1::$2%' file.xsd Boris From boris at codesynthesis.com Wed Mar 26 09:50:42 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] "Unable to open in read mode" using --namespace-regex In-Reply-To: <12B3A4921563764788269D1B5ED153C016A02774@emss04m04.us.lmco.com> References: <12B3A4921563764788269D1B5ED153C01699D929@emss04m04.us.lmco.com> <20080325210617.GA13244@karelia> <12B3A4921563764788269D1B5ED153C016A0264A@emss04m04.us.lmco.com> <20080326131004.GA22152@karelia> <12B3A4921563764788269D1B5ED153C016A02774@emss04m04.us.lmco.com> Message-ID: <20080326135042.GB22152@karelia> Hi Timothy, Lenz, Timothy K writes: > For some reason, every single time I run it with -trace, I get > that "unable to open in read mode" error, even if it works without > the -trace. Makes --namespace-regex-trace worthless to me. Let me try to clarify this a bit: --namespace-regex and --namespace-regex-trace are not the same. --namespace-regex has a value which is a regular expression that is used to translate XML namespaces to C++ namespaces. This options is used like so: --namespace-regex The --namespace-regex-trace option does not have a value. It is just a flag that specifies whether the process of applying regular expressions should be traced or not. If it is not specified, then there is no tracing. If it is specified, then the tracing is performed. You would normally use this option *together* with --namespace-regex, not instead of. Now since this option does not have a value, when you do something like this: $ xsd --namespace-regex-trace '/foo/bar/' file.xsd The compiler treats both /foo/bar/ and file.xsd as input files. This is why you get the unable to open error. Boris From timothy.k.lenz at lmco.com Wed Mar 26 10:16:11 2008 From: timothy.k.lenz at lmco.com (Lenz, Timothy K) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] "Unable to open in read mode" using --namespace-regex In-Reply-To: <20080326135042.GB22152@karelia> References: <12B3A4921563764788269D1B5ED153C01699D929@emss04m04.us.lmco.com> <20080325210617.GA13244@karelia> <12B3A4921563764788269D1B5ED153C016A0264A@emss04m04.us.lmco.com> <20080326131004.GA22152@karelia> <12B3A4921563764788269D1B5ED153C016A02774@emss04m04.us.lmco.com> <20080326135042.GB22152@karelia> Message-ID: <12B3A4921563764788269D1B5ED153C016A02810@emss04m04.us.lmco.com> Boris: With that, the light bulb is finally lit for me! I obviously thought the -trace was just a tracer version of the command. Didn't realize it was a flag. Thanks very much for your help. I seem to be chugging along now. Tim Lenz Lockheed Martin, Information Systems & Global Services Tactical Tomahawk Weapons Control System (610) 354-6911 timothy.k.lenz@lmco.com -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, March 26, 2008 9:51 AM To: Lenz, Timothy K Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] "Unable to open in read mode" using --namespace-regex Hi Timothy, Lenz, Timothy K writes: > For some reason, every single time I run it with -trace, I get > that "unable to open in read mode" error, even if it works without > the -trace. Makes --namespace-regex-trace worthless to me. Let me try to clarify this a bit: --namespace-regex and --namespace-regex-trace are not the same. --namespace-regex has a value which is a regular expression that is used to translate XML namespaces to C++ namespaces. This options is used like so: --namespace-regex The --namespace-regex-trace option does not have a value. It is just a flag that specifies whether the process of applying regular expressions should be traced or not. If it is not specified, then there is no tracing. If it is specified, then the tracing is performed. You would normally use this option *together* with --namespace-regex, not instead of. Now since this option does not have a value, when you do something like this: $ xsd --namespace-regex-trace '/foo/bar/' file.xsd The compiler treats both /foo/bar/ and file.xsd as input files. This is why you get the unable to open error. Boris From hajduk at imag.net Wed Mar 26 11:06:19 2008 From: hajduk at imag.net (Mario Madunic) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] utility to create image from XSD Message-ID: <1206543979.47ea666bbcf30@members.uniserve.com> Hi, I'm looking for a utility that I can run in ANT (it can be a jar, exe, or anything I can run from a command line) that will create an image from an XSD. It would need to resolve references to groups, datatypes, elements, and attributes. I like using Turbo XML but it is a manual process. Any info would be appreciated. Marijan (Mario) Madunic From boris at codesynthesis.com Wed Mar 26 14:16:28 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] utility to create image from XSD In-Reply-To: <1206543979.47ea666bbcf30@members.uniserve.com> References: <1206543979.47ea666bbcf30@members.uniserve.com> Message-ID: <20080326181628.GF22152@karelia> Hi Mario, Mario Madunic writes: > I'm looking for a utility that I can run in ANT (it can be a jar, exe, or > anything I can run from a command line) that will create an image from an > XSD. If by image you mean "graphic image" then you are asking on the wrong mailing list. This list is for discussions related to CodeSynthesis XSD, an XML Schema to C++ data binding compiler. Maybe the tools directory maintained by the XML Schema working group at W3C will have something that you might use: http://www.w3.org/XML/Schema#Tools Boris From hajduk at imag.net Thu Mar 27 09:49:17 2008 From: hajduk at imag.net (Mario Madunic) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] utility to create image from XSD In-Reply-To: <20080326181628.GF22152@karelia> References: <1206543979.47ea666bbcf30@members.uniserve.com> <20080326181628.GF22152@karelia> Message-ID: <1206625757.47eba5dd3230f@members.uniserve.com> Thanks for the info and sorry about the post. Mario Quoting Boris Kolpackov : > Hi Mario, > > Mario Madunic writes: > > > I'm looking for a utility that I can run in ANT (it can be a jar, exe, or > > anything I can run from a command line) that will create an image from an > > XSD. > > If by image you mean "graphic image" then you are asking on the > wrong mailing list. This list is for discussions related to > CodeSynthesis XSD, an XML Schema to C++ data binding compiler. > > Maybe the tools directory maintained by the XML Schema working > group at W3C will have something that you might use: > > http://www.w3.org/XML/Schema#Tools > > > Boris > From Nick.John at ActivIdentity.com Fri Mar 28 01:59:45 2008 From: Nick.John at ActivIdentity.com (Nick John) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Visual Studio rule file does not work with IncrediBuild Message-ID: Hi, The xsd-cxx-tree.rules file in etc\vc-8.0 does not work with IncrediBuild in Visual Studio 2005. This is because the rule file is relying on the [AllOptions] in the command line to be expanded with the OutDir property first. With IncrediBuild this is not the case. The solution is remove the -output-dir from the command line: xsd.exe cxx-tree [AllOptions] [AdditionalOptions] [Inputs] and add it into the switch for the OutDir property (--output-dir [value]) You then need to change the Outputs field to be: "[$OutDir]\$(InputName)[$HeaderSuffix];[$OutDir]\$(InputName)[$SourceSuf fix]" Note the '$' chars inside the square brackets ('[',']') means you get the actual value of the property rather than the switch value for the property. See the attached rule file. Cheers, Nick Nicholas John ActivIdentity 7 Phipps Close , Deakin , ACT Tel: +61 2 6208 4866 http://www.actividentity.com The information contained in this email message may be privileged, confidential and protected from disclosure. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this email message in error, please notify the sender by reply email and delete the message and any attachments. -------------- next part -------------- A non-text attachment was scrubbed... Name: xsd-cxx-tree.rules Type: application/octet-stream Size: 8822 bytes Desc: xsd-cxx-tree.rules Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20080328/367cb313/xsd-cxx-tree.obj From boris at codesynthesis.com Fri Mar 28 10:55:53 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Visual Studio rule file does not work with IncrediBuild In-Reply-To: References: Message-ID: <20080328145553.GB11220@karelia> Hi Nick, Nick John writes: > "[$OutDir]\$(InputName)[$HeaderSuffix];[$OutDir]\$(InputName)[$SourceSuf > fix]" > > Note the '$' chars inside the square brackets ('[',']') means you get > the actual value of the property rather than the switch value for the > property. Thanks, this is great stuff! I was looking for a way to get the actual value without the option but couldn't find it in Microsoft's documentation. So I had to resort to the --output-dir prefix hack. I've integrated your changes into the rules file for the next release. Thanks, Boris From henry.bruce at intel.com Fri Mar 28 20:10:44 2008 From: henry.bruce at intel.com (Bruce, Henry) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Tree Parsing: How to handle schema namespaces missing from XML data Message-ID: <85218E4FD03C7342B981E29C218D6176044146AA@orsmsx417.amr.corp.intel.com> I am trying to parse XML data from a web service. The data is described by a schema that uses namespaces, but they are not present in the web service response. As part of my testing, I used the .NET XSD tool to generate C# parsing code. I got round the lack of namespace qualifiers in the data by setting System.Xml.Serialization.XmlRootAttribute.Namespace to null in the generated code. The resulting code parsed the data just fine. Now I am seeking to do the equivalent with the tree mapping code generated by the CodeSynthesis. Anyone know how to do this? I apologize if this trick is the documentation and I've missed it. Thanks, Henry From lvkun2006 at gmail.com Sun Mar 30 07:07:59 2008 From: lvkun2006 at gmail.com (kun lv) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] a problem with CDATA part Message-ID: <32b74eaf0803300407l60408882rdb9878f04ce15ec9@mail.gmail.com> Hi! I have a problem with serializing. One string-type param of the class generated by XSD, have to be set as XML string. example: param = " ]]>" The output should like the string under: ]]> but the result i got is <! [CDATA[ <A></> ]]> How can I make the output what I want. Thanks a lot!!! From boris at codesynthesis.com Sun Mar 30 16:03:41 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Tree Parsing: How to handle schema namespaces missing from XML data In-Reply-To: <85218E4FD03C7342B981E29C218D6176044146AA@orsmsx417.amr.corp.intel.com> References: <85218E4FD03C7342B981E29C218D6176044146AA@orsmsx417.amr.corp.intel.com> Message-ID: <20080330200341.GA25538@karelia> Hi Henry, Bruce, Henry writes: > I am trying to parse XML data from a web service. The data is described > by a schema that uses namespaces, but they are not present in the web > service response. > > Now I am seeking to do the equivalent with the tree mapping code > generated by the CodeSynthesis. This is actually quite tricky unless you can change your schema to remove tragetNamespace so that XML that you get corresponds to the schema and, in turn, the generated code. If you cannot change your schema then there are a few ways to work around this but they depend on a few things: First, can you tell us whether, according to your schema, only the root element is namespace-qualified or if there are inner namespace- qualified elements and/or attributes. In other words, whether your XML document should look like this: ... or like this: ... This is normally determined by the elementFormDefault attribute in your schema (if it is not present then by default local elements are unqualified). Second, it would be helpful to know if you plan to have XML Schema validation in Xerces-C++ enabled during parsing (it is enabled by default). Some work-arounds may not be possible if validation is enabled. Boris From boris at codesynthesis.com Sun Mar 30 16:16:48 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] a problem with CDATA part In-Reply-To: <32b74eaf0803300407l60408882rdb9878f04ce15ec9@mail.gmail.com> References: <32b74eaf0803300407l60408882rdb9878f04ce15ec9@mail.gmail.com> Message-ID: <20080330201648.GB25538@karelia> Hi, kun lv writes: > The output should like the string under: > > > > ]]> > > > but the result i got is > > > <! [CDATA[ > <A></> > ]]> > There are two ways you can go about this: 1. You can serialize the object model to DOM, find the element in question, and convert the DOMText node that contains "" to the DOMCDATASection node. Then you can serialize DOM to XML. For more information on how to do this, see the C++/Tree Mapping User Manual (the "Serialization" chapter), C++/Tree Mapping FAQ, and Xerces-C++ DOM documentation. 2. If this is a specific element that should be serialized as CDATA, then you can defined a new type for this element in XML Schema (make it inherit from xsd:string). Then you can customize the generated C++ class and override its serialization operator. In the serialization operator you will create a DOMCDATASection with element's content. For more information on how to do this, see the C++/Tree Customization Guide, custom/wildcard example (shows how to customize the serialization operator) and Xerces-C++ DOM documentation. Boris From samlepirate at samlepirate.net Mon Mar 31 04:53:21 2008 From: samlepirate at samlepirate.net (Samuel Toulouse) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Remove Xerces Dependencies Message-ID: <4AC1DD0A-1773-4AFE-8EC7-38060278CC28@samlepirate.net> Hi everybody, I would like to know if there is a way to remove xml parsers dependencies from a header generated with xsd compiler. I would like to generate binary XDR representation of my xml with my build system and load them on my target device. So I wonder if it is possible to completely remove xerces-c because it is not currently ported on my target platform and i don't need to read/write xml. thanks, ++ samuel From boris at codesynthesis.com Mon Mar 31 04:54:08 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Remove Xerces Dependencies In-Reply-To: <4AC1DD0A-1773-4AFE-8EC7-38060278CC28@samlepirate.net> References: <4AC1DD0A-1773-4AFE-8EC7-38060278CC28@samlepirate.net> Message-ID: <20080331085408.GA26841@karelia> Hi Samuel, Samuel Toulouse writes: > I would like to generate binary XDR representation of my xml with my > build system and load them on my target device. So I wonder if it is > possible to completely remove xerces-c because it is not currently > ported on my target platform and i don't need to read/write xml. I am pretty sure it is possible if you don't mind modifying a few files in the runtime library (libxsd). Here is what you can do: 1. Compile your schemas with the --suppress-parsing option. This should result in the generated code that does not include any parsing constructors and therefore does not need Xerces-C++. 2. Then you will need to remove parts of the code that depend on Xerces-C++ from a few files in libxsd/xsd/cxx/tree/. I think just cleaning up elements.* and types.* should be enough. You can comment or remove all the parsing constructors (those that have DOMElement and DOMAttr arguments) since they won't be used. Boris From boris at codesynthesis.com Mon Mar 31 06:20:48 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Tree Parsing: How to handle schema namespaces missing from XML data In-Reply-To: <85218E4FD03C7342B981E29C218D617604414851@orsmsx417.amr.corp.intel.com> References: <85218E4FD03C7342B981E29C218D6176044146AA@orsmsx417.amr.corp.intel.com> <20080330200341.GA25538@karelia> <85218E4FD03C7342B981E29C218D617604414851@orsmsx417.amr.corp.intel.com> Message-ID: <20080331102048.GC26841@karelia> Hi Henry, I've CC'ed xsd-users to my reply in case someone else is interested in this. Bruce, Henry writes: > I guess I could change the schema, but am reluctant to so if there if a > chance of a workaround. I am OK with disabling schema validation if the > spirit of "just getting it to work". > > I have attached the schema as I'm not quite sure how to answer your > namespace-qualified question (I'm guessing the answer is yes). Although > I'm new to XML, even I can tell that schema seems to be badly coded. I've checked your schema and it appears that only the root element in the document should be qualified: both elementFormDefault and attributeFormDefault in your schema are set to 'unqualified' and all the inner element declarations are local (that is, there are no ref=""-style declarations). In other words, your document looks like this: ... BTW, compared to other schemas I have seen, your schema doesn't look too bad. There are two ways to handle the absence of the proper namespace qualification in the root element. First is quite clean but does not support validation in Xerces-C++. The second is a bit hairy but will work with validation enabled. The first approach involves parsing the XML document to DOM and then calling the root element's type constructor directly instead of using one of the parsing functions. We are essentially bypassing the element name and namespace check for the root element which is performed in the parsing functions. Let's say your document root element name is 'root' and its type is 'root_t'. Normally, you would parse it like this: std::istringstream istr (""); std::auto_ptr r (root (istr)); With this approach you would do it like this: xml_schema::dom::auto_ptr doc ( parse (istr, "", false)); xercesc::DOMElement* root (doc->getDocumentElement ()); std::auto_ptr r (new root (*root)); In this code fragment, the parse() function that is used to parse XML to DOM is taken from the 'multiroot' example. Note also that you will need to initialize and terminate the Xerces-C++ runtime as shown in the 'multiroot' example. You may also find some of the answers in the C++/Tree Mapping FAQ useful: http://wiki.codesynthesis.com/Tree/FAQ The 'multiroot' example will probably also be useful to you by itself since it shows how to handle several document types (in your case requests) without knowing which one it is. The second approach involves "fixing up" the document before it is parsed in order to make it valid per the schema. To do this, you will need to detect the beginning of the opening tag (e.g., "" with ""). This is quite easy to do if the XML document is saved in a string or buffer and harder if you get a chunk of the document at a time. A more advanced version of this method which avoids copying would be to create a special implementation of std::istream or xercesc::InputSource which will do this "fixing up" on the fly without modifying the original buffer. Boris From timothy.k.lenz at lmco.com Mon Mar 31 15:01:30 2008 From: timothy.k.lenz at lmco.com (Lenz, Timothy K) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Validation during serialization? Message-ID: <12B3A4921563764788269D1B5ED153C016B7BBC1@emss04m04.us.lmco.com> Good day to all! I am currently parsing and serializing XML files with the greatest of ease using XSD. My problem is, however, that I can't figure out how to validate what I serialize against the XML schema without reparsing what I just serialized. The parsing methods take a Properties class which provides the location of the XML schema, but the closest thing I can find for the serialization methods is the namespace_infomap which puts that info in the output, but does not seem to actually validate any of the data against the provided schema. Basically, I can do this: /* First, let's make a new XML file */ string outfile("out.xml"); ofstream f(outfile.c_str()); MyData md; /* populate md here with values that violate the schema */ xml_schema::NamespaceInfomap map; map[""].name = "MyNS"; map[""].schema = "MyNS.xsd"; try { serializeMyData(f, md, map); } catch(const xml_schema::Exception &e) { /* serialization works great, no exceptions thrown */ cerr << e << endl; return 1; } f.close(); /* Now let's read what we just wrote */ try { xml_schema::Properties props; props.schema_location("MyNS", MyNS.xsd"); /* Alternatively, could not populate props.schema_location and just use what's in the output xml file. The results are the same either way. */ auto_ptr inmd ( parseMyData(outfile.c_str(), 0, props)); } catch(const xml_schema::Exception &e) { /* Always catching exceptions in here for the data that violates the schema. This is data generated by the above serialization call. */ cerr << e << endl; return 1; } I've been looking through the command line options and the online manuals for serialization of the cxx-tree stuff, but have yet to find anything that helps me do this. Thanks in advance! Tim Lenz From boris at codesynthesis.com Mon Mar 31 16:24:45 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Validation during serialization? In-Reply-To: <12B3A4921563764788269D1B5ED153C016B7BBC1@emss04m04.us.lmco.com> References: <12B3A4921563764788269D1B5ED153C016B7BBC1@emss04m04.us.lmco.com> Message-ID: <20080331202445.GB3804@karelia> Hi Timothy, Lenz, Timothy K writes: > I am currently parsing and serializing XML files with the greatest of > ease using XSD. My problem is, however, that I can't figure out how to > validate what I serialize against the XML schema without reparsing what > I just serialized. The C++/Tree mapping does not support XML Schema validation during serialization (it uses underlying parser's XML Schema validation capabilities and Xerces-C++ does not support validation during serialization). We are, however, working on another XML Schema to C++ mapping which will provide XML Schema validation in the generated code for both parsing and serialization. Boris