From giuseppe500 at yahoo.it Tue Feb 1 05:54:53 2011 From: giuseppe500 at yahoo.it (giuseppe ferrari) Date: Tue Feb 1 05:55:01 2011 Subject: [xsd-users] ifc xml Message-ID: <16503.81468.qm@web27306.mail.ukl.yahoo.com> many thanks Boris. I managed to create a test project that deserialize / serialize an XML document. But I want to understand what you did to manage the nillable type,at code level in the parse and serializing the attribute with the nillable_type "nil". I understand that because you use a template (because otherwise you'd having to create many classes) and how to replace in the command xsd nillable types with the template, but not because there are so many types A, B, C, D, etc. in the template ..... Then the management: nil if it is true what does it do? / Nil if there is false or does he? thanks. ________________________________ Da: giuseppe ferrari A: xsd-users@codesynthesis.com Inviato: Ven 28 gennaio 2011, 16:42:40 Oggetto: Re: [xsd-users] ifc xml i think that i have to implement in the nillable-type.hxx class one or more serialization constructor , but what do the serialization constructors that i must implement? The serialization constructors logic is a cascade mode or is more complicated? How works the serialization in your xml engine? Thanks. From giuseppe500 at yahoo.it Tue Feb 1 10:24:30 2011 From: giuseppe500 at yahoo.it (giuseppe ferrari) Date: Tue Feb 1 10:24:38 2011 Subject: [xsd-users] ifc xml Message-ID: <406517.1977.qm@web27302.mail.ukl.yahoo.com> final problem, the namespace. I saw the multiroot example for load an xml in a dom xml model , and the parseWithContext. but i'm not understand how replace a namespace with another . In my case had : xml input 1 , it don't work xml input 2 it work fine xmlns="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" xmlns:ifc="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" xmlns:ex="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" xsi:schemaLocation="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL IFC2X3.xsd"> i must replace xmlns to "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" and add xmlns:ifc="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" is possible do a replace a namespace with the parseWithContext? so i add the xmlns:ifc and replace the xmlns="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" with "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" thanks again. From boris at codesynthesis.com Wed Feb 2 11:26:19 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 2 11:10:50 2011 Subject: [xsd-users] ifc xml In-Reply-To: <406517.1977.qm@web27302.mail.ukl.yahoo.com> References: <406517.1977.qm@web27302.mail.ukl.yahoo.com> Message-ID: Hi Giuseppe, giuseppe ferrari writes: > xmlns="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" > xmlns:ex="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" > xsi:schemaLocation="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL IFC2X3.xsd"> > > xmlns="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" > xmlns:ifc="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" > xmlns:ex="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" > xsi:schemaLocation="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL IFC2X3.xsd"> > > i must replace xmlns to "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" Yes, this is actually something that makes your original XML simply invalid according to the schema. There is no way to fix this with parseWithContext() unfortunately. The best way to resolve this would to get whomever produced the invalid documents to correct them. The only way to work around this issue that I can think of is to parse the document into DOM with validation disabled and then change the DOM document representation (rename element {urn:iso.org:standard:10303:part(28):version(2):xmlschema:common,uos} to {http://www.iai-tech.org/ifcXML/IFC2x3/FINAL,uos}) before passing it to the generated code. > and add > xmlns:ifc="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" This should be possible to accomplish with parseWithContext(). Boris From giuseppe500 at yahoo.it Wed Feb 2 11:47:07 2011 From: giuseppe500 at yahoo.it (giuseppe ferrari) Date: Wed Feb 2 11:47:18 2011 Subject: [xsd-users] ifc xml In-Reply-To: References: <406517.1977.qm@web27302.mail.ukl.yahoo.com> Message-ID: <929045.93854.qm@web27301.mail.ukl.yahoo.com> ________________________________ Da: Boris Kolpackov A: giuseppe ferrari Cc: xsd-users@codesynthesis.com Inviato: Mer 2 febbraio 2011, 17:26:19 Oggetto: Re: [xsd-users] ifc xml Hi Giuseppe, giuseppe ferrari writes: > xmlns="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" > xmlns:ex="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" > xsi:schemaLocation="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL IFC2X3.xsd"> > > xmlns="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" > xmlns:ifc="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" > xmlns:ex="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common" > xsi:schemaLocation="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL IFC2X3.xsd"> > > i must replace xmlns to "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" Yes, this is actually something that makes your original XML simply invalid according to the schema. There is no way to fix this with parseWithContext() unfortunately. The best way to resolve this would to get whomever produced the invalid documents to correct them. The only way to work around this issue that I can think of is to parse the document into DOM with validation disabled and then change the DOM document representation (rename element {urn:iso.org:standard:10303:part(28):version(2):xmlschema:common,uos} to {http://www.iai-tech.org/ifcXML/IFC2x3/FINAL,uos}) before passing it to the generated code. > and add > xmlns:ifc="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL" This should be possible to accomplish with parseWithContext(). Boris thansk . I have resolve. now , and i hope that is the last problem is to parse the three attribute: id,ref and pos in the nillable template; because these attributes are needed for parse("at hand", not the xml parsing of codesynthesis or deserialization) the ifc. In ifc a ref is related to id and a id is related to ref. Is possible to modify the nullable_type template for this? thanks. From boris at codesynthesis.com Thu Feb 3 09:28:24 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 3 09:12:39 2011 Subject: [xsd-users] ifc xml In-Reply-To: <929045.93854.qm@web27301.mail.ukl.yahoo.com> References: <406517.1977.qm@web27302.mail.ukl.yahoo.com> <929045.93854.qm@web27301.mail.ukl.yahoo.com> Message-ID: Hi Giuseppe, giuseppe ferrari writes: > now , and i hope that is the last problem is to parse the three attribute: > id,ref and pos in the nillable template; because these attributes are needed > for parse("at hand", not the xml parsing of codesynthesis or deserialization) > the ifc. > In ifc a ref is related to id and a id is related to ref. > Is possible to modify the nullable_type template for this? Yes, there are two ways to do this. If you know that these three attributes are the only ones needed, then you can just have three data members (e.g., strings) in the complex_nillable_type wrapper for them. In the parsing constructor, if nil is true, then you extract these attributes from the DOM and store them in the data members. Similarly, in the serialization operator, if _nil() is true, you add these attributes to the DOM element. If you want a more generic solution which will work with any attributes, then you can maintain a list of all attributes in complex_nillable_type that were present when parsing an element with nil=true. Boris From giuseppe500 at yahoo.it Fri Feb 4 09:34:29 2011 From: giuseppe500 at yahoo.it (giuseppe ferrari) Date: Fri Feb 4 09:34:37 2011 Subject: [xsd-users] Re: ifc xml and transcode Message-ID: <539231.8539.qm@web27306.mail.ukl.yahoo.com> Hello Boris. Thank you for your previous email, I am now able to import all the attributes. Parsing: The IFC has attributes for each entity as an id or a ref, if it is an object id is a defined entity (filled with data and under data), if a ref wants to say that the object refers to an id and that the 'object' s id must take the place of 'object with ref (clearly de ref == id). Now I thought to use two maps 1) id / item 2) ref / object and loop through all the entities and transcode. The problem for me are nested entities, for example: KGy Kiss678 Gyula222222222 The problem is that I have to iterate the children of the IfcPersonAndOrganization otherwise this person who is the child of IfcPersonAndOrganization i not find 'ever! only iterating the data of the sub-entity i'm can transcode this person , but i must have access to all sequences that are called in a different way, and they are different objects. there is a way to transcode the entire document with the parsing or should I do it with dom at the end of deserialization? thanks. From matthew.d.wood at intel.com Mon Feb 7 23:19:33 2011 From: matthew.d.wood at intel.com (Wood, Matthew D) Date: Tue Feb 8 10:15:51 2011 Subject: [xsd-users] Getting the tag name in a cxx-parser post_ method Message-ID: <8DD2590731AB5D4C9DBF71A877482A900177C82FFB@orsmsx509.amr.corp.intel.com> I'm attempting to parse the XACML 2.0 schema using the XSD/Parser method (http://docs.oasis-open.org/xacml/2.0/access_control-xacml-2.0-policy-schema-os.xsd). I have everything working beautifully, except for one construct that seems to be a bit of a corner-case for the parser. The schema defines a type AttributeDesignatorType and four derived types ActionAttributeDesignatorType, ResourceAttributeDesignatorType, EnvironmentAttributeDesignatorType, and SubjectAttributeDesignatorType with the following properties: - AttributeDesignatorType is an abstract type that is never found in actual XML - All derivatives of AttributeDesignatorType are part of substitution group ExpressionType - Only SubjectAttributeDesignatorType has additional attributes - Each derived type has a specific semantic meaning, so they need to be differentiated The last point causes the parser to generate a parser skeleton for AttributeDesignatorType and SubjectAttributeDesignatorType, with the former parser shared by the three types defining no additional structure and the later parser derived from the former. At points within the schema where a specific derivative type is reference explicitly, I can infer the tag type based on the element callback of the containing parser. In cases where the derivative type is encountered in the context of a substitution group, I can differentiate the SubjectAttributeDesignatorType due to the extra attributes triggering the unique parser, but the other three derivatives only call the parser for the common AttributeDesignatorType. When I receive the call to post_AttributeDesignatorType (via overridden post_ExpressionType), I need to determine the end tag name to properly interpret the semantics of the document. This is where I'm stumped. Setting a breakpoint in the post_AttributeDesignatorType method, I can see that the call sequence triggering the method is from the parser skeleton of the containing element instead of the AttributeDesignatorType parser skeleton, so overriding the _end_element_impl method in the AttributeDesignatorType skeleton and stealing the tag that way won't work. I could override the _end_element_impl method in the containing parser, but I can't see a clean way to do that, and there are multiple points where the structure can appear in the context of a substitution group so it could get really messy from a maintenance standpoint. Thanks in advance, Matt From boris at codesynthesis.com Tue Feb 8 12:22:10 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Feb 8 12:05:19 2011 Subject: [xsd-users] Getting the tag name in a cxx-parser post_ method In-Reply-To: <8DD2590731AB5D4C9DBF71A877482A900177C82FFB@orsmsx509.amr.corp.intel.com> References: <8DD2590731AB5D4C9DBF71A877482A900177C82FFB@orsmsx509.amr.corp.intel.com> Message-ID: Hi Matthew, Wood, Matthew D writes: > At points within the schema where a specific derivative type is reference > explicitly, I can infer the tag type based on the element callback of the > containing parser. In cases where the derivative type is encountered in > the context of a substitution group, I can differentiate the > SubjectAttributeDesignatorType due to the extra attributes triggering > the unique parser, but the other three derivatives only call the parser > for the common AttributeDesignatorType. When I receive the call to > post_AttributeDesignatorType (via overridden post_ExpressionType), I > need to determine the end tag name to properly interpret the semantics > of the document. This is the "substitution group element acts as an identifier" pattern that does not map very cleanly to OO type systems. We had a similar questions on the XSD/e list some time ago: http://www.codesynthesis.com/pipermail/xsde-users/2008-October/000072.html There is unfortunately no elegant way to deal with this in C++/Parser in XSD (we have added explicit support for the current element querying in XSD/e thought). The best approach that I can think of right now boils down to intercepting the SAX callbacks and caching the element name somewhere where the AttributeDesignatorType can retrieve it. Here is one way this can be implemented (I assume you are using Xerces-C++ as the underlying XML parser): 1. Create your own SAX2XMLReader parser. See the 'performance' example for the code that shows how to do this. 2. Create your own SAX2 handler by deriving from xercesc::DefaultHandler. In the startElement callback save the element name/namespace and call the previous handler (can be stored as a member variable). For the rest of the callbacks, call the previous handler. For the list of callbacks that you need to "forward" see the event_router class in libxsd/xsd/cxx/parser/xerces/elements.hxx. 3. Create your own document class that derives from xml_schema::document. Add a member variable that stores a reference to SAX2XMLReader and a member variable that stores the SAX2 handler created above. Override the start_root_element() callback in which you first get the current handler and pass it to your customized handler created on step (2) (SAX2XMLReader::getDefaultHandler) and then set the custom handler as the new current handler (SAX2XMLReader::setDefaultHandler). For the code that shows how to override start_root_element(), see the 'multiroot' example. 4. Pass SAX2 handler to AttributeDesignatorType's c-tor which stores it in a member variable for later use. In its pre() callback it can then use the handler to retrieve the current element name/namespace. 5. Use the custom document class as the document parser and pass the SAX2XMLReader parser to the parse() function. Boris From shubhgd at cs.vt.edu Tue Feb 8 14:06:27 2011 From: shubhgd at cs.vt.edu (shubhgd@cs.vt.edu) Date: Wed Feb 9 01:48:44 2011 Subject: [xsd-users] Integrating XSD generated classes into an existing C++ project Message-ID: <20110208140627.43245zggappr516b@webmail.cs.vt.edu> Hi, I am trying to integrate XSD generated classes into an existing C++ project, however, am not able to find the best way to do this. What I did and what I am looking for follows, 1. Created C++ classes (cxx and hxx) from an XML schema using xsd cxx-tree. 2. Need to include the classes generated in step 1 into an existing C++ make project (it is a huge application with lot of dependencies and all) 3. Tried to include the xsd generated classes as #include in the main.cpp of the existing application, but got a lot of runtime errors with error messages like ?DOMNode? declared as a ?virtual? field at external location: /usr/include/xsd/cxx/tree/elements.hxx expected a type, got ?map? external location: /usr/include/xsd/cxx/tree/elements.hxx and so on. 4. Not sure how to integrate the two projects (XSD and the existing application) seemingly. Please let me know if any one has encountered such a problem or has a clue on moving ahead with this. I might be doing something wrong fundamentally, as have no experience in dealing with C++ projects. I appreciate any kind of help. Thank you. Thanks and Regards, -S From matthew.d.wood at intel.com Tue Feb 8 21:47:34 2011 From: matthew.d.wood at intel.com (Wood, Matthew D) Date: Wed Feb 9 01:48:44 2011 Subject: [xsd-users] Supporting recursive types with XSD/Parser Message-ID: <8DD2590731AB5D4C9DBF71A877482A90017BADD33C@orsmsx509.amr.corp.intel.com> Thanks again for the quick response on my previous question. I recently discovered another issue processing the XACML 2.0 schema. The element can be nested, such as: abc I see the following set of calls using XSD/Parser w/Expat for the XML above (indented to match XML): ConditionType_pimpl::pre() ApplyType_pimpl::pre() // First Apply element start ApplyType_pimpl::FunctionId() AttributeValueType_pimpl::pre() AttributeValueType_pimpl:: _any_characters() // xsi:anyType AttributeValueType_pimpl::post_AttributeValueType() // via post_ExpressionType() override ApplyType_pimpl::Expression() // result of AttributeValueType_pimpl::post_AttributeValueType() ApplyType_pimpl::pre() // Second Apply element start ApplyType_pimpl::FunctionId() ActionAttributeDesignatorType_pimpl::pre() ActionAttributeDesignatorType_pimpl::AttributeId() ActionAttributeDesignatorType_pimpl::DataType() ActionAttributeDesignatorType_pimpl::post_ActionAttributeDesignatorType() // via post_ExpressionType() override ApplyType_pimpl::Expression() // result of ActionAttributeDesignatorType_pimpl::post_AttributeValueType() ApplyType_pimpl::Expression() // !!!! same value was passed to previous call !!!! ApplyType_pimpl::post_ApplyType() // via post_ExpressionType() override // !!!! Missing second call to post_ApplyType() !!!! ConditionType_pimpl::Expression() // result of ApplyType_pimpl::post_ApplyType() ConditionType_pimpl::post_ConditionType() Since the ApplyType_pimpl is a recursively called parser, I implemented an internal value stack. Whenever a pre() call is made, it pushes a state record. Element callbacks are handled using the state on the top of the stack. The post_ApplyType() calls cause a return value to be generated and the stack to pop. Since the callbacks aren't being called correctly, the stack never pops the second time. I couldn't find an example of how to handle this successfully. Am I missing something, or is this a known issue? A workaround would be greatly appreciated. Thanks in advance, Matt From Daniel.roy.Kaasa at kongsberg.com Wed Feb 9 04:25:40 2011 From: Daniel.roy.Kaasa at kongsberg.com (Daniel.roy.Kaasa@kongsberg.com) Date: Wed Feb 9 04:25:51 2011 Subject: [xsd-users] Output location and symbol conflicts. Message-ID: Hi Boris, I am trying to solve two problems which I haven't find a solution for (please correct me if I am way off course). 1. I would like to have XSD generate the output for two differently located paths, (.h) files in one location and (.cpp) in another. For example, my project is structured as so ./cpp/include/gml (.h) and ./cpp/gml/generated (cpp). Currently I am using regex options to modify the include statements and executing a perl script to move the files explicitly and this is tedious. It would be nice if it were possible to have a switch for specifying --output-h-dir and --output-c-dir. In addition that the includes were prefixed to reflect the header file locations. 2. My projects are partitioned with dynamic libraries, but my problem is specifically with DLLs on windows. I have followed the documentation for exporting and importing, using the options --import-maps and --export-maps. However I am running into problems symbols conflicts with the xml_schema::simple_type<> being defined across several dlls. For example I am importing symbols from dlls which contain generated parsers into other dependent dlls of parsers. xlink.dll <--gml.dll <--filter.dll Daniel __________________________________________________________________________ Daniel R. K?sa, Kongsberg Defence & Aerospace, P. O. Box 1003, 3601 Kongsberg, Norway Email: daniel.roy.kaasa@kongsberg.com Tlf (+47) 32 28 89 78, (+47) 32 73 34 43 www.kongsberg.com CONFIDENTIALITY This e-mail and any attachment contain KONGSBERG information which may be proprietary, confidential or subject to export regulations, and is only meant for the intended recipient(s). Any disclosure, copying, distribution or use is prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in error, please delete it immediately from your system and notify the sender properly. From giuseppe500 at yahoo.it Wed Feb 9 06:03:12 2011 From: giuseppe500 at yahoo.it (giuseppe ferrari) Date: Wed Feb 9 06:03:21 2011 Subject: [xsd-users] (no subject) Message-ID: <931632.75998.qm@web27305.mail.ukl.yahoo.com> hello Boris. I rebuild the question because i'm was don't clear. In my xml i have a set of ref and id attributes. I read that xerces builds a id/ref cross/reference. My problem is that the id ref cross reference don't work! may be that i have the class template nullable-type that don't read the ref attribute when the nill attribute == true? and this compromises the cross/reference? I try to read the ref attribute with the attached nullable-type , but don't works. thanks. -------------- next part -------------- A non-text attachment was scrubbed... Name: nillable-type.hxx Type: application/octet-stream Size: 7278 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20110209/9587d1df/nillable-type.obj From boris at codesynthesis.com Wed Feb 9 09:57:54 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 9 09:40:49 2011 Subject: [xsd-users] Output location and symbol conflicts. In-Reply-To: References: Message-ID: Hi Daniel, Daniel.roy.Kaasa@kongsberg.com writes: > 1. I would like to have XSD generate the output for two differently > located paths, (.h) files in one location and (.cpp) in another. > For example, my project is structured as so ./cpp/include/gml (.h) > and ./cpp/gml/generated (cpp). Currently I am using regex options > to modify the include statements and executing a perl script to > move the files explicitly and this is tedious. It would be nice > if it were possible to have a switch for specifying --output-h-dir > and --output-c-dir. In addition that the includes were prefixed > to reflect the header file locations. While it will be possible to add the options you have mentioned, automatically figuring out the include prefix will be a bit too much magic for XSD to handle. Consider something like this: xsd cxx-tree --output-h-dir ../include/foo --output-c-dir src/bar What should the include prefix be? It can be 'foo' (-I ../include), or empty (-I ../include/foo). Or it can be ../../include/foo. The XSD compiler has no way of guessing which one you have in mind. > 2. My projects are partitioned with dynamic libraries, but my problem > is specifically with DLLs on windows. I have followed the documentation > for exporting and importing, using the options --import-maps and > --export-maps. However I am running into problems symbols conflicts > with the xml_schema::simple_type<> being defined across several dlls. > For example I am importing symbols from dlls which contain generated > parsers into other dependent dlls of parsers. > > xlink.dll <--gml.dll <--filter.dll You need to generate the XML Schema namespace into a separate file (--generate-xml-schema), place this file into the "root" DLL (xlink.dll in your case is a good candidate), and then use that file in all other schemas (--extern-xml-schema). Boris From boris at codesynthesis.com Wed Feb 9 10:01:37 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 9 09:44:31 2011 Subject: [xsd-users] Re: Integrating XSD generated classes into an existing C++ project In-Reply-To: <20110208140627.43245zggappr516b@webmail.cs.vt.edu> References: <20110208140627.43245zggappr516b@webmail.cs.vt.edu> Message-ID: Hi, shubhgd@cs.vt.edu writes: > 3. Tried to include the xsd generated classes as #include in the > main.cpp of the existing application, but got a lot of runtime errors > with error messages like > ?DOMNode? declared as a ?virtual? field at external location: > /usr/include/xsd/cxx/tree/elements.hxx > expected a type, got ?map? external location: > /usr/include/xsd/cxx/tree/elements.hxx > and so on. Which C++ compiler and version are you using? Have you added include paths (-I C++ compiler option) for Xerces-C++ and libxsd? > I might be doing something wrong fundamentally, as have no experience > in dealing with C++ projects. In this case I suggest that you find someone in your organization who has experience with this kind of C++ projects and who can help you out. Boris From boris at codesynthesis.com Wed Feb 9 10:41:54 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 9 10:24:49 2011 Subject: [xsd-users] Supporting recursive types with XSD/Parser In-Reply-To: <8DD2590731AB5D4C9DBF71A877482A90017BADD33C@orsmsx509.amr.corp.intel.com> References: <8DD2590731AB5D4C9DBF71A877482A90017BADD33C@orsmsx509.amr.corp.intel.com> Message-ID: Hi Matthew, Wood, Matthew D writes: > I see the following set of calls using XSD/Parser w/Expat for the XML > above (indented to match XML): C++/Parser supports recursive parsing and we have a test case for that in the test suite. If you have validation enabled, can you try to disable it and see if anything changes? Boris From rjl at third-monday.com Wed Feb 9 10:37:15 2011 From: rjl at third-monday.com (Russ Loucks) Date: Wed Feb 9 10:37:22 2011 Subject: [xsd-users] Integrating XSD generated classes into an existing C++ project In-Reply-To: <20110208140627.43245zggappr516b@webmail.cs.vt.edu> References: <20110208140627.43245zggappr516b@webmail.cs.vt.edu> Message-ID: <4D52B4AB.5070904@third-monday.com> On 02/08/2011 01:06 PM, shubhgd@cs.vt.edu wrote: > Hi, > > I am trying to integrate XSD generated classes into an existing C++ > project, however, am not able to find the best way to do this. What I > did and what I am looking for follows, > 1. Created C++ classes (cxx and hxx) from an XML schema using xsd > cxx-tree. > 2. Need to include the classes generated in step 1 into an existing > C++ make project (it is a huge application with lot of dependencies > and all) > 3. Tried to include the xsd generated classes as #include in the > main.cpp of the existing application, but got a lot of runtime errors > with error messages like > ?DOMNode? declared as a ?virtual? field at external location: > /usr/include/xsd/cxx/tree/elements.hxx > expected a type, got ?map? external location: > /usr/include/xsd/cxx/tree/elements.hxx > and so on. > 4. Not sure how to integrate the two projects (XSD and the existing > application) seemingly. > > Please let me know if any one has encountered such a problem or has a > clue on moving ahead with this. I might be doing something wrong > fundamentally, as have no experience in dealing with C++ projects. I > appreciate any kind of help. Thank you. I've been sort of successful doing this sort of thing. My application is not that large, only about 10 or so subdirectories of source files. The project is a Qt-based beast and I let that build the Makefiles from the Qt project files. I have a separate (pre-built) Makefile that converts the XSD files to source files and builds up a Qt project file for those files. I do run that Makefile separately from the main Qt-based build process; I just haven't figured out how to include that step in the Qt-based project build process (e.g., the current process is not painful enough for me to change it, yet...). The directory structure in summary: root src dir1 cpp and h files dir2 cpp and h files dir3 cpp and h files xsd resource.xsd Makefile.XSD This makefile runs xsd-tree over the XSD files in 'resource.xsd' and puts them in 'src/xsd'. It then creates a 'xsd.pri' (Qt-project include file) of these files and puts that in the 'src/xsd' directory. Other notes: 1) All Makefiles include the Xerces and XSD installation directories in the includes options (e.g., -I/usr/share/xsd-3.3.0/libxsd -I/usr/share/xerces-c-3/include). 2) All (of my) include files that use XSD-based structures include statements to forward declare the classes (since I have namespaces in my XSD structures): namespace model { namespace flowDesign { class displayLayoutPanelType; class displayLayoutComponentType; } } using namespace model::flowDesign; 3) All (of my) source files that use the XSD-based structures include the top-level (e.g. root) elements as needed: #include "xsd/displayLayoutPanelType.h" 4) The Makefiles include the Xerces library path (-L/usr/share/xerces-c-3 -lxerces-c_3) to build/link. Hope that helps. r -- Russ Loucks mailto: rjl AT third-monday DOT com mobile: 612.205.9171 www.third-monday.com From boris at codesynthesis.com Wed Feb 9 10:58:43 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 9 10:41:38 2011 Subject: [xsd-users] ID/IDREF and nillable In-Reply-To: <931632.75998.qm@web27305.mail.ukl.yahoo.com> References: <931632.75998.qm@web27305.mail.ukl.yahoo.com> Message-ID: <20110209155843.GA9715@onega.codesynthesis.com> Hi Giuseppe, giuseppe ferrari writes: > In my xml i have a set of ref and id attributes. > I read that xerces builds a id/ref cross/reference. That's correct, though it is at the DOM level. > My problem is that the id ref cross reference don't work! may be that > i have the class template nullable-type that don't read the ref attribute > when the nill attribute == true? Do you mean the ID/IDREF reference support in the object model does not work? I.e., using the IDREF type to get the referenced object? If that's the case then yes, if you don't store the ref attribute in the nillable type wrapper as xml_schema::idref, then the references won't work. In essence, what you need to do is add a member to complex_nillable_type of type xml_schema::idref, let's say it is called ref_. Then, in the parsing constructor, you initialize it like this: complex_nillable_type (const xercesc::DOMElement& e, xml_schema::flags f = 0, xml_schema::container* c = 0) : B (e, f | xml_schema::flags::base, c), nil_ (false), ref_ (xml_schema::idref (""), 0, this) { string ref_str = ... ref_ = ref_str; } Then, once the whole document has been parsed, you can try to resolve the reference. If you try to resolve inside the parsing constructor, it may fail because the referenced object may not have been parsed yet. Boris From boris at codesynthesis.com Thu Feb 10 05:26:39 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 10 05:09:49 2011 Subject: [xsd-users] Output location and symbol conflicts. In-Reply-To: References: Message-ID: Hi Daniel, Boris Kolpackov writes: > You need to generate the XML Schema namespace into a separate file > (--generate-xml-schema), place this file into the "root" DLL (xlink.dll > in your case is a good candidate), and then use that file in all other > schemas (--extern-xml-schema). I forgot to mention that you will also need to use the --export-xml-schema option when generating the XML Schema namespace types to export them from the root DLL. Boris From matthew.d.wood at intel.com Wed Feb 9 14:55:34 2011 From: matthew.d.wood at intel.com (Wood, Matthew D) Date: Thu Feb 10 05:10:14 2011 Subject: [xsd-users] Supporting recursive types with XSD/Parser In-Reply-To: References: <8DD2590731AB5D4C9DBF71A877482A90017BADD33C@orsmsx509.amr.corp.intel.com> Message-ID: <8DD2590731AB5D4C9DBF71A877482A90017BADD731@orsmsx509.amr.corp.intel.com> With or without the --generate-validation switch, I get the same sequence of calls from the skeleton. Could the issue be the combination of recursive parsing and polymorphic types? Every element within the element is part of the ExpressionType substitution group. I set a breakpoint in xsd::cxx::parser::expat::document::end_element_thunk_(void*, const C*) at the point where it calls d.end_element_() to correlate incoming end tag to the to the *_pimpl::post_* method called up the stack. When the second end tag is found in the original sample, it calls ApplyType_pimpl::Expression(), but doesn't call ApplyType_pimpl::post_ExpressionType() first, as expected (ApplyType_pimpl overrides post_ExpressionType() to call ApplyType_pimpl::post_ApplyType() for polymorphic support). Going back to the call sequence I'm experiencing, I've noted the missing call that would make the sequence work correctly. ConditionType_pimpl::pre() ApplyType_pimpl::pre() // First Apply element start ApplyType_pimpl::FunctionId() AttributeValueType_pimpl::pre() AttributeValueType_pimpl:: _any_characters() // xsi:anyType AttributeValueType_pimpl::post_AttributeValueType() // via post_ExpressionType() override ApplyType_pimpl::Expression() // result of AttributeValueType_pimpl::post_AttributeValueType() ApplyType_pimpl::pre() // Second Apply element start ApplyType_pimpl::FunctionId() ActionAttributeDesignatorType_pimpl::pre() ActionAttributeDesignatorType_pimpl::AttributeId() ActionAttributeDesignatorType_pimpl::DataType() ActionAttributeDesignatorType_pimpl::post_ActionAttributeDesignatorType() // via post_ExpressionType() override ApplyType_pimpl::Expression() // result of ActionAttributeDesignatorType_pimpl::post_AttributeValueType() ******** Begin Expected Reaction to second ******** ++++++++ Begin Missing Call ++++++++ ApplyType_pimpl::post_ApplyType() // via postExpressionType() override ++++++++ End Missing Call ++++++++ ApplyType_pimpl::Expression() ******** End Expected Reaction to second ******** ApplyType_pimpl::post_ApplyType() // via post_ExpressionType() override ConditionType_pimpl::Expression() // result of ApplyType_pimpl::post_ApplyType() ConditionType_pimpl::post_ConditionType() My options file contains the following lines: --xml-parser expat --generate-validation --namespace-map urn:oasis:names:tc:xacml:2.0:policy:schema:os=XACMLPolicyParser --root-element Policy --root-element PolicySet --type-map xsd.map --char-type char --generate-polymorphic Thanks, Matt -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Wednesday, February 09, 2011 7:42 AM To: Wood, Matthew D Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Supporting recursive types with XSD/Parser Importance: Low Hi Matthew, Wood, Matthew D writes: > I see the following set of calls using XSD/Parser w/Expat for the XML > above (indented to match XML): C++/Parser supports recursive parsing and we have a test case for that in the test suite. If you have validation enabled, can you try to disable it and see if anything changes? Boris From giuseppe500 at yahoo.it Thu Feb 10 11:37:12 2011 From: giuseppe500 at yahoo.it (giuseppe ferrari) Date: Thu Feb 10 11:37:21 2011 Subject: [xsd-users] Re: reference Message-ID: <261901.15725.qm@web27306.mail.ukl.yahoo.com> thanks boris. I did that you say ,but now how i can resolve the refid type after the document parsing? i read a lot in the documentation and i searched in google , but i not able to understand how solve a reference I explain my problem : i have create a member in the nullable type and i set the ref_ attribute when i need , so i try to resolve the ref/id with the idref IfcPersonBase is the reference that i must resolve: complex_nillable_type* pobje = dynamic_cast< complex_nillable_type* >(pifcx); xml_schema::idref* p = &pobje->ref_ ; //ref =i1561 ifc::IfcPersonBase* pi = dynamic_cast (ref.get()); the problem is that my xml is formed as : ecc... the resolve system is trying to get the root , the parent of IfcPerson that is that has a map with 0 elements for the resolving system, i think that root should be the that has the elements in map, and then extract the correct reference may be? Thanks. From erik.sjolund at gmail.com Fri Feb 11 09:04:05 2011 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Fri Feb 11 09:04:13 2011 Subject: [xsd-users] serialization into QDataStream binary format Message-ID: Hi, Instead of serializing into XDR or CDR I tried serialize into QDataStream. (for more info see http://doc.qt.nokia.com/4.7/qdatastream.html) Here is the source code: https://svn.sbc.su.se/repos/qdatastream-for-codesynthesis-xsd/tags/first-trial I have only done one test and that was with the schema file examples/cxx/tree/hello/hello.xsd That test worked for me. Here is some information of how I proceeded. I started out by copying from the directory xsd-3.3.0-x86_64-linux-gnu/libxsd/xsd/cxx/tree the files xdr-stream-insertion.hxx xdr-stream-extraction.hxx xdr-stream-common.hxx to new file names; qdatastream-stream-insertion.hxx qdatastream-stream-extraction.hxx qdatastream-stream-common.hxx and adjusted them to QDataStream. There is not much error handling. Maybe there are some exceptions from Qt that could be caught to be able to throw the exceptions qdatastream_stream_insertion and qdatastream_stream_extraction ? Please also take a look at the functions for insertion and extraction of const buffer& x I saved the length into the datatype quint64. Is it the right choice? In the file qdatastream-stream-extraction.hxx : ------- int bytes_read = s.impl ().readRawData (x.data (), len_as_int); if (bytes_read != len_as_int) { std::cerr << "readRawBytes did not read all bytes" << std::endl; exit (EXIT_FAILURE); } -------- If readRawData() reads less than requested we probably should not exit(). Maybe a while loop is better? Feel free to modify the code and incorporate it into XSD. See my modifications to these files as public domain. To test it out you could do something like xsdcxx cxx-tree --hxx-prologue '#include "qdatastream-stream-insertion.hxx"' \ --hxx-prologue '#include "qdatastream-stream-extraction.hxx"' \ --generate-extraction QDataStream \ --generate-insertion QDataStream \ --generate-serialization In your program you need to include these files: #include #include and write something like: QFile file("/tmp/qt.dat"); file.open(QIODevice::WriteOnly); QDataStream q_datastream(&file); xml_schema::ostream ostream_qt(q_datastream); ostream_qt << data_object; file.close(); cheers, Erik Sj?lund From boris at codesynthesis.com Fri Feb 11 11:04:30 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Feb 11 10:47:57 2011 Subject: [xsd-users] serialization into QDataStream binary format In-Reply-To: References: Message-ID: Hi Erik, Erik Sj?lund writes: > Please also take a look at the functions for insertion and extraction of > const buffer& x > I saved the length into the datatype quint64. Is it the right choice? Yes, either 32 or 64 bit unsigned integer should work fine. > In the file qdatastream-stream-extraction.hxx : > ------- > int bytes_read = s.impl ().readRawData (x.data (), len_as_int); > if (bytes_read != len_as_int) { > std::cerr << "readRawBytes did not read all bytes" << std::endl; > exit (EXIT_FAILURE); > } > -------- > If readRawData() reads less than requested we probably should not exit(). Yes, definitely. Throwing an exception is probably a good idea. > Maybe a while loop is better? This really depends on the semantics of readRawBytes(). Does the Qt documentation say that you have to keep calling it until you get all the data? > Feel free to modify the code and incorporate it into XSD. See my > modifications to these files as public domain. This looks very cool but I think a better approach would be to upload your implementation (perhaps with an example and a README file) to the wiki: http://wiki.codesynthesis.com/XSD Boris From giuseppe500 at yahoo.it Mon Feb 14 04:20:37 2011 From: giuseppe500 at yahoo.it (giuseppe ferrari) Date: Mon Feb 14 04:20:45 2011 Subject: [xsd-users] Re: xml not well formed Message-ID: <699567.70635.qm@web27308.mail.ukl.yahoo.com> sorry , i'm attach the wrong xml , this is the correct xml ________________________________ Da: giuseppe ferrari A: Boris Kolpackov ; xsd-users@codesynthesis.com Inviato: Lun 14 febbraio 2011, 10:17:19 Oggetto: xml not well formed hello. I have the attached xml that was exported by a software, and i'm trying to parse it. The problem are the pos attributes with prefix :ex, how i can prepare it for the deserializing? Why this exporting behavior of the xml? 1)There is a namespace problem? 2)I must delete the ex prefix from the pos attributes? thanks. -------------- next part -------------- A non-text attachment was scrubbed... Name: 6.ifcxml Type: application/octet-stream Size: 21198 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20110214/0950c85b/6.obj From erik.sjolund at gmail.com Mon Feb 14 07:37:46 2011 From: erik.sjolund at gmail.com (=?ISO-8859-1?Q?Erik_Sj=F6lund?=) Date: Mon Feb 14 07:38:06 2011 Subject: [xsd-users] serialization into QDataStream binary format In-Reply-To: References: Message-ID: On Fri, Feb 11, 2011 at 5:04 PM, Boris Kolpackov wrote: > This looks very cool but I think a better approach would be to upload > your implementation (perhaps with an example and a README file) to the > wiki: Good idea. I added http://wiki.codesynthesis.com/Binary_serialization cheers, Erik Sj?lund From darren.garvey at gmail.com Mon Feb 14 07:21:26 2011 From: darren.garvey at gmail.com (Darren Garvey) Date: Mon Feb 14 07:52:44 2011 Subject: [xsd-users] Element names from exceptions Message-ID: Hi, I am currently trying to produce some user-friendly error messages by extracting information from the exceptions thrown by C++/Tree parsing. The actual error descriptions are quite nice in most cases and I can pass them on directly. However, while the line / column numbers are useful when debugging problem, they're indecipherable to users, who don't see XML at all but a user interface. I was hoping to get information about the element being parsed without having to dig back into the XML using the line / column info. For instance, when an empty element is found that is expected to be a number, you get: "error: value '' does not match regular expression facet '[+\-]?[0-9]+'". Is there some means of getting the context of the error, eg. the element name that was being parsed? Thanks in advance, Darren From boris at codesynthesis.com Mon Feb 14 15:23:23 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 14 15:07:42 2011 Subject: [xsd-users] Element names from exceptions In-Reply-To: References: Message-ID: Hi Darren, Darren Garvey writes: > The actual error descriptions are quite nice in most cases and I can pass > them on directly. However, while the line / column numbers are useful when > debugging problem, they're indecipherable to users, who don't see XML at all > but a user interface. I was hoping to get information about the element > being parsed without having to dig back into the XML using the line / column > info. > > For instance, when an empty element is found that is expected to be a > number, you get: "error: value '' does not match regular expression facet > '[+\-]?[0-9]+'". > > Is there some means of getting the context of the error, eg. the element > name that was being parsed? The information in the error messages is what's provided by Xerces-C++ and there is no built-in support for element names/paths there. But you can achieve this yourself with a little bit of code. Here is the outline: 1. First parse the document with validation enabled. If there were any errors, remember their line/column information (see the xml_schema::parsing exception for details). 2. Parse the XML again but this time with validation disables and into a DOM document. You will also need to assign line/column numbers to the elements in this DOM document. For more information on how to do this, see the 'linecol' example: http://www.codesynthesis.com/~boris/tmp/linecol.tar.gz 3. Now traverse the DOM document looking for elements that match (or are closest too) the line number of the error. You can also use the column number to further narrow down the list to a single element. This might be necessary if you have something like this in your XML: foobar 4. Once you have the element, you can get its name or even traverse its parents chain to construct an XPath-like path. Boris From boris at codesynthesis.com Mon Feb 14 15:33:05 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 14 15:17:24 2011 Subject: [xsd-users] serialization into QDataStream binary format In-Reply-To: References: Message-ID: Erik Sj?lund writes: > I added > http://wiki.codesynthesis.com/Binary_serialization Great stuff! Thanks, Erik. Boris From giuseppe500 at yahoo.it Mon Feb 14 04:17:19 2011 From: giuseppe500 at yahoo.it (giuseppe ferrari) Date: Mon Feb 14 15:27:40 2011 Subject: [xsd-users] xml not well formed Message-ID: <701712.96909.qm@web27307.mail.ukl.yahoo.com> hello. I have the attached xml that was exported by a software, and i'm trying to parse it. The problem are the pos attributes with prefix :ex, how i can prepare it for the deserializing? Why this exporting behavior of the xml? 1)There is a namespace problem? 2)I must delete the ex prefix from the pos attributes? thanks. -------------- next part -------------- A non-text attachment was scrubbed... Name: 2.ifcxml Type: application/octet-stream Size: 33450 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20110214/ace97c54/2-0001.obj From boris at codesynthesis.com Mon Feb 14 15:49:18 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 14 15:33:40 2011 Subject: [xsd-users] Re: xml not well formed In-Reply-To: <701712.96909.qm@web27307.mail.ukl.yahoo.com> References: <701712.96909.qm@web27307.mail.ukl.yahoo.com> Message-ID: Hi Giuseppe, giuseppe ferrari writes: > I have the attached xml that was exported by a software, and i'm trying > to parse it. The XML your software produced is invalid per the schema. In ex.xsd you have attributeFormDefault="unqualified" which means the "pos" attribute should be unqualified in the XML. > The problem are the pos attributes with prefix :ex, how i can prepare > it for the deserializing? > Why this exporting behavior of the xml? I think you should contact the vendor of the software that you are using and ask them to fix this problem. The xsd-users mailing list is definitely the wrong place to ask such questions about third- party software. Boris From boris at codesynthesis.com Tue Feb 15 06:22:54 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Feb 15 06:07:23 2011 Subject: [xsd-users] XSD/e 3.2.0 released Message-ID: Hi, We have released XSD/e 3.2.0. XSD/e is the light-weight/mobile/embedded applications version of XSD. Major new features in this release include configurable application character encoding, support for custom memory allocators, mapping of XML Schema enumerations to C++ enums, support for schema evolution, generation of clone functions for variable-length types, and improved support for XML Schema facet validation, including xs:pattern. This release also adds official support and sample configurations for the Integrity 178b, Android, and Symbian platforms. For the complete and more detailed list of new features in this release, refer to the announcement email on the xsde-announcements mailing list: http://www.codesynthesis.com/pipermail/xsde-announcements/2011/000010.html Boris From rlischner at proteuseng.com Thu Feb 17 08:09:15 2011 From: rlischner at proteuseng.com (Ray Lischner) Date: Thu Feb 17 08:52:45 2011 Subject: [xsd-users] Capturing schema version number Message-ID: We are using C++/Tree 3.3.0. We need to be able to record the schema version number in the generated code when the schema provides the version attribute. What I'd like to do is to declare an extern std::string or char array in the generated header, with the definition in the generated source file. I can easily write a script to get the schema version, but the --prologue and --epilogue switches insert their text outside the generated namespace. This is usually what I want, but in this case, I want to inject text inside the namespace. How do I do that? At this point, the only two options I see are: 1. Modify xsd to generate the information I want. Add, say, --generate-version-string switch. 2. Write a script to post-process the generated source files. Are there any other options? Ray Lischner, Distinguished Member of Technical Staff 133 National Business Pkwy, Ste 150 t. 443.539.3448 Annapolis Junction, MD 20701 c. 410.854.5170 rlischner@proteuseng.com f. 443.539.3370 This electronic message and any files transmitted with it contain information which may be privileged and/or proprietary. The information is intended for use solely by the intended recipient(s). If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of this information is prohibited. If you have received this electronic message in error, please advise the sender by reply email or by telephone (443.539.3400) and delete the message. From boris at codesynthesis.com Thu Feb 17 09:26:24 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 17 09:11:39 2011 Subject: [xsd-users] Capturing schema version number In-Reply-To: References: Message-ID: Hi Ray, Ray Lischner writes: > We need to be able to record the schema version number in the generated > code when the schema provides the version attribute. What I'd like to do > is to declare an extern std::string or char array in the generated header, > with the definition in the generated source file. I can easily write a > script to get the schema version, but the --prologue and --epilogue > switches insert their text outside the generated namespace. This is > usually what I want, but in this case, I want to inject text inside > the namespace. How do I do that? I assume you realize that if you have two such schema files that map to the same C++ namespace, you will get duplicate symbols down the line. If you still want this, what prevents you from opening the namespace in prologue/epilogue? If you don't want to hard-code C++ namespaces in the command line, your script can extract the targetNamespace attribute just as it does for version. You can then map it to a C++ namespace similar to how XSD does it. Boris From shubhgd at cs.vt.edu Sun Feb 20 20:11:38 2011 From: shubhgd at cs.vt.edu (shubhgd@cs.vt.edu) Date: Mon Feb 21 01:42:16 2011 Subject: [xsd-users] error: cannot convert to ?int? in assignment Message-ID: <20110220201138.10202038h5tlkk3u@webmail.cs.vt.edu> Hi, I am trying to use the XSD generated C++ classes for mapping an XML schema union type data. The XSD definition looks like: and in the driver.cxx I want to use the value of a scalar variable from the corresponding XML. I tried to achieve this with the following piece of code: auto_ptr a (aircraft (xml_file_path)); for (data::scalar_const_iterator s (d->scalar().begin ()); s != d->scalar ().end ();++s) { string nm = s->name().get(); if(nm == "npts_top") { int npts_top = s->sval(); } } Here, aircraft is the root element. And the hierarchy is aircraft->data->scalar. However, with this piece of code, I get the following error: error: cannot convert ?const scalartype? to ?int? in assignment which sounds right because sval is of type scalartype and not int. But scalartype can be a type of int (as it's a union of int, string, and so on). So, I am not able to convert sval to an int type which I was guessing would be taken care of by the underlying scalartype, but apparently not. Could any one let me know how to handle this? Thank you very much. Thanks and Regards, Shubhangi From boris at codesynthesis.com Mon Feb 21 08:57:20 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 21 08:40:26 2011 Subject: [xsd-users] Re: error: cannot convert to ?int? in assignment In-Reply-To: <20110220201138.10202038h5tlkk3u@webmail.cs.vt.edu> References: <20110220201138.10202038h5tlkk3u@webmail.cs.vt.edu> Message-ID: Hi Shubhangi, shubhgd@cs.vt.edu writes: > > > > > [...] > > However, with this piece of code, I get the following error: > error: cannot convert ?const scalartype? to ?int? in assignment In C++/Tree union XML Schema types are mapped to C++ classes derived from std::string. So what you get is a lexical representation of the value. If you want to convert it to one of the member types, you will need to do it yourself, for example: #include using namespace std; scalartype v = ...; int i; istringstream is (v); if (!is >> i) { // Error: value is not an int. } Or, if you are using Boost, you can shorten the above code with lexical_cast: #include using boost::lexical_cast; scalartype v = ...; int i = lexical_cast (v); Boris From shubhgd at cs.vt.edu Mon Feb 21 10:41:08 2011 From: shubhgd at cs.vt.edu (shubhgd@cs.vt.edu) Date: Mon Feb 21 15:19:44 2011 Subject: [xsd-users] Re: error: cannot convert to ?int? in assignment In-Reply-To: References: <20110220201138.10202038h5tlkk3u@webmail.cs.vt.edu> Message-ID: <20110221104108.935671u9ysw40mtw@webmail.cs.vt.edu> Hi Boris, Thank you very much. It works fine with the boost::lexical_cast. Now, have another problem with parsing a nested element type. I am trying to understand how a nested XML element gets mapped into C++ classes and finding it difficult to reach to the leaf node easily. The hierarchy is as the following. What I need to do is, to retrieve the def field (which is a xs:string) for a CT of an AFB. So the hierarchy of elements to access is: G->AFB->CT->def, however, each one of them have a complexType definition and I don't know how to reach the leaf from the following hierarchy of complexTypes and elements. It would be great if you can put some light on this. Thank you very much. Thanks and Regards, Shubhangi Quoting "Boris Kolpackov" : > Hi Shubhangi, > > shubhgd@cs.vt.edu writes: > >> >> >> >> >> [...] >> >> However, with this piece of code, I get the following error: >> error: cannot convert ?const scalartype? to ?int? in assignment > > In C++/Tree union XML Schema types are mapped to C++ classes derived > from std::string. So what you get is a lexical representation of the > value. If you want to convert it to one of the member types, you will > need to do it yourself, for example: > > #include > > using namespace std; > > scalartype v = ...; > int i; > > istringstream is (v); > if (!is >> i) > { > // Error: value is not an int. > } > > Or, if you are using Boost, you can shorten the above code with > lexical_cast: > > #include > > using boost::lexical_cast; > > scalartype v = ...; > int i = lexical_cast (v); > > Boris > > From victor.manoliu at yahoo.com Tue Feb 22 04:14:06 2011 From: victor.manoliu at yahoo.com (Adrian Victor Manoliu) Date: Tue Feb 22 04:14:14 2011 Subject: [xsd-users] CityGML deserialization - CityModel generation Message-ID: <995783.93915.qm@web45504.mail.sp1.yahoo.com> Greetings everyone, I'm currently working on a CityGML (de)serializer - I need C++ classes for certain corresponding objects - and I'm having some trouble with generating the root object itself. I don't know how familiar everyone here is with CityGML, but here's a description of the situation: I've used the CodeSynthesis version of xsd.exe in the supplied command line batch via the common.options/gml.options/citygml.options files. As a result, hxx and cxx files were created for each of the GML and CityGML xsd files. The root object tag in CityGML is , but the root class is actually CityModelType. The corresponding constructor I used is found in citygmlbase.hxx and has the prototype: ::std::auto_ptr< ::citygml::CityModelType > CityModel (::xml_schema::dom::auto_ptr< xercesc::DOMDocument >& d, ::xml_schema::flags f, const ::xml_schema::properties&) I used this constructor (which I've also pasted entirely at the end of my post) in order to create my object and iterate through its items: const std::string fName = "waldbruecke_v1.0.0.gml"; std::auto_ptr iCity(CityModel(fName, flags.dont_validate)); CityModelType::_GenericApplicationPropertyOfCityModel_const_iterator ci; (I supplied "flags.dont_validate" because I don't want the schemas to be validated via Internet.) Within the above mentioned constructor a map is created, which seems to hold the correspondencies between CityGML(XML) tags and the generated classes: ::xsd::cxx::tree::type_factory_map< char >& tfm ( ::xsd::cxx::tree::type_factory_map_instance< 0, char > () ); This is where things start to go wrong. tfm actually contains two maps, type_map and element_map (typical for XML, I would say): tfm {type_map_=[624](...,...) element_map_={...} } xsd::cxx::tree::type_factory_map & Of these two, the first one seems to be ok, however element_map is just a long array of fields containing "error". I can't really tell what that "error" means or what caused it. I haven't found any source where this string is assigned to the fields of the map, in the cxx or txx files, so this would be the first problem. Afterwards, the actual object, r, is created through another pointer, tmp: ::std::auto_ptr< ::xsd::cxx::tree::type > tmp ( tfm.create ( "CityModel", "http://www.opengis.net/citygml/1.0", &::xsd::cxx::tree::factory_impl< ::citygml::CityModelType >, true, true, e, n, f, 0)); The resulting object pointer looks like this (there are 1870 parsed items): ptr {dom_info_=auto_ptr {...} map_=auto_ptr [1870]((0x01e6e0e8,0x01e6da38 {_GenericApplicationPropertyOfBuilding_={...} }),...,...) container_=0x00000000 } Finally, the object is generated and returned by the constructor: if (tmp.get () != 0) { ::std::auto_ptr< ::citygml::CityModelType > r ( dynamic_cast< ::citygml::CityModelType* > (tmp.get ())); if (r.get ()) tmp.release (); else throw ::xsd::cxx::tree::not_derived< char > (); return r; } The object is made of three fields: flags_, container_ and v_. The 1870 items in the pointer exist in container_, however v_ is completely empty, and this is the second problem because it's the v_ field that the iterator will look in to retrieve the CityModelType elements (back in the main method). To conclude, I would say this second issue is caused by the first one, but I can't really tell why all this is happening. Hope to hear from you soon. Thanks. Cheers, Victor ********** ::std::auto_ptr< ::citygml::CityModelType > CityModel (::xml_schema::dom::auto_ptr< xercesc::DOMDocument >& d, ::xml_schema::flags f, const ::xml_schema::properties&) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > c ( ((f & ::xml_schema::flags::keep_dom) && !(f & ::xml_schema::flags::own_dom)) ? static_cast< xercesc::DOMDocument* > (d->cloneNode (true)) : 0); xercesc::DOMDocument& doc (c.get () ? *c : *d); const xercesc::DOMElement& e (*doc.getDocumentElement ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (e)); if (f & ::xml_schema::flags::keep_dom) doc.setUserData (::xml_schema::dom::tree_node_key, (c.get () ? &c : &d), 0); ::xsd::cxx::tree::type_factory_map< char >& tfm ( ::xsd::cxx::tree::type_factory_map_instance< 0, char > ()); ::std::auto_ptr< ::xsd::cxx::tree::type > tmp ( tfm.create ( "CityModel", "http://www.opengis.net/citygml/1.0", &::xsd::cxx::tree::factory_impl< ::citygml::CityModelType >, true, true, e, n, f, 0)); if (tmp.get () != 0) { ::std::auto_ptr< ::citygml::CityModelType > r ( dynamic_cast< ::citygml::CityModelType* > (tmp.get ())); if (r.get ()) tmp.release (); else throw ::xsd::cxx::tree::not_derived< char > (); return r; } throw ::xsd::cxx::tree::unexpected_element < char > ( n.name (), n.namespace_ (), "CityModel", "http://www.opengis.net/citygml/1.0"); } } ********** From boris at codesynthesis.com Tue Feb 22 10:49:06 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Feb 22 10:32:17 2011 Subject: [xsd-users] CityGML deserialization - CityModel generation In-Reply-To: <995783.93915.qm@web45504.mail.sp1.yahoo.com> References: <995783.93915.qm@web45504.mail.sp1.yahoo.com> Message-ID: Hi Victor, Adrian Victor Manoliu writes: > The corresponding constructor I used is found in citygmlbase.hxx and > has the prototype: > > ::std::auto_ptr< ::citygml::CityModelType > > CityModel (::xml_schema::dom::auto_ptr< xercesc::DOMDocument >& d, > ::xml_schema::flags f, > const ::xml_schema::properties&) This is not a constructor, it is a parsing function. > const std::string fName = "waldbruecke_v1.0.0.gml"; > std::auto_ptr iCity(CityModel(fName, flags.dont_validate)); > CityModelType::_GenericApplicationPropertyOfCityModel_const_iterator ci; > > Within the above mentioned constructor a map is created, which seems to > hold the correspondencies between CityGML(XML) tags and the generated > classes: You are going into implementation details of XSD expecting things to be a certain way without understanding very well how they works. I suggest that instead you tell us what is not working in your code. For example, do you not get any members in CityModelType instance? Boris From boris at codesynthesis.com Tue Feb 22 10:52:45 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Feb 22 10:35:57 2011 Subject: [xsd-users] Re: error: cannot convert to ?int? in assignment In-Reply-To: <20110221104108.935671u9ysw40mtw@webmail.cs.vt.edu> References: <20110220201138.10202038h5tlkk3u@webmail.cs.vt.edu> <20110221104108.935671u9ysw40mtw@webmail.cs.vt.edu> Message-ID: Hi, shubhgd@cs.vt.edu writes: > I am trying to understand how a nested XML element gets mapped into > C++ classes and finding it difficult to reach to the leaf node easily. This is covered in detail in both numerous examples that come with XSD (e.g., 'library') and the Getting Started Guide (Sections 4.1 and 4.2). Boris From victor.manoliu at yahoo.com Wed Feb 23 02:38:59 2011 From: victor.manoliu at yahoo.com (Adrian Victor Manoliu) Date: Wed Feb 23 02:39:08 2011 Subject: [xsd-users] CityGML deserialization - CityModel generation In-Reply-To: References: <995783.93915.qm@web45504.mail.sp1.yahoo.com> Message-ID: <399571.66645.qm@web45511.mail.sp1.yahoo.com> Hello, Thank you for your quick reaction. Indeed I'm rather loose in expressing myself, but everything is rather complex and I try to summarize a bit. I guess that made the final part of my message confusing. What I meant to say was that after the CityModel method is called, iCity is made of three fields: flags_, container_ and v_. The 1870 items in the pointer exist in container_, however v_ is completely empty. This is the problem because it's the v_ field that the iterator looks in to retrieve the elements. Perhaps the invalid map fields created earlier cause this. Victor ----- Original Message ---- From: Boris Kolpackov To: Adrian Victor Manoliu Cc: xsd-users@codesynthesis.com Sent: Tue, February 22, 2011 4:49:06 PM Subject: Re: [xsd-users] CityGML deserialization - CityModel generation Hi Victor, Adrian Victor Manoliu writes: > The corresponding constructor I used is found in citygmlbase.hxx and > has the prototype: > > ::std::auto_ptr< ::citygml::CityModelType > > CityModel (::xml_schema::dom::auto_ptr< xercesc::DOMDocument >& d, > ::xml_schema::flags f, > const ::xml_schema::properties&) This is not a constructor, it is a parsing function. > const std::string fName = "waldbruecke_v1.0.0.gml"; > std::auto_ptr iCity(CityModel(fName, flags.dont_validate)); > CityModelType::_GenericApplicationPropertyOfCityModel_const_iterator ci; > > Within the above mentioned constructor a map is created, which seems to > hold the correspondencies between CityGML(XML) tags and the generated > classes: You are going into implementation details of XSD expecting things to be a certain way without understanding very well how they works. I suggest that instead you tell us what is not working in your code. For example, do you not get any members in CityModelType instance? Boris From boris at codesynthesis.com Wed Feb 23 08:31:45 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 23 08:15:04 2011 Subject: [xsd-users] CityGML deserialization - CityModel generation In-Reply-To: <399571.66645.qm@web45511.mail.sp1.yahoo.com> References: <995783.93915.qm@web45504.mail.sp1.yahoo.com> <399571.66645.qm@web45511.mail.sp1.yahoo.com> Message-ID: Hi Victor, Adrian Victor Manoliu writes: > What I meant to say was that after the CityModel method is called, iCity is made > of three fields: flags_, container_ and v_. These are private, implementation-specific members of the CityModelType class. Why do you insist on looking into the implementation details? Did you try to access the data stored in CityModelType using the public interface? In particular, did you try to iterate over the _GenericApplicationPropertyOfCityModel element sequence that is contained in CityModelType? Note also that it is an abstract element and you will need to cast it to one of the concrete types, as described in Section 2.11, "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11 Boris From victor.manoliu at yahoo.com Thu Feb 24 04:58:02 2011 From: victor.manoliu at yahoo.com (Adrian Victor Manoliu) Date: Thu Feb 24 04:58:10 2011 Subject: [xsd-users] CityGML deserialization - CityModel generation In-Reply-To: References: <995783.93915.qm@web45504.mail.sp1.yahoo.com> <399571.66645.qm@web45511.mail.sp1.yahoo.com> Message-ID: <392645.14182.qm@web45503.mail.sp1.yahoo.com> Greetings, I really am sorry, but I just can't figure this out. To be more specific: Here I create the CityModelType object, iCity: const std::string fName = "waldbruecke_v1.0.0.gml"; std::auto_ptr iCity(CityModel(fName, flags.dont_validate)); While debugging, after this instruction, in my 'Locals' tab iCity is composed of two elements: - a public gml::AbstractFeatureCollectionType, which includes: - public gml::AbstractFeatureType wrapper - private featureMember_ - private featureMembers_ - the private _GenericApplicationPropertyOfCityModel_ which contains the sequence of private items: - flags_ - container_ - v_ Now, once I have iCity, I simply want to iterate over its elements, that is the Buildings, BuildingParts etc. by doing something like this (I have been doing this from the start): CityModelType::_GenericApplicationPropertyOfCityModel_const_iterator ci; for ( ci = iCity->_GenericApplicationPropertyOfCityModel().begin(); ci != iCity->_GenericApplicationPropertyOfCityModel().end(); ++ci) { [...] } I understand there's a problem of abstract objects and I have read the manual chapter concerning dynamic casts, however in this case I don't see how I could know what type to cast these objects to (this is also due to my lack of experience in dealing with these automatically generated classes which relate in an intricate way). The reason for which I insist on flags_, container_ and v_ is the way projects like "library" (in the XSD example suite) work - the iterator which is used there looks in the v_ field. Actually, it's quite the same thing here, the "begin()" function returns the iterator at the position v_.begin(). In the "library" example, v_ contains the three elements corresponding to the book records. Here, like I said, for iCity this field is [0](), so the for loop doesn't happen. The objects are not there, but they can, however, be found in the map_ of the container_ field. I don't know what I could use from the public interface to get to those records. Actually, if this is the right situation (and those earlier mentioned maps aren't wrong), what I would like to know is what I can iterate upon in this case. Again, I'm sorry if I'm being obnoxious, but this is rather stressful. Thank you for your understanding. Victor ----- Original Message ---- From: Boris Kolpackov To: Adrian Victor Manoliu Cc: xsd-users@codesynthesis.com Sent: Wed, February 23, 2011 2:31:45 PM Subject: Re: [xsd-users] CityGML deserialization - CityModel generation Hi Victor, Adrian Victor Manoliu writes: > What I meant to say was that after the CityModel method is called, iCity is >made > of three fields: flags_, container_ and v_. These are private, implementation-specific members of the CityModelType class. Why do you insist on looking into the implementation details? Did you try to access the data stored in CityModelType using the public interface? In particular, did you try to iterate over the _GenericApplicationPropertyOfCityModel element sequence that is contained in CityModelType? Note also that it is an abstract element and you will need to cast it to one of the concrete types, as described in Section 2.11, "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11 Boris From hayim at marvell.com Thu Feb 24 06:48:11 2011 From: hayim at marvell.com (Haim Boot) Date: Thu Feb 24 06:57:56 2011 Subject: [xsd-users] Using XSD with VxWorks Message-ID: Hi Boris I'm using CodeSynthesis XSD XML Schema to C++ compiler 3.3.0 code generator. I tired to compile it using Tornado (for VxWorks) and I get many errors due to lack of header files (i/ostream, BASETSD.H, etc). I read on your web site that Tornado tool chain is supported for VxWorks. Are there any special steps which I should take in order to build it? Is there any special lib which should be used during linkage? Thanks, Haim ________________________________ Haim Boot, Marvell Israel - SW Engineer 6 Hamada Street Mordot HaCarmel Industrial Park Yokneam, 20692, Israel Email: hayim@marvell.com Office: +972.4.9091520 - OnNet: 704.1520 Fax: +972.4.9091501 Web site: http://www.marvell.com This message may contain confidential, proprietary or legally privileged information. The information is intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by telephone or by e-mail and delete the message from your computer. ________________________________ From boris at codesynthesis.com Thu Feb 24 07:04:18 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 24 07:02:27 2011 Subject: [xsd-users] Using XSD with VxWorks In-Reply-To: References: Message-ID: Hi Haim, Haim Boot writes: > I'm using CodeSynthesis XSD XML Schema to C++ compiler 3.3.0 code generator. > I tired to compile it using Tornado (for VxWorks) and I get many errors > due to lack of header files (i/ostream, BASETSD.H, etc). > > I read on your web site that Tornado tool chain is supported for VxWorks. XSD does not support VxWorks but XSD/e[1] does. The page[2] you are referring to is talking about XSD/e. [1] http://www.codesynthesis.com/products/xsde/ [2] http://www.codesynthesis.com/products/xsde/platforms.xhtml Boris From boris at codesynthesis.com Mon Feb 28 09:48:35 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Feb 28 09:47:11 2011 Subject: [xsd-users] CityGML deserialization - CityModel generation In-Reply-To: <392645.14182.qm@web45503.mail.sp1.yahoo.com> References: <995783.93915.qm@web45504.mail.sp1.yahoo.com> <399571.66645.qm@web45511.mail.sp1.yahoo.com> <392645.14182.qm@web45503.mail.sp1.yahoo.com> Message-ID: Hi Adrian, Adrian Victor Manoliu writes: > const std::string fName = "waldbruecke_v1.0.0.gml"; > std::auto_ptr iCity(CityModel(fName, flags.dont_validate)); > > [...] > > Now, once I have iCity, I simply want to iterate over its elements, that > is the Buildings, BuildingParts etc. by doing something like this (I have > been doing this from the start): > > CityModelType::_GenericApplicationPropertyOfCityModel_const_iterator ci; > > for (ci = iCity->_GenericApplicationPropertyOfCityModel().begin(); > ci != iCity->_GenericApplicationPropertyOfCityModel().end(); > ++ci) > { > [...] > } > > however in this case I don't see how I could know what type to cast these > objects to You need to study the GML/CityGML schemas to see which concrete elements (and types) substitute which abstract elements. Here is an example body of the above for-loop. Hopefully, it will get you started: for (ci = iCity->_GenericApplicationPropertyOfCityModel().begin(); ci != iCity->_GenericApplicationPropertyOfCityModel().end(); ++ci) { xml_schema::type& x (*ci); if (gml::FeaturePropertyType* cityObjectMember = dynamic_cast (&x)) { gml::FeaturePropertyType::_Feature_const_iterator fi; for (fi = cityObjectMember->_Feature ().begin (); fi != cityObjectMember->_Feature ().end (); ++fi) { gml::AbstractFeatureType& f (*fi); if (citygml::building::BuildingType* b = dynamic_cast (&f); { // We've got a building. } else if (...) { ... } } } } Boris From mburnham at gblsys.com Mon Feb 28 16:38:07 2011 From: mburnham at gblsys.com (Matt Burnham) Date: Mon Feb 28 16:38:19 2011 Subject: [xsd-users] enumerations not exported in dll when "generate-inline" enabled Message-ID: Using XSD (C++ / Tree) version 3.3 I have a schema that includes the following: The command line (along with the additional option --hxx-prologue "#include \"my_dll_export.h\"" ) for generating the C++ class is: xsd.exe cxx-tree --generate-inline --generate-serialization --generate-ostream --generate-default-ctor --output-dir "." --hxx-suffix ".hxx" --cxx-suffix ".cxx" --ixx-suffix ".ixx" --fwd-suffix "-fwd.hxx" --namespace-map "=tmp" --export-symbol "MY_DLL_DECL" The resulting class is put in a DLL and when I try and link an application with the DLL, I get the following link error: unresolved external symbol "public: static char const * const * const tmp::action::_xsd_action_literals_" (?_xsd_action_literals_@action@tmp@@2QBQBDB) If I don't enable inline generation, everything works fine. I'm attaching a zip file that contains a VS 2010 solution and projects to build both the DLL and application using the dll. It uses the rules file the cxx-tree build step. -------------- next part -------------- A non-text attachment was scrubbed... Name: test_xml.zip Type: application/zip Size: 5459 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20110228/718607a6/test_xml.zip