From till.steinbach at informatik.haw-hamburg.de Wed Aug 3 11:48:05 2011 From: till.steinbach at informatik.haw-hamburg.de (Till Steinbach) Date: Wed Aug 3 11:48:10 2011 Subject: [xsd-users] Cross file references Message-ID: Dear mailing list users, i have a question concerning references. I have a huge XSD schema of my meta model that was generated from an Ecore model. My instances are divided in multiple xml files each with its own root. There are references between the files. Example: ------------foo.xml--------------- ------------model.xml--------------- I then try to parse the model.xml. Of course the parser is not able to resolve the refBar object correctly since it does not understand the syntax of the reference (It is the EMF syntax). If there would be another way to specify such links I could change the references on the fly before parsing. Is there a way to use links to elements in other files with xsd? I currently use xcerces as underlaying xml parser. Thanks! Till -------------------------------------------------------------------------------------- Till Steinbach till.steinbach@informatik.haw-hamburg.de Arbeitsgruppe CoRE - Communication over Real-time Ethernet Hochschule f?r Angewandte Wissenschaften Hamburg Raum 580B Berliner Tor 7 20099 Hamburg Tel.: +49 40 428 59 8406 http://www.informatik.haw-hamburg.de/core.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2476 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20110803/ebb6ce41/smime.bin From boris at codesynthesis.com Thu Aug 4 09:10:42 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 4 09:13:20 2011 Subject: [xsd-users] Cross file references In-Reply-To: References: Message-ID: Hi Till, Till Steinbach writes: > i have a question concerning references. I have a huge XSD schema of my meta > model that was generated from an Ecore model. My instances are divided in > multiple xml files each with its own root. There are references between the > files. > > > > > > > > The " Is there a way to use links to elements in other files with xsd? > I currently use xcerces as underlaying xml parser. There are generally two approaches to handling this which can be called "before schema" and "after schema". With the "before schema" approach your XML Schema (and the resulting C++ object model) doesn't know anything about references and expects XML as a single, complete file (or stream). The way to handle this with XSD is to first parse the XML file into DOM and then pre-process it (by resolving all the references) before handing it off to the object model parser. The major drawback of this approach is that you cannot use XML Schema validation since that happens during the XML-to-DOM parsing stage and since your schema doesn't know anything about references, validation will fail. The "after schema" approach assumes that your schemas are aware of the referencing mechanism. For example, the schema can look like this: Which allows the instance to look like this: ddd Or like this: With this approach you can have XML Schema validation enabled. You can also resolve the references in the DOM document before handing it off to the object model or you can do it in the object model (since the object model will contain the references). You can even customize the generated object model (the model type in the above example) to load the referenced elements automatically or even lazily. Which approach to choose for reference resolution will probably be influenced by the number of types that can have such references. If the number of great then it may be too tedious to customize every type and the generic DOM approach may be an easier solution. Also your references look a lot like XPath so you can probably use the XPath processor (either the one that comes with Xerces-C++ or XQilla) to resolve them. Boris From till.steinbach at informatik.haw-hamburg.de Fri Aug 5 03:45:09 2011 From: till.steinbach at informatik.haw-hamburg.de (Till Steinbach) Date: Fri Aug 5 03:45:11 2011 Subject: [xsd-users] Cross file references In-Reply-To: References: Message-ID: Hi Boris, thanks a lot for your advices! > The " was ment > There are generally two approaches to handling this which can be > called "before schema" and "after schema". > > With the "before schema" approach your XML Schema (and the resulting > C++ object model) doesn't know anything about references and expects > XML as a single, complete file (or stream). The way to handle this > with XSD is to first parse the XML file into DOM and then pre-process > it (by resolving all the references) before handing it off to the > object model parser. > > The major drawback of this approach is that you cannot use XML Schema > validation since that happens during the XML-to-DOM parsing stage and > since your schema doesn't know anything about references, validation > will fail. The missing Schema validation is no problem. To be sure to understand you right. 1. Parse the first file into DOM. loop until end of file 2.1 Go through the model to the next reference 2.2 Do the parsing for the Reference 2.3 Replace the reference with the resulting DOM endloop 3. Pass the DOM with the resolved references to the object model parser This was my first Idea as well, but what if there are cycles in the references? What if there are multiple references to the same object. Will the object parser use the same objects for the same elements in the DOM? Example: This should be resolved as two model objects with pointers to the same bar object! > The "after schema" approach assumes that your schemas are aware of the > referencing mechanism. For example, the schema can look like this: > > > > > > > > > > > > > > > > > > Which allows the instance to look like this: > > > > ddd > > > > Or like this: > > > > My schema looks like this: So it would allow either bar to be an element of model or a reference as string attribute. > With this approach you can have XML Schema validation enabled. You can > also resolve the references in the DOM document before handing it off > to the object model or you can do it in the object model (since the > object model will contain the references). You can even customize the > generated object model (the model type in the above example) to load > the referenced elements automatically or even lazily. > > Which approach to choose for reference resolution will probably be > influenced by the number of types that can have such references. If > the number of great then it may be too tedious to customize every > type and the generic DOM approach may be an easier solution. There are lots of references. So it would require lots of work to change all the types > Also your references look a lot like XPath so you can probably use > the XPath processor (either the one that comes with Xerces-C++ or > XQilla) to resolve them. Unfortunately it is not XPath! It's an EMF special syntax, but it would be no problem to preprocess it and make it XPath style. The problem is that XPath does not allow referencing other files I think. That is in my eyes the biggest issue that forces me to resolve the references manually. Thanks for your help! Till -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2476 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20110805/1094567b/smime.bin From boris at codesynthesis.com Fri Aug 5 07:22:56 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 5 07:25:34 2011 Subject: [xsd-users] Cross file references In-Reply-To: References: Message-ID: Hi Till, Till Steinbach writes: > To be sure to understand you right. > > 1. Parse the first file into DOM. > loop until end of file > 2.1 Go through the model to the next reference > 2.2 Do the parsing for the Reference > 2.3 Replace the reference with the resulting DOM > endloop > 3. Pass the DOM with the resolved references to the object model parser Yes, that's exactly what I meant. > This was my first Idea as well, but what if there are cycles in the > references? What if there are multiple references to the same object. > Will the object parser use the same objects for the same elements in > the DOM? If you have cycles and need to share the same nodes between multiple references (which is also will most likely be required to deal with cycles), then this approach probably won't work. > My schema looks like this: > > > > > > > > > > > > > [...] > > There are lots of references. So it would require lots of work to > change all the types. You don't really need to change the types. You just derive from the generated ones and customize some aspects. For more information on type customization see the C++/Tree Mapping Customization Guide: http://wiki.codesynthesis.com/Tree/Customization_guide As well as the examples in the examples/cxx/tree/custom/ directory. Based on your requirements (handle cycles, shared nodes), it seems you will have to handle this in the object model. You can either leave the object model unchanged and resolve references in the user code as they are retrieved. Using your schema as an example, that would mean checking if the refBar attribute is present, if so, looking up the expression in some map of already loaded fragments that is kept on the side, if it is there, then returning it. Otherwise load the object model for the referenced file, find the node in question and then add it to the map and return that. Alternatively, if you want to hide all this from the clients of the object model, then you will need to customize the types that have such references and hide all these operations in these customizations (the map of already loaded fragments should probably go to the root of the model). This will require some work from your side (maybe you can use template to automate some of it). But then your requirements are not exactly trivial either. > Unfortunately it is not XPath! I have only seen one example of the expression, but everything after the file name looks like XPath to me. Boris From mikekowdley at yahoo.com Sun Aug 14 17:51:01 2011 From: mikekowdley at yahoo.com (Mike Kowdley) Date: Mon Aug 15 08:40:38 2011 Subject: [xsd-users] looking for help designing my XSD to work with my XML's namespace Message-ID: <1313358661.45967.YahooMailNeo@web160317.mail.bf1.yahoo.com> Hello all, I am receiving an XML file and am trying to design an XSD that will allow me to parse it using the xsd cxx-tree tool.? I am using CodeSynthesis XSD 3.3.0.? The document is failing to parse and I am not sure how to correct my XSD document. My XML document looks something like this: 1234 ? data ? data And my XSD looks something like this: ? ? ??? ????? ????? ??? ??? ??? ??? ? ? ??? ????? ??? ? I have changed some of the names to protect the innocent. If I try to parse this document I get an unexpected element exception. expected_namespace: expected_name: ReferenceInformation encountered_namespace: urn:dataprovidercontent:referenceinformation03 encountered_name: ReferenceInformation I have also found that if I edit the XML document and remove the xmlns attribute from the start tag, then the document parses without any error. It seems that the xmlns attribute to the tag needs to be noted in the XSD document. I'm equally happy solving this the "right" way (getting my XSD to be correct for parsing this document) or the "wrong" way (convining the parser to ignore the namespace, or something similar) but I am pretty new to this so I'm not sure how to proceed. Hopefully my question is succinct enough that it's an easy answer!? Thanks in advance for reading this question. Regards, Mike K. From boris at codesynthesis.com Mon Aug 15 08:44:08 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 15 08:46:43 2011 Subject: [xsd-users] looking for help designing my XSD to work with my XML's namespace In-Reply-To: <1313358661.45967.YahooMailNeo@web160317.mail.bf1.yahoo.com> References: <1313358661.45967.YahooMailNeo@web160317.mail.bf1.yahoo.com> Message-ID: Hi Mike, Mike Kowdley writes: > xmlns="urn:dataprovidercontent:referenceinformation03"> > 1234 > > [...] > > It seems that the xmlns attribute to the tag > needs to be noted in the XSD document. Yes, this is a very basic XML Schema knowledge and strictly speaking such questions are off-topic here (this mailing list is not for XML Schema help; more appropriate places would be the xmlschema-dev and xml-dev mailing lists). To fix your schema you will need to add the following attributes to your xsd:schema element: targetNamespace="urn:dataprovidercontent:referenceinformation03" elementFormDefault="true" Boris From mjklaim at gmail.com Thu Aug 18 09:17:10 2011 From: mjklaim at gmail.com (=?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?=) Date: Thu Aug 18 09:17:17 2011 Subject: [xsd-users] Namespace name constant Message-ID: Hi, I can see in my xsd genereted code ( http://code.google.com/p/art-of-sequence/source/browse/tools/aoslcpp/include/aoslcpp/aosl/aosl.hpp and related files ) that the namespace name is always written directly as " artofsequence.org/aosl/1.0" and not a constant. I was looking for such a constant to use it in my tool code, in particular in this case where I need validation (from http://code.google.com/p/art-of-sequence/source/browse/tools/aosdesigner/core/Sequence.cpp ) : Sequence::Sequence( Project& project, const boost::filesystem::path sequence_file_path ) : m_project( project ) , m_location( sequence_file_path ) { xml_schema::Properties properties; properties.schema_location( "artofsequence.org/aosl/1.0", path::AOSL_XSD_FILE.string() ); // HERE boost::filesystem::ifstream filestream( full_location() ); try { auto sequence = aosl::parse_sequence( filestream, 0, properties ); m_sequence.reset( sequence.release() ); } catch( const ::xsd::cxx::tree::parsing< char >& e ) { ... } ... } bool Sequence::save() { .... xml_schema::NamespaceInfomap namespace_infos; namespace_infos["aos"].name = "artofsequence.org/aosl/1.0"; boost::filesystem::ofstream filestream( sequence_file_path ); aosl::serialize_sequence( filestream, *m_sequence, namespace_infos ); return true; } My questions : 1. Did I miss the existence of such a constant? 2. Is there a way to make the generator provide it? I want the tool to be dependant on the version of the library which code have been generated from the xsd, so I need them to use the same namespace. So the name of the namespace should be available in the generated code. I want to avoid having to change a constant in the tool code each time I change the namespace in the xsd and generate code from it. I'll certainly miss that change as several years might separate each change... Jo?l Lamotte From boris at codesynthesis.com Fri Aug 19 04:42:25 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 19 04:44:58 2011 Subject: [xsd-users] Namespace name constant In-Reply-To: References: Message-ID: Hi Jo?l, Klaim - Jo?l Lamotte writes: > 1. Did I miss the existence of such a constant? The only way to get this constant is to use the element type feature (--generate-element-type). In this mode XSD will generate a type instead of a set of parsing/serialization functions for each global element (document root). These types provide the static name() and namespace_() functions. See the documentation as well as the 'messaging' example in the examples/cxx/tree/ directory in the XSD distribution for more information. Boris From erikina at gmail.com Mon Aug 22 20:43:38 2011 From: erikina at gmail.com (Eric Springer) Date: Mon Aug 22 20:44:05 2011 Subject: [xsd-users] Please don't use 'override' as a variable name Message-ID: Hi, One issue I'm have with XSD is the use of "override" in a couple places, ( e.g. in xsd 3.3.0, override an argument name to the function "register_type" on line 229 of file: cxx/tree/type-factory-map.txx) Visual Studio treats 'override' as a keyword meaning that you are overriding a virtual function, and if you're not (e.g. you made a mistake, or the base signature changed) it will fail to compile. For other compilers we have a simple macro like "#define override " to strip out override for compatibility As a result, this means that when using xsd we need to patch the system header manually, which is pretty unideal and messy. It'd be really great if you guys could rename the variable to something else :) Thanks, Eric Springer From boris at codesynthesis.com Tue Aug 23 10:09:47 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 23 10:12:19 2011 Subject: [xsd-users] Please don't use 'override' as a variable name In-Reply-To: References: Message-ID: Hi Eric, Eric Springer writes: > One issue I'm have with XSD is the use of "override" in a couple places, Fixed, thanks for reporting this! If you would like a patch, you can get it here: http://scm.codesynthesis.com/?p=xsd/xsd.git;a=commit;h=f167e58e1bc3959f32da890022cccfa51f2c73ec We will also do a more careful check for C++-0x keywords before the next release. Boris From erikina at gmail.com Tue Aug 23 19:23:54 2011 From: erikina at gmail.com (Eric Springer) Date: Tue Aug 23 19:32:32 2011 Subject: [xsd-users] Please don't use 'override' as a variable name In-Reply-To: References: Message-ID: On Wed, Aug 24, 2011 at 12:09 AM, Boris Kolpackov wrote: > Fixed, thanks for reporting this! If you would like a patch, you can get > it here: Thanks! Appreciate it :) From ppontheweb.hi at gmail.com Thu Aug 25 10:54:38 2011 From: ppontheweb.hi at gmail.com (Prashant Parashar) Date: Thu Aug 25 10:59:52 2011 Subject: [xsd-users] Issue with xml_schema::document.parse Message-ID: Hi all, I am using Code Synthesis XSD 3.3. While working with this library I am facing a strange problem i.e. when I run the program from the IDE(VS2005) this function works fine and when I run the exe of the program it fails. All the parameters are same in both the cases. Please help me in solving this issue. Looking forward for your replies. Thanks in advance PPontheweb From boris at codesynthesis.com Fri Aug 26 11:02:59 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 26 11:05:30 2011 Subject: [xsd-users] Issue with xml_schema::document.parse In-Reply-To: References: Message-ID: Hi Prashant, Prashant Parashar writes: > I am using Code Synthesis XSD 3.3. While working with this library I am > facing a strange problem i.e. when I run the program from the IDE(VS2005) > this function works fine and when I run the exe of the program it fails. All > the parameters are same in both the cases. How does the function fail? Does it throw an exception? Or does it crash? Maybe when you are running your executable manually, you run it from a different working directory, and the XML file you are trying to parse cannot be found? There could hundreds of different reasons and without more information we can only guess. Boris From rc.mail.dev at gmail.com Mon Aug 29 03:38:48 2011 From: rc.mail.dev at gmail.com (Romain) Date: Mon Aug 29 03:38:56 2011 Subject: [xsd-users] problem in example provided in cxx/tree/binary/boost Message-ID: Hi, I have noticed a difference between the latest version (3.3) and the previous version (3.2) in the example given for the binary serialization using Boost. In the files boost-archive-extraction.hxx and boost-archive-insertion.hxx, the operator >> and << for the extraction / insertion of a binary buffer does not return anything. Could anyone tell me why? (the example given in 3.2 did include a return statement). Thank you for your help. Regards, Romain From boris at codesynthesis.com Mon Aug 29 03:55:54 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 29 03:58:26 2011 Subject: [xsd-users] problem in example provided in cxx/tree/binary/boost In-Reply-To: References: Message-ID: Hi Romain, Romain writes: > In the files boost-archive-extraction.hxx and boost-archive-insertion.hxx, > the operator >> and << for the extraction / insertion of a binary buffer > does not return anything. That's a bug, that is now fixed in master: http://scm.codesynthesis.com/?p=xsd/xsd.git;a=commit;h=48374dd6056032ae9b3dfd8408634dcec5f298ec Thanks for reporting this! Boris From Vaughan at Roberts.name Mon Aug 29 01:19:28 2011 From: Vaughan at Roberts.name (Vaughan Roberts) Date: Mon Aug 29 06:11:35 2011 Subject: [xsd-users] cxx-parser and optional element or attribute Message-ID: <001501cc660b$3c524600$b4f6d200$@Roberts.name> I have been using cxx-parser to parse an xml document which has a number of optional elements and attributes. My problem seems to be that if the optional element is not present I still get the previous value of the element returned. I note that cxx-tree has calls such as: bar.foo().present() to help determine whether an optional element is present and bar.foo().get() and bar.foo().reset() functions to deal with them, however I have not been able to find any reference to these types of functions in cxx-parser. How do you handle optional elements in cxx-parser? Here is a snippet from my .xsd file. It is the optional elements: fielder and assist that I am having trouble with at the moment. If they are provided for a Ball, they only relate to that Ball and should be reset afterwards. What I seem to be getting at the moment is that there is nothing until the first time they have a value and then that value is returned for all subsequent Balls. Best regards, Vaughan Mob: 0412 122 362 From victor.manoliu at yahoo.com Mon Aug 29 04:35:51 2011 From: victor.manoliu at yahoo.com (Adrian Victor Manoliu) Date: Mon Aug 29 06:14:07 2011 Subject: [xsd-users] CityGML deserialization - tag In-Reply-To: References: Message-ID: <1314606951.48311.YahooMailNeo@web45509.mail.sp1.yahoo.com> Hello, It works, thank you for your help ! Victor ________________________________ From: Pavel Pohanka To: victor.manoliu@yahoo.com Cc: xsd-users@codesynthesis.com Sent: Monday, May 2, 2011 9:59 AM Subject: Re: [xsd-users] CityGML deserialization - tag Hallo Adrian Victor Manoliu writes: > To sum up what I've written below (in case you don't ?have the time to > read everything), the CityGML serialization works, however one ?tag is > not generated properly - is always replaced by > , perhaps a problem caused by substitution groups. I had same problem some time ago and Boris explained it to me. The problem is really caused by substitution groups, because generated code looks for the first substituting element. You have to write the following code in order to include cityObjectMember: citygml::CityModelType city_model; gml::FeaturePropertyType city_object_member; city_object_member._name ("cityObjectMember"); city_object_member._namespace ("http://www.opengis.net/citygml/1.0"); Then you can write whatever object you like: city_object_member._Feature(some_type); city_model.featureMember().push_back(city_object_member); Ciao, Pavel From boris at codesynthesis.com Mon Aug 29 06:31:35 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 29 06:34:08 2011 Subject: [xsd-users] cxx-parser and optional element or attribute In-Reply-To: <001501cc660b$3c524600$b4f6d200$@Roberts.name> References: <001501cc660b$3c524600$b4f6d200$@Roberts.name> Message-ID: Hi Vaughan, Vaughan Roberts writes: > I have been using cxx-parser to parse an xml document which has a number of > optional elements and attributes. My problem seems to be that if the > optional element is not present I still get the previous value of the > element returned. > > [...] > > > > [...] > > It is the optional elements: fielder and assist that I am having trouble > with at the moment. If they are provided for a Ball, they only relate to > that Ball and should be reset afterwards. What I seem to be getting at the > moment is that there is nothing until the first time they have a value and > then that value is returned for all subsequent Balls. In C++/Parser, for optional elements (and attributes) that are not present, the corresponding callback function is simply not called. I tries to reproduce your problem using the library example. This examples has the died element which is optional. I modified the sample library.xml file by removing this element from the second book entry. However, the example still works as expected; I don't get the date of death for the second book and get the correct values for the first and third. Perhaps what happens in your case is that you do not clear the data member that is used to store the optional element. As a result, when the element is missing (and the callback is not called), it appears as if the old value was specified. The place to clear such optional (and container) values is in the _pre() callback. We do this for the died element in the library example. Check library-pimpl.cxx, line 60. Boris From ledunkang at 163.com Mon Aug 29 09:27:50 2011 From: ledunkang at 163.com (lEdUnkAnG) Date: Mon Aug 29 09:27:58 2011 Subject: [xsd-users] How to export class with given namespace by CodeSynthesis XSD? Message-ID: <47fa313.c71e.13215b97da8.Coremail.ledunkang@163.com> In my project I've many XSD files in following format, file1.xsd ---- file2.xsd ---- Because the root elements of these XSD files have same name ''REQUEST'', Code Synthesis XSD generates two C++ classes with same class name,REQUEST. To avoid name-duplicating problem, I've to add namespace manually to generated C++ classes in file1.cxx/hxx and file2.cxx/hxx files. And it works. What I'm wondering is that whether there is any convenient method to put generated C++ class in given namespace by XSD command line options. Any help will be appreciated. Thanks in advance! From boris at codesynthesis.com Mon Aug 29 13:08:29 2011 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 29 13:11:01 2011 Subject: [xsd-users] How to export class with given namespace by CodeSynthesis XSD? In-Reply-To: <47fa313.c71e.13215b97da8.Coremail.ledunkang@163.com> References: <47fa313.c71e.13215b97da8.Coremail.ledunkang@163.com> Message-ID: Hi, lEdUnkAnG writes: > To avoid name-duplicating problem, I've to add namespace manually to > generated C++ classes in file1.cxx/hxx and file2.cxx/hxx files. And it > works. > > What I'm wondering is that whether there is any convenient method to put > generated C++ class in given namespace by XSD command line options. Yes, there is. It is called --namespace-map. In your case you would use it like this: ... --namespace-map =ns1 file1.xsd ... --namespace-map =ns2 file2.xsd The empty XML Schema namespace before the equal sign is used to indicate that we are dealing with a schema without a target namespace (just like yours). Boris From eric.keller.ek1 at roche.com Wed Aug 31 11:28:28 2011 From: eric.keller.ek1 at roche.com (Keller, Eric) Date: Wed Aug 31 12:30:32 2011 Subject: [xsd-users] [xsd/cxx/tree/serialization/{float, double}.hxx] warning: comparing floating point with == or != is unsafe Message-ID: Hi everyone, while compiling xsd generated code, the following files: xsd/cxx/tree/serialization/float.hxx:35:37 xsd/cxx/tree/serialization/double.hxx:33:35:37:85 throw a warning using our actual gcc version. warning: comparing floating point with == or != is unsafe unfortunately the gcc version we are using to compile, has some issue with the #pragma GCC diagnostic push/ignored/pop so disabling these warning is currently not possible... could you please give me some feedback how I should suppress this warning? Xsd version: 3.2.0 Compiler version: gcc 4.4.3 Best regards -- Eric Keller