From mark_erlich at hotmail.com Mon Jan 4 04:39:09 2010 From: mark_erlich at hotmail.com (Mark Erlich) Date: Mon Jan 4 04:39:17 2010 Subject: [xsd-users] How to get a schema location path from existing xml file Message-ID: Hi,I'm a new user of xsd and have been using it just for a few weeks.Application I'm writing should read a xml file and in certain conditionsit should create a new xml file, where the schema is same as inprevious file. My problem starts when I'm trying to serialize my newxml file: I can't get path for a schema out of the existing xml file!Is there any way to get this parameter when parsing a file? source for this section:---------------------------std::auto_ptr< ::Configuration > conf( configuration (DEFAULT_CONF_LOC, xml_schema::Flags::dont_initialize));Configuration::OcspSequence ocspSeq;Configuration::ParamSequence paramSeq;paramSeq.push_back(newParam);conf->ocsp(ocspSeq); //replace all ocsp data with empty ocsp sequenceconf->param(paramSeq); //replace all param data with new modified param sequence std::ofstream ofs;ofs.open(USER_CONF_LOC.c_str());xml_schema::NamespaceInfomap map;map[""].name = "";map[""].schema = getConfXsdPath().c_str(); //<--- Here is the problem. //I want to get schema path //from DEFAULT_CONF_LOC //file.configuration(ofs, *conf, map);ofs.close();--------------------------- With Best Regards,-Mark- _________________________________________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. 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_3:092010 From boris at codesynthesis.com Mon Jan 4 05:42:31 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 4 05:34:42 2010 Subject: [xsd-users] How to get a schema location path from existing xml file In-Reply-To: References: Message-ID: Hi Mark, Mark Erlich writes: > I can't get path for a schema out of the existing xml file! Is there any > way to get this parameter when parsing a file? This information is not copied to the object model so the only way to get it is from the DOM representation. For that you will need to do the XML-to-DOM parsing yourself. For an example on how to do it see the multiroot example in the examples/cxx/tree/ directory. Once you get the DOM document you can do something like this: #include // xml::transcode #include namespace xml = xsd::cxx::xml; DOMElement* root = ... const XMLCh* xsl = root->getAttributeNS ( xercesc::SchemaSymbols::fgURI_XSI, xercesc::SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCATION); std::string sl; if (xsl != 0) { sl = xml::transcode (xsl); } If you want to store this string as part of the object model, then you can customize the generated root element class to include this information. With this approach you can also avoid the DOM creation step and extract the schema directly location in the parsing constructor. For more information on how to do this see the wildcard example in the examples/cxx/tree/custom/ directory. Boris From mark at smartlink.ee Mon Jan 4 05:43:58 2010 From: mark at smartlink.ee (mark) Date: Mon Jan 4 05:53:17 2010 Subject: [xsd-users] How to get a schema location path from existing xml file In-Reply-To: References: Message-ID: <883ce10660cab04a9a42bdc4360396f8@smartlink.ee> On Mon, 4 Jan 2010 12:42:31 +0200, Boris Kolpackov wrote: > Hi Mark, > > Mark Erlich writes: > >> I can't get path for a schema out of the existing xml file! Is there any >> way to get this parameter when parsing a file? > > This information is not copied to the object model so the only way to > get it is from the DOM representation. For that you will need to do > the XML-to-DOM parsing yourself. For an example on how to do it see > the multiroot example in the examples/cxx/tree/ directory. Once you > get the DOM document you can do something like this: > > #include // xml::transcode > #include > > namespace xml = xsd::cxx::xml; > > DOMElement* root = ... > > const XMLCh* xsl = root->getAttributeNS ( > xercesc::SchemaSymbols::fgURI_XSI, > xercesc::SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCATION); > > std::string sl; > > if (xsl != 0) > { > sl = xml::transcode (xsl); > } > > If you want to store this string as part of the object model, then > you can customize the generated root element class to include this > information. With this approach you can also avoid the DOM creation > step and extract the schema directly location in the parsing > constructor. For more information on how to do this see the wildcard > example in the examples/cxx/tree/custom/ directory. > > Boris Thank You Boris! It helped me a lot. Regards, -Mark- From youngerking1985 at gmail.com Sun Jan 10 22:48:41 2010 From: youngerking1985 at gmail.com (=?UTF-8?B?546L54Sw6L6J?=) Date: Sun Jan 10 22:48:48 2010 Subject: [xsd-users] CityGML reader Message-ID: <648d03b21001101948u286e5b0bgb6f6c587b19bce32@mail.gmail.com> Hi, administrator I want to read CityGML file in VS2005. I have download Citygml-1.0.0.zip from http://wiki.codesynthesis.com/Schemas/CityGML, however, I don't know how to compile it in VS2005, Could you help me? I really appreciate for your help. Best wishes. Youngerking From boris at codesynthesis.com Mon Jan 11 06:27:36 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 11 06:18:22 2010 Subject: [xsd-users] CityGML reader In-Reply-To: <648d03b21001101948u286e5b0bgb6f6c587b19bce32@mail.gmail.com> References: <648d03b21001101948u286e5b0bgb6f6c587b19bce32@mail.gmail.com> Message-ID: Hi, writes: > I want to read CityGML file in VS2005. I have download Citygml-1.0.0.zip > from http://wiki.codesynthesis.com/Schemas/CityGML, however, I don't know > how to compile it in VS2005, Could you help me? I have updated this file to also include Microsoft batch file that can be used to compile the schemas. Here is the relevant part from the updated README file: To compile the schemas on Microsoft Windows you can use the provide generate.bat batch file. Edit this file first to set the correct XSD compiler path. Once the schemas are compiled, the generated code can be found in the gml\, citygml\, and xs\ directories. To build the test driver with VC++ you will need to create a VC++ console project and add the generated code as well as the driver.cxx and xml-schema-custom.cxx files to it. Boris From sutambe at dre.vanderbilt.edu Tue Jan 12 11:58:23 2010 From: sutambe at dre.vanderbilt.edu (Sumant Tambe) Date: Tue Jan 12 11:58:31 2010 Subject: [xsd-users] vocabulary-specific types for simple elements Message-ID: <4B4CAA2F.9020806@dre.vanderbilt.edu> Hi, I was wondering if there is a way in xsd (tool) to generate classes that wrap simple content such as As far as I know, the parent class of such an element gets a set of overloaded price() methods that essentially return C++ int. Instead, I was thinking of a class named "price". Based my limited knowledge of the implementation of the generator, I think if we force it to consider all elements as complex elements (using a command-line switch), we can get the desired effect. Am I wrong? Some extra name mangling might be necessary to resolve name collisions. Thanks, Sumant. From gleonid at yahoo.com Tue Jan 12 12:27:19 2010 From: gleonid at yahoo.com (Leonid Gershanovich) Date: Tue Jan 12 12:27:27 2010 Subject: [xsd-users] string literal definitions for element names Message-ID: <949047.77352.qm@web112403.mail.gq1.yahoo.com> Hi Boris, is there a way to instruct generator to produce set of string literal definitions for element/attribute names? let say that I have a very simple schema(sample.xsd): ------------------------ ? ??? ? ------------------------ Then I generate SAX wrappers with expat and driver code with following command: ./CodeSynthesis/3.2.0/bin/xsd? cxx-parser \ ????? --xml-parser expat??????????? \ ????? --skel-type-suffix _sax_interface??????? \ ????? --skel-file-suffix -sax_interface??????? \ ????? --impl-type-suffix "-sax_impl"??? \ ????? --impl-file-suffix "-sax_impl" --generate-print-impl --impl-file-suffix "-sax_impl" --generate-test-driver? \ ????? --hxx-suffix .h????????????????????????? \ ????? --ixx-suffix .ipp??????????????????????? \ ????? --cxx-suffix .cpp??????????????????????? \ ????? --proprietary-license??????????????????? \ ????? sample.xsd In sample-driver.cpp I am getting code like this: -------------------------- ??? ::xml_schema1::document doc_p ( ????? sample_el_p, ????? "http://schemas.247realmedia.com/sample", ????? "sample_el"); -------------------------- Ideally I do not want to have neither element name nor xml namspace?hardcoded in my program, but I could not find in generated code any?way to?do this otherwise. Idea is that if I decide to change schema and rename element/attribute/targetNamespace I I would want my code to stop compiling, but with hardcoded literals I would have to go thru my code and make sure that names in schema are in sync with whatever is hardcoded. Thanks Leonid Gershanovich From bpringle at sympatico.ca Tue Jan 12 14:58:52 2010 From: bpringle at sympatico.ca (Bill Pringlemeir) Date: Tue Jan 12 14:58:43 2010 Subject: [xsd-users] vocabulary-specific types for simple elements In-Reply-To: <4B4CAA2F.9020806@dre.vanderbilt.edu> (Sumant Tambe's message of "Tue, 12 Jan 2010 10:58:23 -0600") References: <4B4CAA2F.9020806@dre.vanderbilt.edu> Message-ID: <873a2b14eb.fsf@sympatico.ca> On 12 Jan 2010, sutambe@dre.vanderbilt.edu wrote: > Hi, > > I was wondering if there is a way in xsd (tool) to generate classes > that wrap simple content such as type="xs:int" /> > As far as I know, the parent class of such an element gets a set of > overloaded price() methods that essentially return C++ int. Instead, I > was thinking of a class named "price". > > Based my limited knowledge of the implementation of the generator, I > think if we force it to consider all elements as complex elements > (using a command-line switch), we can get the desired effect. Am I > wrong? Some extra name mangling might be necessary to resolve name > collisions. You can do this is various ways that I can think of. 1) You could insert a complex type that wraps a price. 2) You can use --type-regex and change the type of price. Use a wrapper class in all users of price to return the class. The first is the least effort, but impossible if you can not modify the schema for some reason. You could just 'patch' the schema before generation so that is true to the online variant. The second option is more work. You need to modify both the interface and all of the users to move from returning a simple type to a class. You can also customize a 'simple type'. The customization guide has information on how to do this for a date class. This is probably more like what you were thinking of. I have implemented this with a simpleType. A simple type is schema typedef. I think it is difficult if your schema has hard coded types as 'int'. In this case, I am pretty sure you have to wrap all generate user classes as well. I sure Boris might have a better answer. fwiw, Bill Pringlemeir. From sutambe at dre.vanderbilt.edu Tue Jan 12 15:55:31 2010 From: sutambe at dre.vanderbilt.edu (Sumant Tambe) Date: Tue Jan 12 15:55:39 2010 Subject: [xsd-users] vocabulary-specific types for simple elements In-Reply-To: <873a2b14eb.fsf@sympatico.ca> References: <4B4CAA2F.9020806@dre.vanderbilt.edu> <873a2b14eb.fsf@sympatico.ca> Message-ID: <4B4CE1C3.6050400@dre.vanderbilt.edu> Hi Bill, Thanks for your suggestions. > 1) You could insert a complex type that wraps a price. I tried something like below: which seems to work alright for simple elements as well as attributes. I'm not sure if using complexType would be easier. > You can also customize a 'simple type'. The customization guide has > information on how to do this for a date class. I'm not sure which customization guide you referring to. I found several pdf files in the xsd installation. Thanks, Sumant. From bpringle at sympatico.ca Tue Jan 12 17:34:40 2010 From: bpringle at sympatico.ca (Bill Pringlemeir) Date: Tue Jan 12 17:34:26 2010 Subject: [xsd-users] vocabulary-specific types for simple elements In-Reply-To: <4B4CE1C3.6050400@dre.vanderbilt.edu> (Sumant Tambe's message of "Tue, 12 Jan 2010 14:55:31 -0600") References: <4B4CAA2F.9020806@dre.vanderbilt.edu> <873a2b14eb.fsf@sympatico.ca> <4B4CE1C3.6050400@dre.vanderbilt.edu> Message-ID: <87y6k3ymtb.fsf@sympatico.ca> On 12 Jan 2010, sutambe@dre.vanderbilt.edu wrote: >> You can also customize a 'simple type'. The customization guide has >> information on how to do this for a date class. > I'm not sure which customization guide you referring to. I found > several pdf files in the xsd installation. Sorry, it is here, "http://wiki.codesynthesis.com/Tree/Customization_guide". Additional information is in the distribution in the custom example (superman or something) and there are details in the manuals as well. If you are happy with the simple type, then that is ok. However, if you want a 'price' class with a 'std::string prettyPrint()', etc. You would wrap this with your own class which would provide the implementation of 'prettyPrint()'. There are more extensive examples that can control the serialization, data storage, etc. hth, Bill Pringlemeir. -- Finish your beer -- there are sober people in China! From boris at codesynthesis.com Wed Jan 13 08:47:10 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 13 08:37:24 2010 Subject: [xsd-users] vocabulary-specific types for simple elements In-Reply-To: <4B4CAA2F.9020806@dre.vanderbilt.edu> References: <4B4CAA2F.9020806@dre.vanderbilt.edu> Message-ID: Hi Sumant, Sumant Tambe writes: > I was wondering if there is a way in xsd (tool) to generate classes that > wrap simple content such as > As far as I know, the parent class of such an element gets a set of > overloaded price() methods that essentially return C++ int. Instead, I > was thinking of a class named "price". No, there is no way to do this. It is also not clear what extra functionality such a class would have to justify the overhead. You can, however, re-map XML Schema built-in types that are by default mapped to fundamental C++ types to some user defined types (e.g., int to, say, your class Int). For more information on how to do this see the C++/Tree Mapping Customization Guide that Bill already referred you to as well as the examples in the examples/cxx/tree/custom/ directory in the XSD distribution. Boris From boris at codesynthesis.com Wed Jan 13 08:57:05 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 13 08:47:17 2010 Subject: [xsd-users] string literal definitions for element names In-Reply-To: <949047.77352.qm@web112403.mail.gq1.yahoo.com> References: <949047.77352.qm@web112403.mail.gq1.yahoo.com> Message-ID: Hi Leonid, Leonid Gershanovich writes: > is there a way to instruct generator to produce set of string literal > definitions for element/attribute names? > > ... > > ::xml_schema1::document doc_p ( > sample_el_p, > "http://schemas.247realmedia.com/sample", > "sample_el"); > > Ideally I do not want to have neither element name nor xml namspace > hardcoded in my program, but I could not find in generated code any > way to do this otherwise. There is no way to do this at the moment. We cannot add such literals to the parser skeleton corresponding to the element's type since this type can be used in more than one global element. So the only way that I see would be to generate a class for each global element with static functions that return the element's namespace and name. But that seems like a significant overhead for not much functionality (there could be hundreds of global elements while only some of them are actually valid document roots). How many root element do you have to handle in your case? Boris From boris at codesynthesis.com Wed Jan 13 09:37:49 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 13 09:28:05 2010 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 I finally got around to figuring out what's going on here. When you dll-export a class that derives from a template instantiation, VC++ automatically exports this template instantiation. So let's say we have a.cxx which compiles to a.dll and contains the following: class A_EXPORT A: public std::vector { ... }; In this case, a.dll will export both class A and std::vector. Now, let's say we have b.dll (or b.exe for that matter) which links to a.dll and has b.cxx with the following code: void f () { std::vector x; } Let's also assume that std::vector::~vector() is not inline. In this case, when we try to link b.dll, we will get duplicate symbols because ~vector() is exported from a.dll and is instantiated in b.cxx. This works the way it does because b.cxx doesn't know anything about a.cxx and, as a result, the VC++ compiler has no idea that the vector symbols should be imported instead of instantiated. If we had something like this instead: #include a.hxx // Declared class A above. void f () { std::vector x; } Then everything would work without any problems since the compiler would automatically recognize std::vector as imported. Here is an MSDN article that describes a similar situation: http://msdn.microsoft.com/en-us/library/ms174286.aspx Based on this understanding I was able to work around the problem in your case by adding the following code at the end of exportxml.h: #include namespace xsd { namespace cxx { namespace tree { template class __declspec(dllimport) sequence; } } } This basically tells VC++ to assume the symbols for sequence will be provided since geocosmxmllibbasecpp.dll contains an exported class that derives from sequence. I am still think whether something can be done in the generated code to resolve this automatically but it doesn't look promising since this involves translation units that don't know anything about each other. Boris From sutambe at dre.vanderbilt.edu Wed Jan 13 10:07:32 2010 From: sutambe at dre.vanderbilt.edu (Sumant Tambe) Date: Wed Jan 13 10:07:37 2010 Subject: [xsd-users] vocabulary-specific types for simple elements In-Reply-To: References: <4B4CAA2F.9020806@dre.vanderbilt.edu> Message-ID: <4B4DE1B4.8020804@dre.vanderbilt.edu> Hi Boris, >> I was wondering if there is a way in xsd (tool) to generate classes that >> wrap simple content such as >> As far as I know, the parent class of such an element gets a set of >> overloaded price() methods that essentially return C++ int. Instead, I >> was thinking of a class named "price". > > No, there is no way to do this. It is also not clear what extra > functionality such a class would have to justify the overhead. I see a couple of advantages of doing it. 1. The data structure representing information remains abstract behind the interface of the generated class. That allows easy changes in the schema without breaking (some part of) the client code. Say for instance, regular strings to an enumeration of strings. 2. The elements that logically belong to different parts of XML, can be distinguished at the type level. For instance, if book titles and author names, both are represented using strings, it is not clear when you see a string object whether its a title or name. Some extra type-safety can be achieved if they have their respective classes. Also, other than extra classes, do you see any other overhead of such an approach. Thanks, Sumant. From jstein at fiveringscapital.com Wed Jan 13 11:45:36 2010 From: jstein at fiveringscapital.com (Joel Stein) Date: Wed Jan 13 11:45:45 2010 Subject: [xsd-users] --generate-validation Message-ID: <57A505A533615F418F154E57E6FE7B4D682CFAA44F@EXVMBX018-3.exch018.msoutlookonline.net> Hi, I was wondering why the "--generate-validation" option was removed (I saw a post by Boris from early 2009 recommending its use) and if there is currently something similar. Thanks! Joel From boris at codesynthesis.com Thu Jan 14 09:31:34 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 14 09:21:32 2010 Subject: [xsd-users] --generate-validation In-Reply-To: <57A505A533615F418F154E57E6FE7B4D682CFAA44F@EXVMBX018-3.exch018.msoutlookonline.net> References: <57A505A533615F418F154E57E6FE7B4D682CFAA44F@EXVMBX018-3.exch018.msoutlookonline.net> Message-ID: Hi Joel, Joel Stein writes: > I was wondering why the "--generate-validation" option was removed > (I saw a post by Boris from early 2009 recommending its use) and if > there is currently something similar. This option is only valid for the C++/Parser mapping and instructs the XSD compiler to include XML Schema validation support for the specific XML vocabulary into the generated code. For the C++/Tree mapping XML Schema validation is performed by the underlying XML parser (Xerces-C++) and can be enabled/disabled at runtime (see the xml_schema::flags::dont_validate flag). Boris From boris at codesynthesis.com Thu Jan 14 09:46:55 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 14 09:36:54 2010 Subject: [xsd-users] vocabulary-specific types for simple elements In-Reply-To: <4B4DE1B4.8020804@dre.vanderbilt.edu> References: <4B4CAA2F.9020806@dre.vanderbilt.edu> <4B4DE1B4.8020804@dre.vanderbilt.edu> Message-ID: Hi Sumant, Sumant Tambe writes: > > No, there is no way to do this. It is also not clear what extra > > functionality such a class would have to justify the overhead. > > I see a couple of advantages of doing it. > > 1. The data structure representing information remains abstract behind > the interface of the generated class. That allows easy changes in the > schema without breaking (some part of) the client code. Say for > instance, regular strings to an enumeration of strings. There is a typedef alias generated for each element/attribute (e.g., foo::price_type). If used, this will give you the same benefit without any overhead. > 2. The elements that logically belong to different parts of XML, can be > distinguished at the type level. For instance, if book titles and author > names, both are represented using strings, it is not clear when you see > a string object whether its a title or name. Some extra type-safety can > be achieved if they have their respective classes. You can add syntactic clarity by using the type aliases mentioned above. As for the extra type-safety, it is the same as in the schema. In other words, if the author of the schema wanted to distinguish title from author, they could have created separate types for them by deriving from string. This would translate to separate types in C++. In fact I've seen quite a few schemas that do this. I just don't think it is our place to make this decision for the user and sacrifice one thing for another. > Also, other than extra classes, do you see any other overhead of such > an approach. Each additional class would lead to longer compilation times, code bloat (each will have to have a vtable, type information, etc.). There are schemas with thousands of types. If we were to generate a wrapper class for each element/attribute, we could easily reach 10K classes. Plus, there is always the "inconvenience overhead" where the user has to "unwrap" things (e.g., a wrapper for type int is never as convenient to use as int itself). Boris From mathieu.malaterre at gmail.com Thu Jan 14 10:51:46 2010 From: mathieu.malaterre at gmail.com (Mathieu Malaterre) Date: Thu Jan 14 10:52:23 2010 Subject: [xsd-users] xsd2dia or xsd2dot (graphviz) Message-ID: Hi there, I am looking for a tool to convert an XSD Schema to a dia type output or a graphviz output (dot format). Thanks ! -- Mathieu From jstein at fiveringscapital.com Thu Jan 14 15:03:24 2010 From: jstein at fiveringscapital.com (Joel Stein) Date: Thu Jan 14 15:03:33 2010 Subject: [xsd-users] Reusing schema components Message-ID: <57A505A533615F418F154E57E6FE7B4D682E90C102@EXVMBX018-3.exch018.msoutlookonline.net> Hi, I have a situation where I have 2 schemas that have overlapping components. Example: 1 2 3 2 3 4 I would love to take a bar and make a new foo and do foo.setB(bar.getB()) and foo.setC(bar.getC()). There seems to be 2 problems: 1) (a small problem) the types don't match up in C++, even though they do in the schemas. 2) In VC++9.0 (though it seems not in g++), I get a TON of linker errors (LNK2005 already defined) complaining about duplicate definitions of the shared components. I'm using xsd-tree to generate code for a whole bunch of xsds in the same namespace that have overlapping names in their elements. There must be a common solution to this. Thanks! Joel From boris at codesynthesis.com Fri Jan 15 08:36:01 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 15 08:25:50 2010 Subject: [xsd-users] Reusing schema components In-Reply-To: <57A505A533615F418F154E57E6FE7B4D682E90C102@EXVMBX018-3.exch018.msoutlookonline.net> References: <57A505A533615F418F154E57E6FE7B4D682E90C102@EXVMBX018-3.exch018.msoutlookonline.net> Message-ID: Hi Joel, Joel Stein writes: > > 1 > 2 > 3 > > > > 2 > 3 > 4 > > > I would love to take a bar and make a new foo and do foo.setB(bar.getB()) > and foo.setC(bar.getC()). There seems to be 2 problems: > > 1) (a small problem) the types don't match up in C++, even though they do > in the schemas. > > 2) In VC++9.0 (though it seems not in g++), I get a TON of linker errors > (LNK2005 already defined) complaining about duplicate definitions of > the shared components. The best way to solve both of these problems (and also avoid code bloat) is to factor out common types (i.e., types for "b" and "c" elements) into a separate schema which can then be included into the schemas describing "foo" and "bar". If that's not an option (for example, because you cannot modify the schemas), then you can resolve the second problem by generating the code for schemas foo and bar into different C++ namespaces, for example: xsd cxx-tree --namespace-map http://example.com/my-ns=Foo foo.xsd xsd cxx-tree --namespace-map http://example.com/my-ns=Bar bar.xsd Use --namespace-map =Foo if your schemas don't have namespaces. As for the first problem, in this case, you will need to "decompose" the source object until built-in types and construct the target object from these parts manually, for example (assuming CType is complex): const Bar::CType& c = bar.getC (); foo.setC (Foo::CType (c.getName (), c.getAge ())); Boris From boris at codesynthesis.com Fri Jan 15 08:38:46 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 15 08:28:30 2010 Subject: [xsd-users] xsd2dia or xsd2dot (graphviz) In-Reply-To: References: Message-ID: Hi Mathieu, Mathieu Malaterre writes: > I am looking for a tool to convert an XSD Schema to a dia type > output or a graphviz output (dot format). I am not aware of any such tools. You may want to try asking on the xmlschema-dev@w3.org mailing list since it has a wider audience: http://lists.w3.org/Archives/Public/xmlschema-dev/ Boris From sutambe at dre.vanderbilt.edu Mon Jan 18 13:35:25 2010 From: sutambe at dre.vanderbilt.edu (Sumant Tambe) Date: Mon Jan 18 13:35:32 2010 Subject: [xsd-users] vocabulary-specific types for simple elements In-Reply-To: References: <4B4CAA2F.9020806@dre.vanderbilt.edu> <4B4DE1B4.8020804@dre.vanderbilt.edu> Message-ID: <4B54A9ED.2070409@dre.vanderbilt.edu> Hi Boris, ... > There are schemas with thousands of types. If we were to generate a wrapper class > for each element/attribute, we could easily reach 10K classes. Do you have access to such really large schemas? Could you please point me to some? I was trying to lookup the supported schemas page but I'm not sure how to obtain the actual schemas. I think I can easily obtain the schema for OMG's deployment and configuration standard from the CIAO repository. Thanks, Sumant. From ramon at forcewise.com Mon Jan 18 18:26:32 2010 From: ramon at forcewise.com (Ramon F Herrera) Date: Tue Jan 19 03:14:10 2010 Subject: [xsd-users] xsd does not like my xsd schema file Message-ID: <20100118232632.GA5057@cowboy.forcewise.com> Hello, I am a recent convert to xsd. I was thrilled when I discovered it, but haven't been able to make much progress with my XML files. My XML files are very similar, and relatively large (repetitive is a more accurate term). The problem that I have is that xsd does not accept the xsd schema files that I have provided, or sometimes it accepts them but the generated source code does not compile. I used the "hello" example as an initial basis. It seems that the 'hello.xsd' file must be built following certain conventions (IOW, I cannot simply use an automatically generated xsd file), such as creating a complex type named 'hello_t'. Qustion: is there a sample xsd more complex/realistic than the 'hello.xsd' provided? Unfortunately, the company that produces thet XML file does not provide a corresponding XSD schema, so I had to generate one with Stylus Studio. This automatically generated file contains a lot of statements like this: and xsd does not seem to handle those 'future' references. Thanks for sharing your expertise... Regards, -Ramon From erik.sjolund at gmail.com Tue Jan 19 04:02:47 2010 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Tue Jan 19 04:02:52 2010 Subject: [xsd-users] xsd does not like my xsd schema file In-Reply-To: <20100118232632.GA5057@cowboy.forcewise.com> References: <20100118232632.GA5057@cowboy.forcewise.com> Message-ID: <4B557537.4060802@gmail.com> on 2010-01-19 00:26 Ramon F Herrera wrote: > The problem that I have is that xsd does not > accept the xsd schema files that I have provided, or sometimes it > accepts them but the generated source code does not compile. > A tip that might be of help if you want to hand write your schema: I find it easier to first write the schema as relaxng and then convert it to an xml schema. Some links: http://www.thaiopensource.com/relaxng/trang.html http://relaxng.org/tutorial-20011203.html http://en.wikipedia.org/wiki/RELAX_NG An example: $ cd /tmp $ cat /tmp/file.rng $ wget http://jing-trang.googlecode.com/files/trang-20081028.zip $ unzip trang-20081028.zip $ java -jar /tmp/trang-20081028/trang.jar file.rng file.xsd $ cat file.xsd You could validate an xml file to these scemata by these commands $ xmllint --relaxng file.rng file.xml $ xmllint --schema file.xsd file.xml cheers, Erik Sj?lund From boris at codesynthesis.com Tue Jan 19 07:41:51 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 19 07:30:47 2010 Subject: [xsd-users] vocabulary-specific types for simple elements In-Reply-To: <4B54A9ED.2070409@dre.vanderbilt.edu> References: <4B4CAA2F.9020806@dre.vanderbilt.edu> <4B4DE1B4.8020804@dre.vanderbilt.edu> <4B54A9ED.2070409@dre.vanderbilt.edu> Message-ID: Hi Sumant, Sumant Tambe writes: > Do you have access to such really large schemas? Could you please point > me to some? The really large ones we have in our repository are proprietary so I cannot share them. For an example of a fairly large, publicly-available one see the G2S Message Protocol[1] schemas: http://www.gamingstandards.com > I was trying to lookup the supported schemas page but I'm not sure > how to obtain the actual schemas. Each entry on that page has a link to the organization that develops the schema. You should be able to find the download page from there. Also see: http://wiki.codesynthesis.com/Schemas Boris From boris at codesynthesis.com Tue Jan 19 08:03:02 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 19 07:51:51 2010 Subject: [xsd-users] xsd does not like my xsd schema file In-Reply-To: <20100118232632.GA5057@cowboy.forcewise.com> References: <20100118232632.GA5057@cowboy.forcewise.com> Message-ID: Hi Ramon, Ramon F Herrera writes: > The problem that I have is that xsd does not accept the xsd schema > files that I have provided, It would be helpful to see the error messages you get from XSD as well as your schemas. > or sometimes it accepts them but the generated source code does > not compile. I would definitely like to get the schema that reproduces this. > I used the "hello" example as an initial basis. It seems that the 'hello.xsd' > file must be built following certain conventions (IOW, I cannot simply use > an automatically generated xsd file), such as creating a complex type > named 'hello_t'. No, you should be able to use your schemas regardless of the names you use. Perhaps you are trying to use the example driver (driver.cxx) from the hello example with your schemas. Now that won't work. You will need to change it to correspond to your XML vocabulary. > Qustion: is there a sample xsd more complex/realistic than the > 'hello.xsd' provided? There is a number of examples in the examples/ directory in the XSD distribution. The 'library' example might be a good starting point. Also, if you want to see real-world schemas, you can find some on this page: http://wiki.codesynthesis.com/Schemas > > > and xsd does not seem to handle those 'future' references. XSD is able to handle element references without any problems as long as the element name is actually defined (otherwise you will get an error). I am pretty sure there is something wrong with your schemas. Also, if you would like a quick introduction to XML Schema, you may find this document useful: http://www.w3.org/TR/xmlschema-0/ Boris From monika.huether at fkie.fraunhofer.de Thu Jan 21 07:06:45 2010 From: monika.huether at fkie.fraunhofer.de (Huether, Monika) Date: Thu Jan 21 07:06:49 2010 Subject: [xsd-users] Building xsd with the eclipse cdt Message-ID: <1F7B734E199FE14D9EA317591D727919025F15@mailserv1.lorien.fkie.fgan.de> I'm working with eclipse 3.5 under linux and gcc and xercesc 3.0. I'm trying to run the xsd examples. In the xsde mailing list I found an example for building xsde with eclipse. What are the main differences between the xsd and xsde settings? I also can't find the xsd library file in the libxsd folder. Do I have to generate it? Thanks Monika -- Monika H?ther Sensordaten- und Informationsfusion Fraunhofer-Institut f?r Kommunikation, Informationsverarbeitung und Ergonomie FKIE Neuenahrer Stra?e 20 | 53343 Wachtberg Telefon +49 (0)228 9435-338 | Fax -685 mailto:monika.huether@fkie.fraunhofer.de http://www.fkie.fraunhofer.de From boris at codesynthesis.com Thu Jan 21 07:43:13 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jan 21 07:31:37 2010 Subject: [xsd-users] Building xsd with the eclipse cdt In-Reply-To: <1F7B734E199FE14D9EA317591D727919025F15@mailserv1.lorien.fkie.fgan.de> References: <1F7B734E199FE14D9EA317591D727919025F15@mailserv1.lorien.fkie.fgan.de> Message-ID: Hi Monika, Huether, Monika writes: > I'm working with eclipse 3.5 under linux and gcc and xercesc 3.0. I'm > trying to run the xsd examples. In the xsde mailing list I found an > example for building xsde with eclipse. What are the main differences > between the xsd and xsde settings? I have adapted these instructions for the XSD and the C++/Tree mapping. So here are the step-by-step instruction for setting the example/cxx/tree/hello/ example with Eclipse CDT. You can use the same approach for other examples or your application. Here I assume XSD is installed in /opt/xsd and that the Xerces-C++ library was built and installed in /opt/xerces-c. If you haven't built Xerces-C++ yet you can try the following: $ ./configure --prefix /opt/xerces-c $ make $ sudo make install 1. Create a directory for the hello example and copy driver.cxx, hello.xml, and hello.xsd into it. Do not copy the makefile. 2. In Eclipse, do File->New->C++ Project. Type the directory name from step 1 as project name so that the Location field points to the directory created in step 1. Click Next then Finish. At this stage Eclipse will try to build driver.cxx which will result in compile errors. This is expected since we haven't generated the C++ files from the schema yet. 3. In Project Explorer right-click on hello.xsd and select Properties. Select C/C++ Build->Settings, select Build Steps tab, and change Configuration to All. Change "Disable Custom Build Step" to "Apply Custom Build Step Overriding Other Tools". Leave Additional Input Files field blank. In output file names, list all the generated C++ files with the '../' path, separated by semicolon. In our case it will be: ../hello.hxx;../hello.cxx;../hello.ixx In the Command field put the XSD compiler command line that is used to compile the schema. Also add '--output-dir ..' and use the '../' path for the schema file. In our case it will be: /top/xsd/bin/xsd cxx-tree --generate-inline --output-dir .. ../hello.xsd In the Description field put something like "xsd hello.xsd" or "compiling hello.xsd". Click Ok to close the dialog. 4. In Project Explorer right-click on the project name and select Properties. Select C/C++ General->Paths and Symbols, select GNU C++, select Includes tab, and change Configuration to All. Add the path for the libxsd library headers, /opt/xsd/libxsd in our case. Then add the path for the Xerces-C++ headers, /opt/xerces-c/include in our case. Change to the Library Paths tab and add the path to the libxerces-c.so/libxerces-c.a libraries, /opt/xerces-c/lib in our case. Click Apply. Change to C/C++ Build->Settings->GCC C++ Linker->Libraries. Add 'xerces-c' to the Libraries list. Click Ok to close the dialog. 5. Now Eclipse knows how to build the generated C++ files from the schema. Unfortunately, Eclipse is not smart enough to figure out that some files included in driver.cxx are those generated C++ files and it could have successfully compiled driver.cxx if only it compiled the schema first. So when we don't have the generated C++ files, we need to "bootstrap" the project by explicitly compiling them. Once the files are generated, Eclipse will figure out all the dependencies and everything will work as expected (that is, if we modify hello.xsd, Eclipse will know to first recompile hello.xsd and only then recompile driver.cxx). The easiest way to do this bootstrapping is to add a special target that will trigger the schema compilation. Go to Project-> Make Targets->Create. In Target Name type something like Bootstrap. Then uncheck the "Same as the target name" box and enter the name of the generated file with the '../' path, one file per schema is sufficient. In our case it will be ../hello.hxx. Click Ok to close the dialog. 6. Now we can bootstrap the project by doing Project->Make Targets-> Build and selecting the Bootstrap target. After that we can continue with normal builds. Let me know if you run into any issue with this. > I also can't find the xsd library file in the libxsd folder. Do I > have to generate it? No, libxsd is a header-only library so you don't need to build anything for it. Boris From boris at codesynthesis.com Fri Jan 22 09:26:15 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 22 09:16:20 2010 Subject: [xsd-users] Building xsd with the eclipse cdt In-Reply-To: <1F7B734E199FE14D9EA317591D727919025F16@mailserv1.lorien.fkie.fgan.de> References: <1F7B734E199FE14D9EA317591D727919025F16@mailserv1.lorien.fkie.fgan.de> Message-ID: Hi Monika, In the future please keep your replies CC'ed to the xsd-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Huether, Monika writes: > thank you for your quick answer. Now everything works fine. But when I > try to run the project, I return an error: "error while loading shared > libraries: libxerces-c-3.0.so: cannot open shared object file: No such > file or directory" > > But the library and library path are entered in the properties dialog > correctly. Those paths are for the compiler/linker. Here you are having a problem running the program. There are multiple ways to address this, listed from more general to more specific: 1. Add the /opt/xerces-c/lib path to the /etc/ld.so.conf file. This will allow you and other users on this computer to run programs linked to Xerces-C++ without any extra action either from a terminal or from Eclipse. 2. Add the /opt/xerces-c/lib path to the LD_LIBRARY_PATH variable in your .bash_login or similar (and re-login): export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/xerces-c/lib This will allow you to run programs linked to Xerces-C++ without any extra action either from a terminal or from Eclipse. 3. Add the /opt/xerces-c/lib path to the LD_LIBRARY_PATH variable in a terminal: $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/xerces-c/lib This will allow you to run programs linked to Xerces-C++ from this terminal and from Eclipse if you start it from this terminal. 4. In Eclipse in Project Explorer right-click on the project name and select Properties. Select Run/Debug Settings and either edit an existing configuration or create a new one. Select the Environment tab and click New. Enter LD_LIBRARY_PATH in the Name field and /opt/xerces-c/lib in the Value field. Click Ok, to close all the dialogs. This will allow you to run this project from the Eclipse IDE only. Boris From Stephen.James at genband.com Mon Jan 25 12:58:06 2010 From: Stephen.James at genband.com (Stephen James) Date: Mon Jan 25 14:43:39 2010 Subject: [xsd-users] Validation results not as expected. Message-ID: <21F3A5EA2F1A8047A6EA370227C942B203550B18@gbplamail.genband.com> I am testing my solution to verify correct behavior when invalid xml is presented. I can only get exceptions, so far, when I omit a required attribute. The following xml does not throw an exception: Note the first is not terminated??? 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 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 3407 bytes Desc: image001.gif Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20100125/8e146167/attachment.gif From boris at codesynthesis.com Mon Jan 25 15:06:11 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 25 14:53:30 2010 Subject: [xsd-users] Validation results not as expected. In-Reply-To: <21F3A5EA2F1A8047A6EA370227C942B203550B18@gbplamail.genband.com> References: <21F3A5EA2F1A8047A6EA370227C942B203550B18@gbplamail.genband.com> Message-ID: Hi Stephen, Stephen James writes: > The following xml does not throw an exception: Note the first > is not terminated I tried to reproduce this by modifying the hello.xml file in the examples/cxx/tree/hello like this (that is, unterminated greeting element): Hello sun moon world I tried with validation enabled and disabled and in both cases I get: bad.xml:20:3 error: expected end of tag 'greeting' So there has to be something special about the way you do parsing. Can you show the relevant code or even better try to modify one of the example to reproduce the problem? Boris From jstein at fiveringscapital.com Tue Jan 26 09:50:08 2010 From: jstein at fiveringscapital.com (Joel Stein) Date: Tue Jan 26 09:50:18 2010 Subject: [xsd-users] Enums Message-ID: <57A505A533615F418F154E57E6FE7B4D682EAF1738@EXVMBX018-3.exch018.msoutlookonline.net> Hi, If I have: Is there any way to get the string values for "MALE" and "FEMALE" without typing them as a string. Would it possible to reference these as constants or convert a Gender object to a string? Thanks! Joel From boris at codesynthesis.com Tue Jan 26 13:26:16 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 26 13:16:58 2010 Subject: [xsd-users] Enums In-Reply-To: <57A505A533615F418F154E57E6FE7B4D682EAF1738@EXVMBX018-3.exch018.msoutlookonline.net> References: <57A505A533615F418F154E57E6FE7B4D682EAF1738@EXVMBX018-3.exch018.msoutlookonline.net> Message-ID: Hi Joel, Joel Stein writes: > If I have: > > > > > > > > > Is there any way to get the string values for "MALE" and "FEMALE" > without typing them as a string. Would it possible to reference > these as constants or convert a Gender object to a string? The resulting Gender C++ class will have a dual interface. One of a type similar to C++ enum and the other of xml_schema::string which in turn derives from std::string. So you can initialize a Gender object using the enum interface and then get the value as a string, for example: Gender male (Gender::MALE); const std::string& male_str = male; const char* male_c_str = male.c_str (); Boris From Stephen.James at genband.com Tue Jan 26 15:55:48 2010 From: Stephen.James at genband.com (Stephen James) Date: Wed Jan 27 01:21:22 2010 Subject: [xsd-users] Validation results not as expected. In-Reply-To: References: <21F3A5EA2F1A8047A6EA370227C942B203550B18@gbplamail.genband.com> Message-ID: <21F3A5EA2F1A8047A6EA370227C942B203551649@gbplamail.genband.com> I basically copied the code from your driver example for initializing the DOM and parsing, the only difference I could find was that I was reading the xml document from a buffer, rather than from a stream. Note, my DOMLSParser* object and my tree::error_handler objects are file local static objects. >From the working standalone code xml::sax::std_input_source isrc (ifs, argv[j]); Wrapper4InputSource wrap (&isrc, false); Code that is not detecting all errors: XMLCh bufid; MemBufInputSource mem(buffer, len, &bufid); Wrapper4InputSource wrap (&mem, false); Also, how would I reset the error handler in the error_handler_proxy object? I am initializing everything once, caching the schema file and then processing the xml files as they are received over a socket interface. -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Monday, January 25, 2010 2:06 PM To: Stephen James Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Validation results not as expected. Hi Stephen, Stephen James writes: > The following xml does not throw an exception: Note the first > is not terminated I tried to reproduce this by modifying the hello.xml file in the examples/cxx/tree/hello like this (that is, unterminated greeting element): Hello sun moon world I tried with validation enabled and disabled and in both cases I get: bad.xml:20:3 error: expected end of tag 'greeting' So there has to be something special about the way you do parsing. Can you show the relevant code or even better try to modify one of the example to reproduce the problem? Boris From boris at codesynthesis.com Wed Jan 27 07:30:26 2010 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jan 27 07:21:02 2010 Subject: [xsd-users] Validation results not as expected. In-Reply-To: <21F3A5EA2F1A8047A6EA370227C942B203551649@gbplamail.genband.com> References: <21F3A5EA2F1A8047A6EA370227C942B203550B18@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B203551649@gbplamail.genband.com> Message-ID: Hi Stephen, Stephen James writes: > I basically copied the code from your driver example for initializing > the DOM and parsing, the only difference I could find was that I was > reading the xml document from a buffer, rather than from a stream. Note, > my DOMLSParser* object and my tree::error_handler objects are file local > static objects. I can't think of any reason this would cause the errors to disappear. > >From the working standalone code > xml::sax::std_input_source isrc (ifs, argv[j]); > Wrapper4InputSource wrap (&isrc, false); > > Code that is not detecting all errors: > XMLCh bufid; > MemBufInputSource mem(buffer, len, &bufid); > Wrapper4InputSource wrap (&mem, false); Passing uninitialized bufid as a buffer id string is a bad idea. This id is used in diagnostics to identify the document being parsed. Rather, do something like this: MemBufInputSource mem(buffer, len, ""); This way you will get diagnostics like this: :12:34 error: unterminated element tag > Also, how would I reset the error handler in the error_handler_proxy > object? There is no way to reset the error_handler object in 3.2.0 (this has been fixed for the upcoming 3.3.0). So you can either create a new error_handler instance for each parse episode (this is cheap) or I can send you a patch for 3.2.0 that implements the reset functions. Can you also make sure you have this line after the call to DOMLSParser::parse(): eh.throw_if_failed > (); Boris From Stephen.James at genband.com Wed Jan 27 11:34:48 2010 From: Stephen.James at genband.com (Stephen James) Date: Wed Jan 27 11:44:33 2010 Subject: [xsd-users] Validation results not as expected. In-Reply-To: References: <21F3A5EA2F1A8047A6EA370227C942B203550B18@gbplamail.genband.com> <21F3A5EA2F1A8047A6EA370227C942B203551649@gbplamail.genband.com> Message-ID: <21F3A5EA2F1A8047A6EA370227C942B2035AFA88@gbplamail.genband.com> When I went to resetting a new error handler with each parse, it all works as expected. -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, January 27, 2010 6:30 AM To: Stephen James Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Validation results not as expected. Hi Stephen, Stephen James writes: > I basically copied the code from your driver example for initializing > the DOM and parsing, the only difference I could find was that I was > reading the xml document from a buffer, rather than from a stream. Note, > my DOMLSParser* object and my tree::error_handler objects are file local > static objects. I can't think of any reason this would cause the errors to disappear. > >From the working standalone code > xml::sax::std_input_source isrc (ifs, argv[j]); > Wrapper4InputSource wrap (&isrc, false); > > Code that is not detecting all errors: > XMLCh bufid; > MemBufInputSource mem(buffer, len, &bufid); > Wrapper4InputSource wrap (&mem, false); Passing uninitialized bufid as a buffer id string is a bad idea. This id is used in diagnostics to identify the document being parsed. Rather, do something like this: MemBufInputSource mem(buffer, len, ""); This way you will get diagnostics like this: :12:34 error: unterminated element tag > Also, how would I reset the error handler in the error_handler_proxy > object? There is no way to reset the error_handler object in 3.2.0 (this has been fixed for the upcoming 3.3.0). So you can either create a new error_handler instance for each parse episode (this is cheap) or I can send you a patch for 3.2.0 that implements the reset functions. Can you also make sure you have this line after the call to DOMLSParser::parse(): eh.throw_if_failed > (); Boris From benjamin.guillemot at free.fr Sat Jan 30 05:44:28 2010 From: benjamin.guillemot at free.fr (Benjamin Guillemot) Date: Tue Feb 2 04:04:04 2010 Subject: [xsd-users] problem with xsd/tree and tag Message-ID: <4C076189EC0147C88DB0B812EF773B17@Portableben> Hi, I think you don't implement the option < fixed > of the tag fractionDigits. When I make a serialization : for a xsd:decimal type : If I have 1.00 as value i have 1 in my xml file but I want 1.00. (My client need this). The problem is in the file decimal.hxx. Do you think you'll deliver a patch or is there a way to do this properly? Thank you. Benjamin