From boris at codesynthesis.com Thu May 1 04:04:10 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Creating elements in code In-Reply-To: <4aeb04aa0804300656v104b96d3p34788241391a2692@mail.gmail.com> References: <4aeb04aa0804300656v104b96d3p34788241391a2692@mail.gmail.com> Message-ID: <20080501080410.GA19546@karelia> Hi Attila, Attila writes: > targetNamespace="http://www.w3schools.com" > xmlns="http://www.w3schools.com" > elementFormDefault="qualified"> > > > > > > > > > > > > > > > > > > > > > > > Can I provide an XML snippet instead of an entire XML document > like this: > > > jon > rick > hello world > no text > First, it is helpful to distinguish between valid and invalid XML fragments according to the schema. For example, the above fragment is invalid because all the elements in this XML are unqualified while the schema prescribes that they all should be in the "http://www.w3schools.com" namespace. Here is a similar but valid fragment: jon rick hello world no text Not surprisingly handling invalid XML documents with the generated code is tricky. The missing namespace declaration problem pops up from time to time and there are a few techniques that can be used as described in the following recent discussion: http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001587.html http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001589.html http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001593.html Note that from the two methods described in the last message, only the second one will work for your case (the first won't work because all your inner elements are also qualified). In the second method you also don't need to search for the closing tag of the root element. All you need to do is replace the beginning of the root element ( n = note_("noteSnippet.xml"); > Furthermore, could I then take these snippets and use it to construct > a complete XML document? I am not sure what you mean by a "complete XML document". Any valid according to the schema XML document is complete. Boris From ivan at mapsoft.co.yu Thu May 1 09:29:44 2008 From: ivan at mapsoft.co.yu (=?US-ASCII?B?SXZhbiBNYXJrb3ZpYw==?=) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Unsubscribe In-Reply-To: <200804301600.m3UG05Tb032421@codesynthesis.com> References: <200804301600.m3UG05Tb032421@codesynthesis.com> Message-ID: <1209648584535@ivan_mapsoft.co.yu> Unsubscribe. Thanks From jnw at xs4all.nl Thu May 1 08:45:33 2008 From: jnw at xs4all.nl (Jeroen N. Witmond [Bahco]) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Unsubscribe Message-ID: <20881.194.109.230.85.1209645933.squirrel@webmail.xs4all.nl> Ivan Markovic > Unsubscribe. Thanks > > To unsubscribe, you can visit http://codesynthesis.com/mailman/listinfo/xsd-users and follow the instructions at the bottom of that page. Cheers! Jeroen. From drhvm at us.ibm.com Fri May 2 10:27:01 2008 From: drhvm at us.ibm.com (Denny Hatzenbihler) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] problem with xerces namespace Message-ID: I am using the xsd to convert schema's to .hxx and .cxx. The problem i am hitting is the xerces namespace used by the xsd tool (xercesc::) does not match the xerces namespace used by the rest of the code that will be using the generated C++ classes/headers (xercesc_2_7::). Is there a way to change the xerces namespace used by the xsd tool so that it would match the versioned one? From boris at codesynthesis.com Fri May 2 12:58:02 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] problem with xerces namespace In-Reply-To: References: Message-ID: <20080502165802.GA1946@karelia> Hi Denny, Denny Hatzenbihler writes: > I am using the xsd to convert schema's to .hxx and .cxx. The problem i am > hitting is the xerces namespace used by the xsd tool (xercesc::) does not > match the xerces namespace used by the rest of the code that will be using > the generated C++ classes/headers (xercesc_2_7::). The xercesc namespace is defined as an alias for the versioned one (from xercesc/util/XercesDefs.hpp): namespace xercesc = xercesc_2_7; Thus it is possible to use the two interchangeably. What exactly happens? Do you get compile or link errors? Boris From Dave at Yost.com Fri May 2 19:45:07 2008 From: Dave at Yost.com (Dave Yost) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] xsd examples Message-ID: Problem #1 It would be nice to have an example directory that has the hello world example in it and a makefile. I was able to generate C++ from my schema, but when I tried to compile it and a simple main to use it (adapted from the helloworld example in the doc), I couldn't compile it. Problem #2: 0 1333 Z% pwd /Users/yost/Downloads/Incoming/xsd-3.1.0-i686-macosx/examples Fri 16:41:48 ip2 yost /Users/yost/Downloads/Incoming/xsd-3.1.0-i686-macosx/examples 0 1334 Z% make | head make -C cxx g++ -I../../../../libxsd -W -Wall -c library-driver.cxx -o library-driver.o In file included from library-pskel.hxx:79, from library-pimpl.hxx:11, from library-driver.cxx:8: ../../../../libxsd/xsd/cxx/parser/xerces/elements.hxx:14:35: error: xercesc/sax/Locator.hpp: No such file or directory ../../../../libxsd/xsd/cxx/parser/xerces/elements.hxx:15:39: error: xercesc/sax/InputSource.hpp: No such file or directory ../../../../libxsd/xsd/cxx/parser/xerces/elements.hxx:16:42: error: xercesc/sax2/SAX2XMLReader.hpp: No such file or directory ../../../../libxsd/xsd/cxx/parser/xerces/elements.hxx:17:43: error: xercesc/sax2/DefaultHandler.hpp: No such file or directory In file included from ../../../../libxsd/xsd/cxx/parser/xerces/elements.hxx:19, from library-pskel.hxx:79, from library-pimpl.hxx:11, from library-driver.cxx:8: ../../../../libxsd/xsd/cxx/xml/elements.hxx:11:42: error: xercesc/util/PlatformUtils.hpp: No such file or directory In file included from ../../../../libxsd/xsd/cxx/parser/xerces/elements.hxx:449, from library-pskel.hxx:79, from library-pimpl.hxx:11, from library-driver.cxx:8: [etc/] make[3]: *** [library-driver.o] Error 1 make[2]: *** [generated] Error 2 make[1]: *** [parser] Error 2 make: *** [cxx] Error 2 Fri 16:41:54 ip2 yost /Users/yost/Downloads/Incoming/xsd-3.1.0-i686-macosx/examples 0 1335 Z% Thanks Dave From boris at codesynthesis.com Sat May 3 14:53:57 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] xsd examples In-Reply-To: References: Message-ID: <20080503185357.GA5198@karelia> Hi Dave, Dave Yost writes: > It would be nice to have an example directory that has the hello > world example in it and a makefile. There is such a directory (called examples/) and there are the "hello world" examples for both C++/Tree and C++/Parser mappings (see examples/cxx/parser/hello/ and examples/cxx/tree/hello/). They also include makefiles for building them. Plus there is the README file accompanying every distribution that explains what you need and how to build examples. > ../../../../libxsd/xsd/cxx/parser/xerces/elements.hxx:14:35: error: > xercesc/sax/Locator.hpp: No such file or directory The generated code depends on the underlying XML parser which can be Xerces-C++ for C++/Tree and Xerces-C++ or Expat for C++/Parser. See the accompanying README file for more information. You can get the source distribution or precompiled libraries of Xerces-C++ from the project's download page: http://xerces.apache.org/xerces-c/download.cgi Boris From boris at codesynthesis.com Sat May 3 15:07:33 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] problem with xerces namespace In-Reply-To: References: <20080502165802.GA1946@karelia> Message-ID: <20080503190733.GB5198@karelia> Hi Denny, [I've CC'ed xsd-users to my reply since others may encounter a similar problem in the future.] Denny Hatzenbihler writes: > I am now getting another error when I include a xsd generated header file > jdl.hxx which includes xsd/cxx/tree/parsing.hxx > > Do you have any idea what is causing this failure? > > In file included from ./Common/include/xsd/cxx/tree/parsing.hxx:9, > from ./Common/include/jdl.hxx:66, > from Common/src/PEDesc.cpp:158: > ./Common/include/xsd/cxx/tree/parsing.txx:227:38: macro "X" passed 4 > arguments, but takes just 1 > ./Common/include/xsd/cxx/tree/parsing.txx:241:38: macro "X" passed 4 > arguments, but takes just 1 You seem to define a macro called X (probably for handling XMLCh to char conversions) which interferes with template arguments used in the XSD runtime headers. I've ran into the same problem[1] with XQilla not long ago. The way to get rid of this problem is to make sure that you include the header that defines the X macro after you include the generated headers. We will also use a different name for this template argument in the future releases of XSD seeing that it is causing problems. If you would like I can send you the XSD runtime with this change. [1] http://sourceforge.net/mailarchive/message.php?msg_name=20080411090336.GB25596%40karelia Boris From jnw at xs4all.nl Mon May 5 15:45:00 2008 From: jnw at xs4all.nl (Jeroen N. Witmond [Bahco]) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] cxx-parser: include directive in --type-map file is ignored Message-ID: <16420.194.109.230.85.1210016700.squirrel@webmail.xs4all.nl> Greetings, I've stumbled across a strange problem: It seems that include directives in --type-map files are ignored. For instance, when I add 'include "blahblah.hpp";' at the top of file parser-anytype/w3.org-xml-1998.map [1], the generated code does not change. No '#include' statement is added. Regeneration of the code does not result in any messages. This happens both in version 3.0.0 and in version 3.1.0.b3 of xsd. Regards, Jeroen. [1] http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/parser.html From boris at codesynthesis.com Mon May 5 16:15:11 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] cxx-parser: include directive in --type-map file is ignored In-Reply-To: <16420.194.109.230.85.1210016700.squirrel@webmail.xs4all.nl> References: <16420.194.109.230.85.1210016700.squirrel@webmail.xs4all.nl> Message-ID: <20080505201511.GA11663@karelia> Hi Jeroen, Jeroen N. Witmond [Bahco] writes: > For instance, when I add 'include "blahblah.hpp";' at the top of file > parser-anytype/w3.org-xml-1998.map [1], the generated code does not > change. You need to add the include directive in the namespace block (constructs at the top level are applied to schemas without target namespace). For example, I tried this type map: namespace "http://www.w3.org/XML/1998/namespace" { include "foo.hxx"; lang std::string; space std::string; } And got #include "foo.hxx" in the generated header file. Boris From jnw at xs4all.nl Tue May 6 13:09:47 2008 From: jnw at xs4all.nl (Jeroen N. Witmond [Bahco]) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] cxx-parser: include directive in --type-map file is ignored Message-ID: <13832.194.109.230.85.1210093787.squirrel@webmail.xs4all.nl> Hi Boris, "Boris Kolpackov" wrote: > You need to add the include directive in the namespace block (constructs > at the top level are applied to schemas without target namespace). Thanks! Jeroen. From atteeela at gmail.com Tue May 6 14:42:44 2008 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Creating elements in code In-Reply-To: <20080501080410.GA19546@karelia> References: <4aeb04aa0804300656v104b96d3p34788241391a2692@mail.gmail.com> <20080501080410.GA19546@karelia> Message-ID: <4aeb04aa0805061142g12c215d6sb8ae903fc5866af4@mail.gmail.com> Hi Boris, I greatly appreciate your response and it provides me with a good starting point for further research. Maybe I'll provide a little background as to why I am asking all this :) We currently have an application that uses simple-line-based configuration files (flat config) and would like to convert it over to XML. Furthermore we have an automation interface that allows users to send configuration entries over TCP to dynamically replace the contents of the flat file and then have these settings become effective. What I was thinking was to have the parsed CS XSD objects as the "configuration collection" underneath and then be able to use webservices or something to dynamically replace the CS XSD objects. So if someone sends a command to replace element "foo", then I could just parse this element, and then use it to replace the foo element in my configuration collection underneath. Furthermore, will I be able to potentially "build up" a "more complete" configuration file (defined by say mytoolConfig.xsd) and then write it out to an instance document: configsnapshot.xml? Also: will the CS XSD parser restrict how many instances I can have of say "foo" if my mytoolConfig.xsd says I can only have 1 instance? Or will this only be restricted if I choose to write it out to an XSD/validate it? Thank you, On Thu, May 1, 2008 at 4:04 AM, Boris Kolpackov wrote: > Hi Attila, > > Attila writes: > > > > targetNamespace="http://www.w3schools.com" > > xmlns="http://www.w3schools.com" > > elementFormDefault="qualified"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Can I provide an XML snippet instead of an entire XML document > > like this: > > > > > > jon > > rick > > hello world > > no text > > > > First, it is helpful to distinguish between valid and invalid XML > fragments according to the schema. For example, the above fragment > is invalid because all the elements in this XML are unqualified > while the schema prescribes that they all should be in the > "http://www.w3schools.com" namespace. Here is a similar but valid > fragment: > > > jon > rick > hello world > no text > > > Not surprisingly handling invalid XML documents with the generated > code is tricky. The missing namespace declaration problem pops up > from time to time and there are a few techniques that can be used > as described in the following recent discussion: > > http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001587.html > http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001589.html > http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001593.html > > Note that from the two methods described in the last message, only > the second one will work for your case (the first won't work because > all your inner elements are also qualified). In the second method you > also don't need to search for the closing tag of the root element. All > you need to do is replace the beginning of the root element ( with the same element plus the default namespace declaration > ( > Now let's assume that you are trying to parse a valid XML document. > The XML Schema specification prescribes that only non-abstract > globally-defined elements can be XML document roots. In the above > schema that would be 'note' and 'foo'. For each such element, the > XSD compiler generates a set of parsing functions that can be used > to parser the corresponding XML into the object model. So in your > case, provided noteSnippet.xml contains a valid according to the > schema XML document, you can write: > > auto_ptr n = note_("noteSnippet.xml"); > > > > Furthermore, could I then take these snippets and use it to construct > > a complete XML document? > > I am not sure what you mean by a "complete XML document". Any valid > according to the schema XML document is complete. > > Boris > -- Attila Software Developer atteeela@gmail.com From boris at codesynthesis.com Tue May 6 16:05:04 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Creating elements in code In-Reply-To: <4aeb04aa0805061142g12c215d6sb8ae903fc5866af4@mail.gmail.com> References: <4aeb04aa0804300656v104b96d3p34788241391a2692@mail.gmail.com> <20080501080410.GA19546@karelia> <4aeb04aa0805061142g12c215d6sb8ae903fc5866af4@mail.gmail.com> Message-ID: <20080506200504.GB22228@karelia> Hi Attila, Attila writes: > What I was thinking was to have the parsed CS XSD objects as the > "configuration collection" underneath and then be able to use > webservices or something to dynamically replace the CS XSD objects. > > So if someone sends a command to replace element "foo", then I could just > parse this element, and then use it to replace the foo element in my > configuration collection underneath. Furthermore, will I be able to > potentially "build up" a "more complete" configuration file (defined by say > mytoolConfig.xsd) and then write it out to an instance document: > configsnapshot.xml? Yes, this would be pretty straightforward as long as both the the complete configuration file and the fragments that you receive are valid (according to the schema) XML documents. To give you an example, suppose you have a third element in your schema that describes the "complete" configuration: You can then do the following: auto_ptr c = config_ ("complete-config.xml"); // Receive a note fragment. // auto_ptr n = note_ ("note.xml"); // Replace the note fragment in the config with the one we just received. // c->note (*n); > Also: will the CS XSD parser restrict how many instances I can have of say > "foo" if my mytoolConfig.xsd says I can only have 1 instance? If the cardinality of a local element is 1 (e.g., note or foo in the above config) then the generated interface simply won't allow you to have more then one instance in the object model. Once you set the new value as in the last line above, the previous value is gone. Boris From atteeela at gmail.com Wed May 7 14:49:53 2008 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] XSD and XPath Message-ID: <4aeb04aa0805071149x7a17e2c3pd3531506b1dc123f@mail.gmail.com> Hi, I am wondering if it is possible to use XPath expressions against an XSD object model to obtain a particular node. I know that I could do XPath queries against an instance document and then convert to object model, but that is too expensive. Another question is: Will the object model be populated with the defaults specified in the schema if the elements/attributes are not present in an instance document? Thanks, -- Attila Software Developer atteeela@gmail.com From sbalasub at qualcomm.com Thu May 8 18:25:00 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] xml-schema.h Message-ID: Hi, I have a question about where the xml-schema.h should reside. IMO, the file consists of the of the fundamental type declarations for xml-schema and should be rolled with XSD rpm which has files related with xsd/cxx/tree/... In our project, we have two separate libraries both have xml-schema generation. So if the application uses these two libraries we have a duplicate declaration issues. May I know the reason why this is not part of XSD (for example xsd/core/xml-schema.h or xsd/xml-schema.h)? Thanks, Shiva From boris at codesynthesis.com Fri May 9 08:17:28 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] XSD and XPath In-Reply-To: <4aeb04aa0805071149x7a17e2c3pd3531506b1dc123f@mail.gmail.com> References: <4aeb04aa0805071149x7a17e2c3pd3531506b1dc123f@mail.gmail.com> Message-ID: <20080509121728.GC3294@karelia> Hi Attila, Attila writes: > I am wondering if it is possible to use XPath expressions against an XSD > object model to obtain a particular node. > I know that I could do XPath queries against an instance document and then > convert to object model, but that is too expensive. XPath can be used together with the DOM document association feature. This feature allows you to maintain bidirectional association with DOM and object model nodes. You can then execute XPath queries on the underlying DOM document, obtain resulting DOM node(s), resolve associated object model nodes and handle the result using the more convenient object model. In fact, in the next release of XSD we will include an example on how to to this. For the current release you can download this example via this link: http://codesynthesis.com/~boris/tmp/xpath.tar.gz Note also that the above approach has a number of limitations: the DOM association is created only when you parse an XML document to the object model and underlying DOM nodes do not automatically reflect changes made to the object model and vice versa. For more information on DOM association see Section 5.1, "DOM Association" in the C++/Tree Mapping User Manual: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#5.1 > Another question is: Will the object model be populated with the defaults > specified in the schema if the elements/attributes are not present in an > instance document? If XML Schema validation is enabled in Xerces-C++ then default values for both attributes and elements are automatically assigned in DOM and in the object model. If XML Schema validation is disabled then the generated code assigns default values for attributes (elements with default values are quite inconvenient and therefore are not widely used, I don't remember ever seeing a practical schema using them). Note also that there will be no default attributes or elements in DOM with this setup. Boris From atteeela at gmail.com Fri May 9 08:47:21 2008 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] XSD and XPath In-Reply-To: <20080509121728.GC3294@karelia> References: <4aeb04aa0805071149x7a17e2c3pd3531506b1dc123f@mail.gmail.com> <20080509121728.GC3294@karelia> Message-ID: <4aeb04aa0805090547q73f8d102rcd8d6074155e226@mail.gmail.com> Thanks Boris, On Fri, May 9, 2008 at 8:17 AM, Boris Kolpackov wrote: > Hi Attila, > > Attila writes: > > > I am wondering if it is possible to use XPath expressions against an XSD > > object model to obtain a particular node. > > I know that I could do XPath queries against an instance document and > then > > convert to object model, but that is too expensive. > > XPath can be used together with the DOM document association feature. > This feature allows you to maintain bidirectional association with > DOM and object model nodes. You can then execute XPath queries on > the underlying DOM document, obtain resulting DOM node(s), resolve > associated object model nodes and handle the result using the more > convenient object model. In fact, in the next release of XSD we will > include an example on how to to this. For the current release you > can download this example via this link: > > http://codesynthesis.com/~boris/tmp/xpath.tar.gz > > Note also that the above approach has a number of limitations: the > DOM association is created only when you parse an XML document to > the object model and underlying DOM nodes do not automatically > reflect changes made to the object model and vice versa. For more > information on DOM association see Section 5.1, "DOM Association" > in the C++/Tree Mapping User Manual: > > http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#5.1 > > > > Another question is: Will the object model be populated with the > defaults > > specified in the schema if the elements/attributes are not present in an > > instance document? > > If XML Schema validation is enabled in Xerces-C++ then default values for > both attributes and elements are automatically assigned in DOM and in the > object model. > > If XML Schema validation is disabled then the generated code assigns > default values for attributes (elements with default values are quite > inconvenient and therefore are not widely used, I don't remember ever > seeing a practical schema using them). Note also that there will be no > default attributes or elements in DOM with this setup. > > Boris > -- Attila Software Developer atteeela@gmail.com From boris at codesynthesis.com Fri May 9 08:52:00 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] xml-schema.h In-Reply-To: References: Message-ID: <20080509125200.GD3294@karelia> Hi Shiva, Balasubramanyam, Shivakumar writes: > IMO, the file consists of the of the fundamental type declarations for > xml-schema and should be rolled with XSD rpm which has files related > with xsd/cxx/tree/... > > May I know the reason why this is not part of XSD (for example > xsd/core/xml-schema.h or xsd/xml-schema.h)? The contents of this file depend on the way you generated the code. Some things that affect it: character type (char/wchar_t), whether parsing/serialization is enabled (if it is then some extra aliases are added), binary serialization, etc. Plus it is possible to customize the built-in types which is captured in the generated xml-schema.h. This makes it impossible to package it with with the XSD distribution itself. > In our project, we have two separate libraries both have xml-schema > generation. So if the application uses these two libraries we have a > duplicate declaration issues. If your libraries can use the same xml-schema.h (e.g., the XSD command lines use similar options) then you can factor the xml-schema.h file into a separate (perhaps header-only) library which both of your other libraries use. Alternatively, you can keep separate xml-schema.h files (you can either use different names or include them with directory prefixes, e.g., foo/xml-schema.h and bar/xml-schema.h). Plus you will need to change the namespaces that they use for xml_schema. One approach would be to nest the xml_schema namespace into your library namespace. For example, if you have two libraries, libfoo and libbar, and they use foo and bar C++ namespaces respectively, then you can do the following: $ xsd cxx-tree --generate-xml-schema --namespace-map \ http://www.w3.org/2001/XMLSchema=foo::xml_schema foo/xml-schema.xsd $ xsd cxx-tree --generate-xml-schema --namespace-map \ http://www.w3.org/2001/XMLSchema=bar::xml_schema bar/xml-schema.xsd Then foo/xml-schema.h will look like this: namespace foo { namespace xml_schema { ... } } Boris From sbalasub at qualcomm.com Fri May 9 12:36:39 2008 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] xml-schema.h In-Reply-To: <20080509125200.GD3294@karelia> References: <20080509125200.GD3294@karelia> Message-ID: Boris, thanks a lot for your suggestions. -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Friday, May 09, 2008 5:52 AM To: Balasubramanyam, Shivakumar Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] xml-schema.h Hi Shiva, Balasubramanyam, Shivakumar writes: > IMO, the file consists of the of the fundamental type declarations for > xml-schema and should be rolled with XSD rpm which has files related > with xsd/cxx/tree/... > > May I know the reason why this is not part of XSD (for example > xsd/core/xml-schema.h or xsd/xml-schema.h)? The contents of this file depend on the way you generated the code. Some things that affect it: character type (char/wchar_t), whether parsing/serialization is enabled (if it is then some extra aliases are added), binary serialization, etc. Plus it is possible to customize the built-in types which is captured in the generated xml-schema.h. This makes it impossible to package it with with the XSD distribution itself. > In our project, we have two separate libraries both have xml-schema > generation. So if the application uses these two libraries we have a > duplicate declaration issues. If your libraries can use the same xml-schema.h (e.g., the XSD command lines use similar options) then you can factor the xml-schema.h file into a separate (perhaps header-only) library which both of your other libraries use. Alternatively, you can keep separate xml-schema.h files (you can either use different names or include them with directory prefixes, e.g., foo/xml-schema.h and bar/xml-schema.h). Plus you will need to change the namespaces that they use for xml_schema. One approach would be to nest the xml_schema namespace into your library namespace. For example, if you have two libraries, libfoo and libbar, and they use foo and bar C++ namespaces respectively, then you can do the following: $ xsd cxx-tree --generate-xml-schema --namespace-map \ http://www.w3.org/2001/XMLSchema=foo::xml_schema foo/xml-schema.xsd $ xsd cxx-tree --generate-xml-schema --namespace-map \ http://www.w3.org/2001/XMLSchema=bar::xml_schema bar/xml-schema.xsd Then foo/xml-schema.h will look like this: namespace foo { namespace xml_schema { ... } } Boris From david.r.moss at selex-comms.com Tue May 13 05:42:17 2008 From: david.r.moss at selex-comms.com (david.r.moss@selex-comms.com) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Code generation fails for schemas with large maxOccurs values In-Reply-To: <20080509125200.GD3294@karelia> Message-ID: Hi, We're working with some third-party schemas that define large (not 'unbounded') maxOccurs values for sequences. When compiling the schemas, no code is generated, although the build step reports no errors. A test schema that recreates the problem is as follows: It is compiled for cxx-tree with no additional command line options using XSD version 3.0.0. No code is generated when maxOccurs="9957" or greater and when it's a smaller "large" number the code generation takes a very (very) long time. I realise that in general this is bad practise as XML validation is slow with large bounds as mentioned in this previous post: http://codesynthesis.com/pipermail/xsd-users/2007-February/000812.html but surely the code generation should still work - we may well be stuck with these schemas. I've also tried the same example with XSD version 3.1.0 and this time the limit seems to be when maxOccurs="9949" or greater that no code is generated! Cheers, Dave. Dave Moss SELEX Communications Grange Road Christchurch Dorset BH23 4JE United Kingdom Tel: + 44 (0) 1202 404841 Email: david.r.moss@selex-comms.com ------------------------------------------------------------ This email and any attached files contains company confidential information which may be legally privileged. It is intended only for the person(s) or entity to which it is addressed and solely for the purposes set forth therein. If you are not the intended recipient or have received this email in error please notify the sender by return, delete it from your system and destroy any local copies. It is strictly forbidden to use the information in this email including any attachment or part thereof including copying, disclosing, distributing, amending or using for any other purpose. In addition the sender excludes all liabilities (whether tortious or common law) for damage or breach arising or related to this email including but not limited to viruses and libel. SELEX Communications Limited is a Private Limited Company registered in England and Wales under Company Number 964533 and whose Registered Office is Marconi House, New Street, CHELMSFORD, Essex. CM1 1PL. England. From boris at codesynthesis.com Tue May 13 08:01:52 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Code generation fails for schemas with large maxOccurs values In-Reply-To: References: <20080509125200.GD3294@karelia> Message-ID: <20080513120152.GA29662@karelia> Hi David, david.r.moss@selex-comms.com writes: > No code is generated when maxOccurs="9957" or greater and when it's a > smaller "large" number the code generation takes a very (very) long time. > I realise that in general this is bad practise as XML validation is slow > with large bounds as mentioned in this previous post: > > http://codesynthesis.com/pipermail/xsd-users/2007-February/000812.html > > but surely the code generation should still work - we may well be stuck > with these schemas. The XSD compiler uses Xerces-C++ underneath to validate the schemas being compiled. As a result, the same problem with maxOccurs exists when compiling a schema as when validating an instance against it. At the moment the only work around for this problem that I can think of is to change large maxOccurs values to unbounded. The generated code is the same when maxOccurs > 1 and when it is unbounded. You also need to do this if you need validation of the instance. In this case you may have to enforce large maxOccurs constrains in the application. I will also check with the Xerces-C++ developers to see if there is any chance of fixing this problem for the Xerces-C++ 3.0.0 release (last time I checked it required some serious architectural changes). Boris From boris at codesynthesis.com Tue May 13 10:33:53 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Code generation fails for schemas with large maxOccurs values In-Reply-To: <20080513120152.GA29662@karelia> References: <20080509125200.GD3294@karelia> <20080513120152.GA29662@karelia> Message-ID: <20080513143353.GG29662@karelia> Hi David, Boris Kolpackov writes: > I will also check with the Xerces-C++ developers to see if there is > any chance of fixing this problem for the Xerces-C++ 3.0.0 release > (last time I checked it required some serious architectural changes). I spoke to one of the Xerces-C++ developers who tried to implement a solution for this problem. It did not work for all cases at that time but we agreed that we will try to get this solution into shape for the 3.0.0 release. If this does not work out then we will implement the "treat large maxOccurs as unbounded" hack for the time being (this is what Xerces-J apparently does). You can track the progress of this bug here: https://issues.apache.org/jira/browse/XERCESC-1051 Boris From gkr at as-guides.com Tue May 13 13:36:21 2008 From: gkr at as-guides.com (Gordon Kramer) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 35, Issue 9 Re: Code generation fails for schemas with large maxOccurs values (Boris Kolpackov) In-Reply-To: <200805131600.m4DG04lN023253@codesynthesis.com> References: <200805131600.m4DG04lN023253@codesynthesis.com> Message-ID: <1210700181.8895.39.camel@asdtvg-desktop-server> Hi all, Am Dienstag, den 13.05.2008, 12:00 -0400 schrieb xsd-users-request@codesynthesis.com: > Hi David, > > david.r.moss@selex-comms.com writes: > > > No code is generated when maxOccurs="9957" or greater and when it's a > > smaller "large" number the code generation takes a very (very) long time. > > I realise that in general this is bad practise as XML validation is slow > > with large bounds as mentioned in this previous post: > > > > http://codesynthesis.com/pipermail/xsd-users/2007-February/000812.html > > > > but surely the code generation should still work - we may well be stuck > > with these schemas. > > The XSD compiler uses Xerces-C++ underneath to validate the schemas > being compiled. As a result, the same problem with maxOccurs exists > when compiling a schema as when validating an instance against it. > You also need to do this if you need validation of the instance. In > this case you may have to enforce large maxOccurs constrains in the > application. > Would it be a big problem to implement code generation for enforcing maxOccurs>1 outside xercesc validation ? Maybe adding the maxOccurs constraint as a template parameter to sequence ? This would also help enforcing the constraint when programatically adding elements to the sequence. Best Regards, Gordon -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20080513/1e6729ec/attachment.pgp From david.r.moss at selex-comms.com Tue May 13 12:14:51 2008 From: david.r.moss at selex-comms.com (david.r.moss@selex-comms.com) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Code generation fails for schemas with large maxOccurs values In-Reply-To: <20080513143353.GG29662@karelia> Message-ID: Boris, Thanks for that; swift reply as always :) Cheers, Dave. Dave Moss SELEX Communications Grange Road Christchurch Dorset BH23 4JE United Kingdom Tel: + 44 (0) 1202 404841 Email: david.r.moss@selex-comms.com Boris Kolpackov 05/13/08 03:33 PM To david.r.moss@selex-comms.com cc xsd-users@codesynthesis.com Subject Re: [xsd-users] Code generation fails for schemas with large maxOccurs values Hi David, Boris Kolpackov writes: > I will also check with the Xerces-C++ developers to see if there is > any chance of fixing this problem for the Xerces-C++ 3.0.0 release > (last time I checked it required some serious architectural changes). I spoke to one of the Xerces-C++ developers who tried to implement a solution for this problem. It did not work for all cases at that time but we agreed that we will try to get this solution into shape for the 3.0.0 release. If this does not work out then we will implement the "treat large maxOccurs as unbounded" hack for the time being (this is what Xerces-J apparently does). You can track the progress of this bug here: https://issues.apache.org/jira/browse/XERCESC-1051 Boris ------------------------------------------------------------ This email and any attached files contains company confidential information which may be legally privileged. It is intended only for the person(s) or entity to which it is addressed and solely for the purposes set forth therein. If you are not the intended recipient or have received this email in error please notify the sender by return, delete it from your system and destroy any local copies. It is strictly forbidden to use the information in this email including any attachment or part thereof including copying, disclosing, distributing, amending or using for any other purpose. In addition the sender excludes all liabilities (whether tortious or common law) for damage or breach arising or related to this email including but not limited to viruses and libel. SELEX Communications Limited is a Private Limited Company registered in England and Wales under Company Number 964533 and whose Registered Office is Marconi House, New Street, CHELMSFORD, Essex. CM1 1PL. England. From roger at autodata.no Wed May 14 02:26:19 2008 From: roger at autodata.no (Roger Evans) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 35, Issue 9 Re: Code generation fails for schemas with large maxOccurs values (Boris Kolpackov) In-Reply-To: <1210700181.8895.39.camel@asdtvg-desktop-server> References: <200805131600.m4DG04lN023253@codesynthesis.com> <1210700181.8895.39.camel@asdtvg-desktop-server> Message-ID: <1210746379.9706.32.camel@roger-ubuntu> And enforced fixed attributes, too - while you're at it :) On Tue, 2008-05-13 at 19:36 +0200, Gordon Kramer wrote: > Hi all, > > Am Dienstag, den 13.05.2008, 12:00 -0400 schrieb xsd-users-request@codesynthesis.com: > > > Hi David, > > > > david.r.moss@selex-comms.com writes: > > > > > No code is generated when maxOccurs="9957" or greater and when it's a > > > smaller "large" number the code generation takes a very (very) long time. > > > I realise that in general this is bad practise as XML validation is slow > > > with large bounds as mentioned in this previous post: > > > > > > http://codesynthesis.com/pipermail/xsd-users/2007-February/000812.html > > > > > > but surely the code generation should still work - we may well be stuck > > > with these schemas. > > > > The XSD compiler uses Xerces-C++ underneath to validate the schemas > > being compiled. As a result, the same problem with maxOccurs exists > > when compiling a schema as when validating an instance against it. > > > > > You also need to do this if you need validation of the instance. In > > this case you may have to enforce large maxOccurs constrains in the > > application. > > > > Would it be a big problem to implement code generation for enforcing > maxOccurs>1 outside xercesc validation ? > Maybe adding the maxOccurs constraint as a template parameter to > sequence ? > This would also help enforcing the constraint when programatically > adding elements to the sequence. > > Best Regards, > Gordon > From boris at codesynthesis.com Wed May 14 03:22:28 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 35, Issue 9 Re: Code generation fails for schemas with large maxOccurs values (Boris Kolpackov) In-Reply-To: <1210700181.8895.39.camel@asdtvg-desktop-server> References: <200805131600.m4DG04lN023253@codesynthesis.com> <1210700181.8895.39.camel@asdtvg-desktop-server> Message-ID: <20080514072228.GB9621@karelia> Hi Gordon, Roger, Gordon Kramer writes: > Would it be a big problem to implement code generation for enforcing > maxOccurs>1 outside xercesc validation ? While this is definitely an option, I think it is better to fix the bug in Xerces-C++ since all XML Schema validation (for the C++/Tree mapping) is done there. Doing some of it in Xerces-C++ and some of it in the generated code will make it cumbersome to enable/disable validation as well as report validation errors consistently. > Maybe adding the maxOccurs constraint as a template parameter to > sequence ? Yes, that's probably how I would do it. > This would also help enforcing the constraint when programatically > adding elements to the sequence. This is actually a tricky issue. maxOccurs is one of the few XML Schema constraints that are natural to enforce immediately (e.g., as soon as you've exceeded the limit, you get an exception). Its sibling, minOccurs, does not have this property: we don't want an exception thrown for creating an empty sequence which we plan on populating in the next line. If we enforce maxOccurs in the generated code then it would be natural for the user to expect that minOccurs is also somehow enforced. Because of this we have refrained from enforcing any XML Schema constraints in the generated code other than through the interface. For more information on this you may also want to check the following discussion: http://www.codesynthesis.com/pipermail/xsd-users/2008-January/001443.html Roger Evans writes: > And enforced fixed attributes, too - while you're at it :) This can actually be easily done through the interface by not generating the modifiers. I think it hasn't been done yet because not many people use fixed attributes. I've added this to the 3.2.0 TODO list. Thanks, Boris From gkr at as-guides.com Wed May 14 04:50:07 2008 From: gkr at as-guides.com (Gordon Kramer) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 35, Issue 9 Re: Code generation fails for schemas with large maxOccurs values (Boris Kolpackov) In-Reply-To: <20080514072228.GB9621@karelia> References: <200805131600.m4DG04lN023253@codesynthesis.com> <1210700181.8895.39.camel@asdtvg-desktop-server> <20080514072228.GB9621@karelia> Message-ID: <1210755007.12271.37.camel@asdtvg-desktop-server> Hi Boris, Am Mittwoch, den 14.05.2008, 09:22 +0200 schrieb Boris Kolpackov: > While this is definitely an option, I think it is better to fix the > bug in Xerces-C++ since all XML Schema validation (for the C++/Tree > mapping) is done there. Doing some of it in Xerces-C++ and some of it > in the generated code will make it cumbersome to enable/disable > validation as well as report validation errors consistently. I agree with both statements. Is it possible to validate the object model using Xercesc facilities, without having to parse the xml again? > http://www.codesynthesis.com/pipermail/xsd-users/2008-January/001443.html > thanks for the insightful link. answer to question 3: > 3. If error correction by the application is hard/impossible then > what is the use of in-memory validation other then to know > whether the object model is valid/invalid? The only application i have for validation at the moment is to check whether the generated xml document is actually valid. This is enforced using serialisation followed by de-serialisation. For my application this is fast enough at the moment. So in-memory validation is not really an issue here. It would just be nice to call validate() before serialisation instead of parsing the serialised xml again. Also i can imagine using validate for simple types to reject input from unreliable sources. Maybe it would be an option to let xsd generate a Validator class which provides functions to validate all types and global elements, maybe also global attributes, groups ... in the schema using xercesc library (if requested '--with-inmem-validator'). I don't actually know whether this is possible though. Best Regards, Gordon From roger at autodata.no Wed May 14 11:26:02 2008 From: roger at autodata.no (Roger Evans) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 35, Issue 9 Re: Code generation fails for schemas with large maxOccurs values (Boris Kolpackov) In-Reply-To: <20080514072228.GB9621@karelia> References: <200805131600.m4DG04lN023253@codesynthesis.com> <1210700181.8895.39.camel@asdtvg-desktop-server> <20080514072228.GB9621@karelia> Message-ID: <1210778762.9706.40.camel@roger-ubuntu> Hi Boris Looking forward to 3.2.0 to get rid of my typing errors in fixed attributes! The norwegian tax authority uses lots of them. Let me know if you need test cases. Thanks for a solid tool. Much more flexible and reliable than the xsd that comes with mono. Roger On Wed, 2008-05-14 at 09:22 +0200, Boris Kolpackov wrote: > Hi Gordon, Roger, > Roger Evans writes: > > > And enforced fixed attributes, too - while you're at it :) > > This can actually be easily done through the interface by not generating > the modifiers. I think it hasn't been done yet because not many people > use fixed attributes. I've added this to the 3.2.0 TODO list. > > Thanks, > Boris From boris at codesynthesis.com Wed May 14 12:54:28 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Code generation fails for schemas with large maxOccurs values In-Reply-To: <1210778762.9706.40.camel@roger-ubuntu> References: <200805131600.m4DG04lN023253@codesynthesis.com> <1210700181.8895.39.camel@asdtvg-desktop-server> <20080514072228.GB9621@karelia> <1210778762.9706.40.camel@roger-ubuntu> Message-ID: <20080514165428.GA12702@karelia> Hi Roger, Roger Evans writes: > Looking forward to 3.2.0 to get rid of my typing errors in fixed > attributes! The norwegian tax authority uses lots of them. Let me know > if you need test cases. I can sneak this change into 3.1.1 instead of 3.2.0 if you promise to test the beta with your application once it is released ;-). > Thanks for a solid tool. Much more flexible and reliable than the xsd > that comes with mono. Thanks, I am glad you are enjoying it! Boris From boris at codesynthesis.com Wed May 14 13:24:11 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Code generation fails for schemas with large maxOccurs values In-Reply-To: <1210755007.12271.37.camel@asdtvg-desktop-server> References: <200805131600.m4DG04lN023253@codesynthesis.com> <1210700181.8895.39.camel@asdtvg-desktop-server> <20080514072228.GB9621@karelia> <1210755007.12271.37.camel@asdtvg-desktop-server> Message-ID: <20080514172411.GB12702@karelia> Hi Gordon, Gordon Kramer writes: > Is it possible to validate the object model using Xercesc facilities, > without having to parse the xml again? No, unfortunately this is not possible with the current version of Xerces-C++ and I don't think there are plans to support this in near future. > It would just be nice to call validate() before serialisation instead of > parsing the serialised xml again. Actually, in this case it is more efficient (both generated code size and speed -wise) to combine validation and serialization. Both serializer and validator have to "map" the object model data to XML which can take considerable time and amount of object code. We are currently working on another mapping similar to C++/Tree which will support XML Schema validation in generated code for both parsing and serialization. With this approach it is also fairly easy to support just validation by providing a no-op implementation of the low-level XML serializer. > Maybe it would be an option to let xsd generate a Validator class which > provides functions to validate all types and global elements, maybe also > global attributes, groups ... in the schema using xercesc library (if > requested '--with-inmem-validator'). That would require serialization to XML and re-parsing of the data. I think for now we will concentrate on the new mapping I mention above and see what we can learn from it in terms of user feedback. Once we have better understanding of how people use in-memory validation, we will be able to decide whether it makes sense to add something similar to C++/Tree. Boris From jdmcduf at nsa.gov Wed May 14 13:41:31 2008 From: jdmcduf at nsa.gov (Mcduffey, Joe) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Problem with target and default namespaces Message-ID: <3839570ACE75F74EA214500F4F5FA29961E8B0@MSIS-GH1-UEA04.corp.nsa.gov> I am having a problem with namespaces when I try to compile: when I have a parent schema that specifies a default and target namespace and then I include another schema that makes use of types contained in the parent schema errors occur. For example ---------------- Parent.xsd -------------------------------- ... -------------- Child.xsd ---------------------------- ... I then get an error unable to resolve namespace="" From boris at codesynthesis.com Wed May 14 14:00:27 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Problem with target and default namespaces In-Reply-To: <3839570ACE75F74EA214500F4F5FA29961E8B0@MSIS-GH1-UEA04.corp.nsa.gov> References: <3839570ACE75F74EA214500F4F5FA29961E8B0@MSIS-GH1-UEA04.corp.nsa.gov> Message-ID: <20080514180027.GC12702@karelia> Hi Joe, Mcduffey, Joe writes: > I am having a problem with namespaces when I try to compile: > when I have a parent schema that specifies a default and target > namespace and then I include another schema that makes use of > types contained in the parent schema errors occur. For example > > ---------------- Parent.xsd -------------------------------- > > > > ... > > > -------------- Child.xsd ---------------------------- > > > ... > > > I then get an error > unable to resolve namespace="" I was able to create a test case that reproduces the problem. When you include a schema without a target namespace into a schema with a target namespace (the so-called chameleon inclusion) then the included schema assumes the target namespace of the including schema. Chameleon inclusion is quite tricky and I will have to check the XML Schema spec to see what happens if one references things from the including schema. Xerces-C++ handles this test case without any errors so there is a good chance we have a bug in the compiler. I will let you know. I am also not sure whether the chameleon inclusion is intentional or not in your case since the included schema knows about a type in the including schema so its ability to be reused in other namespaces is somewhat limited (that is, all including schemas will have to define testType). If chameleon inclusion is not required then the easy work around for this problem is to add the same target namespace to Child.xsd as in Parent.xsd. Boris From boris at codesynthesis.com Thu May 15 07:53:16 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Problem with target and default namespaces In-Reply-To: <20080514180027.GC12702@karelia> References: <3839570ACE75F74EA214500F4F5FA29961E8B0@MSIS-GH1-UEA04.corp.nsa.gov> <20080514180027.GC12702@karelia> Message-ID: <20080515115316.GB21335@karelia> Hi Joe, Boris Kolpackov writes: > Chameleon inclusion is quite tricky and I will have to check the XML > Schema spec to see what happens if one references things from the > including schema. Xerces-C++ handles this test case without any > errors so there is a good chance we have a bug in the compiler. > I will let you know. While I couldn't find the exact words in the spec that say this is legal, the consensus among XML Schema processors seems to be that it is.I've fixed this in XSD and now it compiles your example without any errors. The fix will appear in the next release. In the meantime I can build you a pre-release binary with the fix if you let me know which platform/CPU architecture you are using. Thanks for reporting this! Boris From lripple at raydon.com Thu May 15 16:56:52 2008 From: lripple at raydon.com (Laura Ripple - Human Sciences) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] unknown element Message-ID: I recently added the namespace to my schema and now I get unknown element on the very first element in the xml when I run. I am compiling with the XSD/parser in VS2005. I have shrunk down my xsd file and the xml to only contain one element. I was hoping that would help see the problem but it has not. Please help me in any way you can. I am new to XML Schemas and I have no idea what I am doing. Thanks in advance The xsd: The xml: Laura 15/5/2008 Laura Ripple - Human Sciences Privileged/Confidential Information may be contained in this email. If you are not the addressee indicated in this email (or responsible for delivery of the message to such person), you may not copy or deliver thisemail to anyone. In such case, you should destroy this email and kindly notify the sender by phone at (386) 267-2936. Please advise immediately if you or your employer do not consent to emails of this kind. Not for release to foreign persons: controlled under U.S. Federal Regulations. Opinions, conclusions and other information in thisemail that do not relate to the official business of Raydon Corporation shall be understood as neither given nor endorsed by it. From roger at autodata.no Fri May 16 06:00:24 2008 From: roger at autodata.no (Roger Evans) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Using generated code on zLinux (s390x) Message-ID: <1210932024.7165.17.camel@roger-ubuntu> Hi, Boris I am trying to take the generated code .cxx and .hxx files along with my c-tree application and compile and link on Suse Linux SLE10 on IBM z/90 under VM. From the wiki, it looks as if this should work, since the "libxsd is a header-only runtime". I take this to mean that I can copy the xsd header files (/include/xsd) to the s390x platform and use them in compiling my application. If this is possible, it will save me from having to build - or ask you to build - xsd on s390x, as it is entirely acceptable to run xsd on my debian desktop, but the application itself must run on s390x. I have downloaded built and installed xerces-c 2.8.0, compiled and linked my application, and it seems to work until I try to serialize. I get the following: roger@lnxnje:~/rf1037> ./rf1037 terminate called after throwing an instance of 'xsd::cxx::tree::serialization' what(): serialization failed Aborted ----------------------------------------------------------------------- gdb gives the following: (gdb) r Starting program: /home/roger/rf1037/rf1037 [Thread debugging using libthread_db enabled] [New Thread 2199031816208 (LWP 2088)] [Switching to Thread 2199031816208 (LWP 2088)] Breakpoint 1, main () at rf1037.cpp:168 168 xml_schema::namespace_infomap map; (gdb) n 169 map[""].name="http://www.brreg.no/or"; (gdb) n 170 map[""].schema= "melding-669-7378.xsd"; (gdb) n 171 Skjema_ (std::cout,skj,map,"ISO-8859-15"); (gdb) n terminate called after throwing an instance of 'xsd::cxx::tree::serialization' what(): serialization failed Program received signal SIGABRT, Aborted. 0x000002000051ce34 in raise () from /lib64/libc.so.6 (gdb) ----------------------------------------------------------- Before I try with different compiler switches, I would like to know whether I'm trying to do something that will never work. Thanks Roger From bruno.marotta at fortis.com Fri May 16 05:19:58 2008 From: bruno.marotta at fortis.com (bruno.marotta@fortis.com) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Wrong mapping? Message-ID: <8E2E628CE354934FAB31A90699BCFA0D0248F7E6@spmw0018.mail.shared.fortis> Hi, I have the following xsd ... Enables to identify a fortis entity from its name in a system. This is used to make a reference to a fortis Entity. The xsd cxx-tree is mapping the Identifiers type to: class __declspec(dllexport) Identifiers: public ::xml_schema::type { public: ... // identifier // typedef ::xml::Identifier identifier_type; typedef ::xsd::cxx::tree::traits< identifier_type, char > identifier_traits; const identifier_type& identifier () const; identifier_type& identifier (); void identifier (const identifier_type& x); void identifier (::std::auto_ptr< identifier_type > p); ... }; The question is: Shouldn't the identifier_type be a sequence? Thanks, Bruno Marotta IS GMK Equity & Capital Markets ISE - Information Systems Fortis Bank Belgium Tel: +32 2 312 01 43 E-mail: bruno.marotta@fortis.com Mail : Montagne du Parc - 3 - Warandeberg, B-1000 Brussels, Belgium -------------- next part -------------- = = = = = = = = = = = = = = = = = = = = = = = = = Fortis disclaimer : http://www.fortis.be/legal/disclaimer.htm Privacy policy related to banking activities of Fortis: http://www.fortis.be/legal/privacy_policy.htm = = = = = = = = = = = = = = = = = = = = = = = = = From boris at codesynthesis.com Fri May 16 06:26:21 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] unknown element In-Reply-To: References: Message-ID: <20080516102621.GA31632@karelia> Hi Laura, Laura Ripple - Human Sciences writes: > I recently added the namespace to my schema and now I get unknown > element on the very first element in the xml when I run. I am compiling > with the XSD/parser in VS2005. I have shrunk down my xsd file and the > xml to only contain one element. I am pretty sure you forgot to add the root element's namespace to the document's constructor. In other words you code looks like this: xml_schema::document doc_p (root_p, "RNFSchemaSmall"); While it should be: xml_schema::document doc_p (root_p, "http://www.raydon.com/RNFSchemaSmall", "RNFSchemaSmall"); If this doesn't help, can you send your test driver that parses the XML document you sent so that I can take a look? Boris From boris at codesynthesis.com Fri May 16 06:32:55 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Wrong mapping? In-Reply-To: <8E2E628CE354934FAB31A90699BCFA0D0248F7E6@spmw0018.mail.shared.fortis> References: <8E2E628CE354934FAB31A90699BCFA0D0248F7E6@spmw0018.mail.shared.fortis> Message-ID: <20080516103255.GB31632@karelia> Hi Bruno, bruno.marotta@fortis.com writes: > > > > > > > > [...] > > The xsd cxx-tree is mapping the Identifiers type to: > > > // identifier > // > typedef ::xml::Identifier identifier_type; > typedef ::xsd::cxx::tree::traits< identifier_type, char > identifier_traits; > > const identifier_type& > identifier () const; > > identifier_type& > identifier (); > > void > identifier (const identifier_type& x); > > void > identifier (::std::auto_ptr< identifier_type > p); > > The question is: Shouldn't the identifier_type be a sequence? No, the 'identifier' element in the 'Identifiers' type has maxOccurs = 1 and minOccrus = 1 so its cardinality is "exactly one". You can change your schema like this to get the sequence in the mapping: Boris From boris at codesynthesis.com Fri May 16 06:45:05 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Using generated code on zLinux (s390x) In-Reply-To: <1210932024.7165.17.camel@roger-ubuntu> References: <1210932024.7165.17.camel@roger-ubuntu> Message-ID: <20080516104505.GC31632@karelia> Hi Roger, Roger Evans writes: > I am trying to take the generated code .cxx and .hxx files along with my > c-tree application and compile and link on Suse Linux SLE10 on IBM z/90 > under VM. From the wiki, it looks as if this should work, since the > "libxsd is a header-only runtime". I take this to mean that I can copy > the xsd header files (/include/xsd) to the s390x platform and use them > in compiling my application. Yes, this should work provided that (1) your can compile workable Xerces-C++ on this platform and (2) the C++ compiler you are using is modern enough to handle the runtime and generated code. > I have downloaded built and installed xerces-c 2.8.0, compiled and > linked my application, and it seems to work until I try to serialize. > I get the following: > > roger@lnxnje:~/rf1037> ./rf1037 > terminate called after throwing an instance of > 'xsd::cxx::tree::serialization' > what(): serialization failed I suggest that you catch and print this exception. This will give you more information on what's going on: try { Skjema_ (std::cout,skj,map,"ISO-8859-15"); } catch (const xml_schema::exception& e) { cerr << e << endl; } My guess would be that the "ISO-8859-15" is not supported by your build of Xerces-C++ on this platform (which you can fix by rebuilding it with ICU as transcoder). For starters I would try to serialize using an encoding for which Xerces-C++ has an intrinsic support, for example, UTF-8. > gdb gives the following: > > (gdb) r > > 168 xml_schema::namespace_infomap map; > (gdb) n > 169 map[""].name="http://www.brreg.no/or"; > (gdb) n > 170 map[""].schema= "melding-669-7378.xsd"; > (gdb) n > 171 Skjema_ (std::cout,skj,map,"ISO-8859-15"); > (gdb) n > terminate called after throwing an instance of > 'xsd::cxx::tree::serialization' > what(): serialization failed Looks like on this platform stack is unwound as the handler is being searched. As a result when no handler is found the stack is completely unwound and useful debug information like where the exception was thrown from is lost. Boris From atandon at ipolicynetworks.com Fri May 16 03:13:37 2008 From: atandon at ipolicynetworks.com (Tandon, Abhishek) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Is it possible to use Visual Studio 6.0 with Codesythesis ... Message-ID: <1D1B75EB6FE3D84084417D7BFA805183020670C0@nsezhpmail01.india.ipolicynet.com> Hi, Is it possible to use Codesynthesis generated code with Visual Studio 6.0? Regards Abhishek -------------- next part -------------- DISCLAIMER: The contents of this E-mail (including the contents of the enclosure(s) or attachment(s) if any) are privileged and confidential material of iPolicy Networks Limited and should not be disclosed to, used by, distributed, reproduced or copied in any manner by anyone other than the intended addressee(s) and for intended purpose. In case you are not the desired addressee or you have received the mail by error, you should re-direct this message to the sender and immediately destroy it. The views expressed in this E-mail message (including the enclosure(s) or attachment(s) if any) are those of the individual sender, except where the sender expressly, and with authority, states them to be the views of iPolicy Networks Limited From akinkunle.aiyeola at fidelitybankplc.com Thu May 15 10:37:59 2008 From: akinkunle.aiyeola at fidelitybankplc.com (Akinkunle O. Aiyeola) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] cmake module for building xsd application Message-ID: <148D0B393706BD44BFC14CFC0E051B9FB13378@HOMAIL2.fidelitybank.com> Good Day, I will like 2 know how XSD works n how 2 manupulate it on xml. And other information. Akinkunle Aiyeola. We are Fidelity - We Keep Our Word Our products and services: FIDELITY MOBILE BANKING, FIDELITY INTERNET BANKING, FIDELITY SWEETA ACCOUNT, NIGFUND, DIASPORA BANKING, FIDELITY EASY ASSET LEASING, etc. Log into www.fidelitybankplc.com for more details. ------------------------------------------------------------------------------------------------------------------ DISCLAIMER NOTICE This email is confidential. Any dissemination, distribution,copying or use of this email is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and destroy it without copying, disclosing or otherwise using its contents. Emails may suffer errors, viruses, delays,interception and amendment. Whilst every reasonable precaution to minimise this risk has been taken, Fidelity Bank Plc cannot accept liability for any damage sustained as a result of software viruses. You should carry out your own virus checks before opening the attachment. From sureshbabu.kps at wipro.com Fri May 16 01:27:16 2008 From: sureshbabu.kps at wipro.com (Suresh) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Support for other than xercesc parser Message-ID: <000a01c8b715$80b1eec0$5c2c1fac@EC4HP120718> Hi, This tool looks great. But our project does not use xercesc parser; instead we are planing to use a light weight parser - http://www.applied-mathematics.net/tools/xmlParser.html. Does XSD support this parser? If not is there any work around to use this parser with XSD? Thank you for your time -Suresh Please do not print this email unless it is absolutely necessary. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com From boris at codesynthesis.com Fri May 16 09:01:50 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Is it possible to use Visual Studio 6.0 with Codesythesis ... In-Reply-To: <1D1B75EB6FE3D84084417D7BFA805183020670C0@nsezhpmail01.india.ipolicynet.com> References: <1D1B75EB6FE3D84084417D7BFA805183020670C0@nsezhpmail01.india.ipolicynet.com> Message-ID: <20080516130150.GA12570@karelia> Hi Abhishek, Tandon, Abhishek writes: > Is it possible to use Codesynthesis generated code with Visual Studio 6.0? CodeSynthesis XSD does not support VC++ 6.0. CodeSynthesis XSD/e (our mobile/embedded systems offering) does: http://www.codesynthesis.com/products/xsde/ Boris From boris at codesynthesis.com Fri May 16 09:24:32 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Support for other than xercesc parser In-Reply-To: <000a01c8b715$80b1eec0$5c2c1fac@EC4HP120718> References: <000a01c8b715$80b1eec0$5c2c1fac@EC4HP120718> Message-ID: <20080516132432.GB12570@karelia> Hi Suresh, Suresh writes: > Does XSD support this parser? If not is there any work around to use this > parser with XSD? The C++/Tree mapping can only be used with Xerces-C++ DOM. C++/Parser supports Xerces-C++ and Expat out of the box and other parsers can be used as long as you can adapt them to a SAX-like interface. In case of the XML parser that you mentioned, it uses a DOM-like representation so while it should be possible to use it with C++/Parser, it will be quite awkward and inefficient. Expat in this case is a much better choice as a light-weight (and conforming, see below) XML parser. > Instead we are planing to use a light weight parser - > http://www.applied-mathematics.net/tools/xmlParser.html. I took a look and here are a few comments to the statements made on that page: > Let's look at the well-known Xerces C++ library: the complete > library is 53 MB! This is not true. Optimized Xerces-C++ library without debug information (which is what will be distributed with your application) is less than 2MB in size. > DTD's or XSD's informations are ignored > Limited Support for character entities This means this is a non-compliant according to the W3C XML spec parser that is not capable of handling all valid XML documents. Unless you control the production of XML that you are planning to parse (and thus can make sure it won't contain any "unsupported" constructs), using this parser in a production application is asking for trouble. Boris From boris at codesynthesis.com Fri May 16 09:31:19 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] cmake module for building xsd application In-Reply-To: <148D0B393706BD44BFC14CFC0E051B9FB13378@HOMAIL2.fidelitybank.com> References: <148D0B393706BD44BFC14CFC0E051B9FB13378@HOMAIL2.fidelitybank.com> Message-ID: <20080516133119.GC12570@karelia> Hi Akinkunle, Akinkunle O. Aiyeola writes: > I will like 2 know how XSD works n how 2 manupulate it on xml. Please read through the getting started guides for the C++/Tree (in-memory XML representation) and C++/Parser (event-based XML representation) mappings: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/ http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/ There is a CMake module for XSD that was contributed by Frederic Heem some time ago: http://www.codesynthesis.com/download/xsd/contrib/cmake/ See the accompanying README file for more information. Boris From cjbeyer at gmail.com Sat May 17 00:21:01 2008 From: cjbeyer at gmail.com (Charles Beyer) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Trouble serializing subclasses. Message-ID: I'm having trouble getting the codesynthesis xsd-tree serializer to fully serialize a list of objects. Perhaps someone here can point out my misstep. My schema has a list of baseclass elements: list of elements of A: CT AList E Values A complex type A: CT A E ulong ID complex type B extends A: CT B : A E ulong JD The generated classes are as you'd imagine. class A: public ::xml_schema::type { ... typedef ::xml_schema::unsigned_long ID_type; ... ::xsd::cxx::tree::one< ID_type > ID_; } class B: public A { ... typedef ::xml_schema::unsigned_long JD_type; ... ::xsd::cxx::tree::one< ID_type > JD_; } class AList: public ::xml_schema::type { typedef A Values_type; typedef ::xsd::cxx::tree::sequence< Values_type > Values_sequence; ... Values_sequence Values_; } I'm tying to serialize an AList that contains classes B: // convert the list into an XML string std::string msg; std::ostringstream oss; xml_schema::namespace_infomap map; map[""].name = "stuff"; map[""].schema = "Schema.xsd"; AList_ (oss, aList, map); msg = oss.str(); It only serializes the Values as type A, not the subclass B: 99999999999 2 Using the exact same schema in .NET and C#, it properly serializes AList: 99999999999 5 2 10 So, that's it. I'm trying to get the xsd-tree serializer to work like my cs xsd serializer. Any pointers? -- Charles Beyer, cjbeyer@gmail.com Austin, TX From boris at codesynthesis.com Sat May 17 01:13:09 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Trouble serializing subclasses. In-Reply-To: References: Message-ID: <20080517051309.GA14712@karelia> Hi Charles, Charles Beyer writes: > It only serializes the Values as type A, not the subclass B: > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="stuff Schema.xsd"> > > 99999999999 > > > 2 > > > > Using the exact same schema in .NET and C#, it properly serializes AList: > > xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="stuff"> > > 99999999999 > 5 > > > 2 > 10 > > > > > So, that's it. I'm trying to get the xsd-tree serializer to work like > my cs xsd serializer. Any pointers? You need to compile your schemas with the --generate-polymorphic option. In XSD support for polymorphism (xsi:type and substitution groups) is optional since the code that is not polymorphism-aware is smaller and faster and the majority of schemas don't need it. There are also an example in examples/cxx/tree/polymorphism/ that shows how to parse/serialize polymorphic XML documents as well as Section 2.11, "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual that gives some extra pointers on working with polymorphic object models: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11 Boris From pankaj at cadence.com Tue May 20 07:55:28 2008 From: pankaj at cadence.com (Pankaj Chawla) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Any XSD vs competition comparisions Message-ID: Hi We are looking to use a XML code generator and found XSD to be very promising. I just wanted to check if there is a comparision document anywhere taht compares XSD versus other competing code generators. We are only interested in C++ code generators. Cheers Pankaj ----------------------------------- http://13degree.wordpress.com ----------------------------------- From boris at codesynthesis.com Tue May 20 09:53:27 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Any XSD vs competition comparisions In-Reply-To: References: Message-ID: <20080520135327.GB13444@karelia> Hi Pankaj, Pankaj Chawla writes: > I just wanted to check if there is a comparision document anywhere taht > compares XSD versus other competing code generators. We are only interested > in C++ code generators. There is a list of high-level reasons (both business and technical) to use XSD over other similar offerings: http://www.codesynthesis.com/products/xsd/reasons.xhtml If you are looking for a more technical and in-depth comparison then there is a research paper (that I co-authored) which compares a bunch of XML Schema-to-C++ compilers: http://www.cse.wustl.edu/~schmidt/PDF/XSC_ACMSE.pdf While it does not mention XSD, it talks about a tool called XSC. XSC was a research tool I designed and implemented while at Vanderbilt University. After I left Vanderbilt we re-implemented it from scratch with lessons learned from XSC. Pretty much everything that is said about XSC in that paper also applies to XSD. Quoting[1] Nicholas Grimes from Raytheon: "I was using XSC but found XSD which is a vastly superior product." [1] http://www.codesynthesis.com/pipermail/xsd-users/2006-June/000394.html While me comparing similar features of XSD and other products probably won't be very useful to you, I can give you a list of major features which are not found in some/all other products : * Event-driven C++/Parser mapping in addition to the traditional in-memory model (C++/Tree) In C++/Tree: * Customization of the generated code including XML Schema built-in types * Customizable identifier naming convention in the generated code * Support for XML Schema polymorphism (xsi:type and substitution groups) * Support for accessing/modifying wildcard content (any/anyAttribute) as DOM fragments * Option to maintain association with underlying DOM nodes * Optional integration with the Oracle Berkeley DB XML database * Extensible, high-performance serialization to compact binary formats (RPC XDR, ACE CDR streams, and Boost serialization are supported out of the box, custom formats and APIs can be easily added) * Support for the file-per-schema and file-per-type compilation models * Generation of documentation comments in the Doxygen format that include documentation extracted from schemas. Boris From byoung at ara.com Thu May 22 10:11:36 2008 From: byoung at ara.com (Brian Young ARA/CFD) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types Message-ID: I am new to XSD, and trying to use this tool to generate some code for a large schema (3+ MB). However the generated code overwhelms the VS2005 compiler with lots of issues. The main one I can't seem to get passed is too many objects exported from a DLL/library, as mentioned here: http://support.microsoft.com/kb/949945. I tried various things like manually moving the parsing & serialization code into a separate lib, to no avail. So I dug in further and what I find is many, many types are being tagged as anonymous which I didn't expect. The result is alot of duplication. In some cases 30 or more separate class definitions for the same data/type. To illustrate the issue I have with the schema I am working with (which I didnt develop), I have simplied the schema and pasted it below. If you run it through the xsd tool, you'll see generated classes "complexType1" and "complexType2" which is correct. But, you'll also see 2 classes "anonType" and "anonType1" which are essentially the same. My goal is to get a single "group1" class rather than 2 separate "anonType" & "anonType1" classes. I've tried many combinations of the command line args, but here are the latest I'm using: xsd.exe cxx-tree --output-dir .\devTest --hxx-suffix .h --cxx-suffix .cpp --ixx-suffix .i --fwd-suffix -fwd.hxx --namespace-map http://www.w3.org/2001/XMLSchema=com::rdm::xml --generate-serialization --generate-doxygen --generate-intellisense --export-symbol RDM_API --hxx-prologue "#include \".\rdm_export.h\"" --show-sloc --namespace-map =com::rdm Any suggestions? Is there a way to get the 'group ref' taken into consideration when determining if a type is anonymous? complexType1 A complex type anonType complexType2 Another complex type anonType A Group Choice between some stuff An element The ID Another element The ID Thank you, Brian From boris at codesynthesis.com Thu May 22 10:39:37 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types In-Reply-To: References: Message-ID: <20080522143937.GC22214@karelia> Hi Brian, Brian Young ARA/CFD writes: > I am new to XSD, and trying to use this tool to generate some code for a > large schema (3+ MB). However the generated code overwhelms the VS2005 > compiler with lots of issues. The main one I can't seem to get passed is > too many objects exported from a DLL/library, as mentioned here: > http://support.microsoft.com/kb/949945. > > I tried various things like manually moving the parsing & serialization > code into a separate lib, to no avail. > > So I dug in further and what I find is many, many types are being tagged > as anonymous which I didn't expect. The result is alot of duplication. > In some cases 30 or more separate class definitions for the same > data/type. > > To illustrate the issue I have with the schema I am working with (which > I didnt develop), I have simplied the schema and pasted it below. If you > run it through the xsd tool, you'll see generated classes "complexType1" > and "complexType2" which is correct. But, you'll also see 2 classes > "anonType" and "anonType1" which are essentially the same. My goal is to > get a single "group1" class rather than 2 separate "anonType" & > "anonType1" classes. > > [...] > > Any suggestions? Is there a way to get the 'group ref' taken into > consideration when determining if a type is anonymous? The groups are a syntactic sugar in XML Schema and are treated as such by the XSD compiler. Once it is time to generate the code, the internal schema model has all group ref's substituted with the actual content of the groups. So there is no out of the box way to get rid of this bloat. I see a couple of potential ways to deal with it. You can create a small preprocessor for the schema which finds all such equivalent types and substitutes them with the named ones (this will result in a semantically equivalent schema). For example you can use Xerces-C++ to load the schema into DOM (unfortunately you cannot compile XMLSchema.xsd to get its C++ object model ;-)) and then inject a named complex type for each group in your schema. Then you can go over and replace each anonymous type that just contains a group with the named type reference. I can help you write something like this if you like. The other approach is to use the file-per-type compilation mode which will result in a separate set of source files being generated for each type defined in your schema. You can then package them into several DLLs. However, looking at the size of your schema, I think it will be pretty hard to maintain. For more information on the file-per-time mode see this blog post: http://www.codesynthesis.com/~boris/blog/2008/02/13/codesynthesis-xsd-3-1-0-released/ Boris From byoung at ara.com Thu May 22 11:17:24 2008 From: byoung at ara.com (Brian Young ARA/CFD) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types In-Reply-To: <20080522143937.GC22214@karelia> References: <20080522143937.GC22214@karelia> Message-ID: I attempted your suggestion already, also to no avail. The XSD compiler ran for a very long time, and then claimed to complete successfully, however, it didn't produce any code (note I used this in conjunction with -extern-xml-schema, let me know if this is a problem). Not sure what happened there... I have considered your first suggestion as well, just wanted to make sure what I'm after couldn't be accomplished with --anonymous-regex first. I was considering going a scripting/text replacement route, but your xerces option is probably. I would love some help getting going, if it wouldn't take long for you produce. One drawback may be that the schema I working with is sensitive. So I wouldn't be able to send you the test case. Thanks for a quick response! -Brian Young -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, May 22, 2008 10:40 AM To: Brian Young ARA/CFD Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Too many anonymous types Hi Brian, Brian Young ARA/CFD writes: > I am new to XSD, and trying to use this tool to generate some code for > a large schema (3+ MB). However the generated code overwhelms the > VS2005 compiler with lots of issues. The main one I can't seem to get > passed is too many objects exported from a DLL/library, as mentioned here: > http://support.microsoft.com/kb/949945. > > I tried various things like manually moving the parsing & > serialization code into a separate lib, to no avail. > > So I dug in further and what I find is many, many types are being > tagged as anonymous which I didn't expect. The result is alot of duplication. > In some cases 30 or more separate class definitions for the same > data/type. > > To illustrate the issue I have with the schema I am working with > (which I didnt develop), I have simplied the schema and pasted it > below. If you run it through the xsd tool, you'll see generated classes "complexType1" > and "complexType2" which is correct. But, you'll also see 2 classes > "anonType" and "anonType1" which are essentially the same. My goal is > to get a single "group1" class rather than 2 separate "anonType" & > "anonType1" classes. > > [...] > > Any suggestions? Is there a way to get the 'group ref' taken into > consideration when determining if a type is anonymous? The groups are a syntactic sugar in XML Schema and are treated as such by the XSD compiler. Once it is time to generate the code, the internal schema model has all group ref's substituted with the actual content of the groups. So there is no out of the box way to get rid of this bloat. I see a couple of potential ways to deal with it. You can create a small preprocessor for the schema which finds all such equivalent types and substitutes them with the named ones (this will result in a semantically equivalent schema). For example you can use Xerces-C++ to load the schema into DOM (unfortunately you cannot compile XMLSchema.xsd to get its C++ object model ;-)) and then inject a named complex type for each group in your schema. Then you can go over and replace each anonymous type that just contains a group with the named type reference. I can help you write something like this if you like. The other approach is to use the file-per-type compilation mode which will result in a separate set of source files being generated for each type defined in your schema. You can then package them into several DLLs. However, looking at the size of your schema, I think it will be pretty hard to maintain. For more information on the file-per-time mode see this blog post: http://www.codesynthesis.com/~boris/blog/2008/02/13/codesynthesis-xsd-3- 1-0-released/ Boris From dabee21 at gmail.com Thu May 22 11:02:23 2008 From: dabee21 at gmail.com (=?ISO-8859-2?Q?Miros=B3aw_Madej?=) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Something wrong Message-ID: <507fc4d50805220802g72fce8ffw95826d89f1264f8d@mail.gmail.com> Hi I have an xml document with element's name poz-pak and in source code generated from schema I have class poz_pak and when I try to parse this xml file I have many errors unknown element . Ofcourse in this case unknown element poz-pak I think because I have poz_pak in source from schema I thing It should be poz-pak in source generated from schema. What do you think about this?? -- Mirek Madej From boris at codesynthesis.com Thu May 22 13:03:23 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Something wrong In-Reply-To: <507fc4d50805220802g72fce8ffw95826d89f1264f8d@mail.gmail.com> References: <507fc4d50805220802g72fce8ffw95826d89f1264f8d@mail.gmail.com> Message-ID: <20080522170323.GD22214@karelia> Hi Mirek, Miroslaw Madej writes: > I have an xml document with element's name poz-pak and in source code > generated from schema I have class poz_pak and when I try to parse this xml > file I have many errors unknown element . The generated code will still use "poz-pak" when comparing element names that come from XML. It is just the C++ identifier was escaped to poz_pak ('-' is not allowed in C++ identifiers). I think you get those errors because XML Schema validation is enabled but the schema is either not specified or cannot be found. Please see the first three questions in the "Parsing" section of the FAQ: http://wiki.codesynthesis.com/Tree/FAQ If you are still having problems parsing this, send a small test case (schema, XML file, and the test driver) that reproduces the problem and I will take a look Boris From boris at codesynthesis.com Thu May 22 13:13:40 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types In-Reply-To: References: <20080522143937.GC22214@karelia> Message-ID: <20080522171340.GE22214@karelia> Hi Brian, Brian Young ARA/CFD writes: > I attempted your suggestion already, also to no avail. The XSD compiler > ran for a very long time, and then claimed to complete successfully, > however, it didn't produce any code (note I used this in conjunction > with -extern-xml-schema, let me know if this is a problem). Not sure > what happened there... Hm, this should work. The --extern-xml-schema option is ok, it is --generate-xml-schema that you cannot use with --file-per-type, about which you get diagnostics. Can you try to use the same options on the test schema that you sent in your previous email. If XSD does not produce any code either, I would like to see how you compile things. > I have considered your first suggestion as well, just wanted to make > sure what I'm after couldn't be accomplished with --anonymous-regex > first. I was considering going a scripting/text replacement route, but > your xerces option is probably. I would love some help getting going, if > it wouldn't take long for you produce. One drawback may be that the > schema I working with is sensitive. So I wouldn't be able to send you > the test case. Ok, I will try to sketch something up tomorrow. Though I would like to find out why --file-per-type does not work on your schema. BTW, is it just one big file or does it use include/import? Boris From byoung at ara.com Thu May 22 14:16:10 2008 From: byoung at ara.com (Brian Young ARA/CFD) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types In-Reply-To: <20080522171340.GE22214@karelia> References: <20080522143937.GC22214@karelia> <20080522171340.GE22214@karelia> Message-ID: --file-per-type does work with the small/sample schema sent previously in this post. I followed the instructions for using XSD with Visual Studio. My original schema is currently one big file. Is there anyway to get more output from the code generator when running --file-per-type on a big schema? I do not see the created files (and SLOC) listed in the Visual Studio Output window as I do when running --file-per-type on the small/sample schema. Thank you, -Brian Young -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Thursday, May 22, 2008 1:14 PM To: Brian Young ARA/CFD Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Too many anonymous types Hi Brian, Brian Young ARA/CFD writes: > I attempted your suggestion already, also to no avail. The XSD > compiler ran for a very long time, and then claimed to complete > successfully, however, it didn't produce any code (note I used this in > conjunction with -extern-xml-schema, let me know if this is a > problem). Not sure what happened there... Hm, this should work. The --extern-xml-schema option is ok, it is --generate-xml-schema that you cannot use with --file-per-type, about which you get diagnostics. Can you try to use the same options on the test schema that you sent in your previous email. If XSD does not produce any code either, I would like to see how you compile things. > I have considered your first suggestion as well, just wanted to make > sure what I'm after couldn't be accomplished with --anonymous-regex > first. I was considering going a scripting/text replacement route, but > your xerces option is probably. I would love some help getting going, > if it wouldn't take long for you produce. One drawback may be that the > schema I working with is sensitive. So I wouldn't be able to send you > the test case. Ok, I will try to sketch something up tomorrow. Though I would like to find out why --file-per-type does not work on your schema. BTW, is it just one big file or does it use include/import? Boris From boris at codesynthesis.com Fri May 23 11:30:52 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types In-Reply-To: References: <20080522143937.GC22214@karelia> <20080522171340.GE22214@karelia> Message-ID: <20080523153052.GB26818@karelia> Hi Brian, Brian Young ARA/CFD writes: > --file-per-type does work with the small/sample schema sent previously > in this post. I followed the instructions for using XSD with Visual > Studio. > > My original schema is currently one big file. Is there anyway to get > more output from the code generator when running --file-per-type on a > big schema? I do not see the created files (and SLOC) listed in the > Visual Studio Output window as I do when running --file-per-type on the > small/sample schema. No, there is no other information produced by XSD. I was running XSD in the --file-per-type mode with your options on schemas in our schema repository. I found one biggish schema on which XSD runs out of 2GB of memory. While it is expected that the compiler will use more memory when --file-per-type is specified (internally it transforms the schema graph "as if" each type was defined in a separate schema file) though it shouldn't use that much memory. So I am going to investigate this. Can you also check XSD memory usage while it is compiling your big schema with --file-per-type? If it runs out of memory and the OS kills it then that would explain the silent failure and no output. I've also created a sample program to transform your schema: http://www.codesynthesis.com/~boris/tmp/simplify.zip I've decided to use XPath to make searching for nodes easier. So you will need the following libraries to build it: Xerces-C++ 2.8.0 http://xerces.apache.org/xerces-c/ XQilla 2.1.2 http://xqilla.sourceforge.net/HomePage It also uses some XSD runtime headers to simplify string conversion, parsing and serialization. I tested it on the sample schema you provided (also included in the .zip file) and it seems to work well. I didn't have much time so the code is a bit hairy. Let me know if you have any questions/problems with it. Also it would be interesting to know if this transformation had any noticeable impact on your schema. Boris From byoung at ara.com Fri May 23 16:37:59 2008 From: byoung at ara.com (Brian Young ARA/CFD) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types In-Reply-To: <20080523153052.GB26818@karelia> References: <20080522143937.GC22214@karelia> <20080522171340.GE22214@karelia> <20080523153052.GB26818@karelia> Message-ID: Boris, After stepping up to xerces2.8 and grabbing qzilla, your schema preprocessor ran without issue. Thank you kindly. I was able to reduce the generated code size by over 40%, which allowed Visual Studio to generate the dll. So, now I can start looking at the generated code more to see if it will suit our purposes. I'll also more closely compare the transformed schema with the original, but it looks good at first glance. Now, for the file-per-type issue. I watched the memory usage and got the same results twice. Slowing climbs to ~650MB, then very quickly climbs to just under 2GB. Slowly goes back down to ~650MB, slowly backup to ~1GB. Then quickly climbs to around ~2GB before disappearing into the night forever. So, your assumption about running out of memory may be correct. -Brian Young -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Friday, May 23, 2008 11:31 AM To: Brian Young ARA/CFD Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Too many anonymous types Hi Brian, Brian Young ARA/CFD writes: > --file-per-type does work with the small/sample schema sent previously > in this post. I followed the instructions for using XSD with Visual > Studio. > > My original schema is currently one big file. Is there anyway to get > more output from the code generator when running --file-per-type on a > big schema? I do not see the created files (and SLOC) listed in the > Visual Studio Output window as I do when running --file-per-type on > the small/sample schema. No, there is no other information produced by XSD. I was running XSD in the --file-per-type mode with your options on schemas in our schema repository. I found one biggish schema on which XSD runs out of 2GB of memory. While it is expected that the compiler will use more memory when --file-per-type is specified (internally it transforms the schema graph "as if" each type was defined in a separate schema file) though it shouldn't use that much memory. So I am going to investigate this. Can you also check XSD memory usage while it is compiling your big schema with --file-per-type? If it runs out of memory and the OS kills it then that would explain the silent failure and no output. I've also created a sample program to transform your schema: http://www.codesynthesis.com/~boris/tmp/simplify.zip I've decided to use XPath to make searching for nodes easier. So you will need the following libraries to build it: Xerces-C++ 2.8.0 http://xerces.apache.org/xerces-c/ XQilla 2.1.2 http://xqilla.sourceforge.net/HomePage It also uses some XSD runtime headers to simplify string conversion, parsing and serialization. I tested it on the sample schema you provided (also included in the .zip file) and it seems to work well. I didn't have much time so the code is a bit hairy. Let me know if you have any questions/problems with it. Also it would be interesting to know if this transformation had any noticeable impact on your schema. Boris From boris at codesynthesis.com Tue May 27 08:22:05 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types In-Reply-To: References: <20080522143937.GC22214@karelia> <20080522171340.GE22214@karelia> <20080523153052.GB26818@karelia> Message-ID: <20080527122205.GA1652@karelia> Hi Brian, Brian Young ARA/CFD writes: > Now, for the file-per-type issue. I watched the memory usage and got the > same results twice. Slowing climbs to ~650MB, then very quickly climbs > to just under 2GB. Slowly goes back down to ~650MB, slowly backup to > ~1GB. Then quickly climbs to around ~2GB before disappearing into the > night forever. So, your assumption about running out of memory may be > correct. I think I've identified and fixed the cause of this high memory usage. At least my schema that used to cause XSD to run out of 2GB of RAM in the --file-per-type mode now compiles fine using only 2% of that memory. Would it be possible for you to test this fix on your schema and let me know if there is an improvement? I've built a pre-release binary which you can get here: http://www.codesynthesis.com/~boris/tmp/xsd-3.1.1.a4-i686-windows.zip Thanks, Boris From boris at codesynthesis.com Wed May 28 06:50:20 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Re: Possible Oversight In-Reply-To: <20080528070220.7E76725D0C5@relay4.relay.sat.mlsrvr.com> References: <20080528070220.7E76725D0C5@relay4.relay.sat.mlsrvr.com> Message-ID: <20080528105020.GA13605@karelia> Hi Manav, In the future please send technical questions/comments like these to the xsd-users mailing list (which I've CC'ed) instead of to me directly. This way other developers who may have experienced a similar problem can provide you with a solution. Plus questions and answers will be archived and available to others with similar problems. Manav Rathi writes: > When using xsd under Windows XP, the anonymous-regex syntax (as specified in > the help files) does not work. We have to add extra quotes to the entire > expression. > > For example, > > >xsd --anonymous-regex %.* .* (.*)%$1% test.xsd > > error: invalid anonymous type regex: '%.*': missing second > pattern-substitution separator > > To fix this, we have to quote the regex string. > > >xsd --anonymous-regex "%.* .* (.*)%$1%" test.xsd > > If you already knew this, please update the documentation too :) It is actually surprisingly tricky to quote regex values in a portable manner. For example, if you use the above expression quoted in "" on a POSIX shell (e.g, GNU/Linux, UNIX, etc.) you will still get the wrong result since $1 is a variable substitution and will be expanded by the shell. The standard way of dealing with this on POSIX platforms is to use '' instead of "" for quoting. The problem is, Windows does not remove '' from arguments. As a result we decided to show only the regular expression proper in the manual without any quoting. It is normally quite easy to realize that quoting is required. Finding an error when incorrect quoting is used like in the $1 substitution problem is a lot trickier since the only indication that there is something wrong is that the regex doesn't do what you want it to. You can also save the regular expression options to a file, one option per line, and use the --options-file option. This way you don't need to worry about shells and quoting. > And thanks for this great tool. You are welcome. I am glad you are enjoying it. > -Manav > > p.s: By default, xsd names all anonymous types (root or nested) by their > element name. In case of conflicts, it appends a 1 (or 2, or 3) to the name. > I thought that instead of this arbitary resolution, it would be better if > all the names were like parent_element_name__this_element_name. So this > regex was required. It is not often that there are conflicts so using the "complete path" for each type would be an overkill in most cases. Plus you can always use --anonymous-regex option to transform the names in pretty much any way you want. > Ofcourse what would be best is that each nested anonymous type is defined as > a nested class within the parent types namespace. This way there'll never be > conflicts between element1::type and element2::type. It used to work this way. There are two major drawbacks to this approach. The first is the code bloat which happens when you reference the same element with anonymous type in two or more other types. In this situation the same nested type will be generated in several places. The second drawback is the poor compiler support for deeply-nested classes. Boris From manav.rathi at incainformatics.com Wed May 28 08:26:31 2008 From: manav.rathi at incainformatics.com (Manav Rathi) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] RE: Possible Oversight Message-ID: <20080528122721.1A38F21307A@relay3.relay.sat.mlsrvr.com> >In the future please send technical questions/comments like these to the xsd-users mailing list (which I've CC'ed) instead of to me directly. Sorry. My bad. >It is actually surprisingly tricky to quote regex values in a portable manner...As a result we decided to show only the regular expression proper in the manual without any quoting... Well, if the manual includes these two lines, I'm sure it would save some people (like me) a lot of time finding this out on our own :) >...the code bloat which happens when you reference the same element with anonymous type in two or more other types. In this situation the same nested type will be generated in several places... This I did not know. So, if I use the same anonymous type within two different elements, then xsd will recognize it as so, and emit only a single instance of the common anonymous type. Nice. Manav From byoung at ara.com Wed May 28 09:44:13 2008 From: byoung at ara.com (Brian Young ARA/CFD) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Too many anonymous types In-Reply-To: <20080527122205.GA1652@karelia> References: <20080522143937.GC22214@karelia> <20080522171340.GE22214@karelia> <20080523153052.GB26818@karelia> <20080527122205.GA1652@karelia> Message-ID: I verified the build runs on my schema using at most 70MB RAM, and using lower cpu consumption than before. In addition, it produced over 2500 cpp/h files in well under 2 minutes. Note, I have not yet inspected or used the generated --file-per-type code, but your fix is verified. -Brian Young -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, May 27, 2008 8:22 AM To: Brian Young ARA/CFD Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Too many anonymous types Hi Brian, Brian Young ARA/CFD writes: > Now, for the file-per-type issue. I watched the memory usage and got > the same results twice. Slowing climbs to ~650MB, then very quickly > climbs to just under 2GB. Slowly goes back down to ~650MB, slowly > backup to ~1GB. Then quickly climbs to around ~2GB before disappearing > into the night forever. So, your assumption about running out of > memory may be correct. I think I've identified and fixed the cause of this high memory usage. At least my schema that used to cause XSD to run out of 2GB of RAM in the --file-per-type mode now compiles fine using only 2% of that memory. Would it be possible for you to test this fix on your schema and let me know if there is an improvement? I've built a pre-release binary which you can get here: http://www.codesynthesis.com/~boris/tmp/xsd-3.1.1.a4-i686-windows.zip Thanks, Boris From mlang at delysid.org Wed May 28 09:44:59 2008 From: mlang at delysid.org (Mario Lang) Date: Sun Oct 11 15:34:02 2009 Subject: [xsd-users] Preserving element order in MusicXML? Message-ID: <873ao2ee5g.fsf@x2.delysid.org> Hi. I just stumbled across xsdcxx (very very cool!) since I am working on MusicXML software. I've got a xsd file by using trang to convert from the DTD[1], and applied a little bit of hand editing. So far, so good. I ym using cxx-tree and My test program kind of works. Now I added serialisation and noticed that the output XML file looses element order, which is dramatic for MusicXML files. The problem is as follows: MusicXML defined a complexType (music-data) which basically behaves like HTML body. There are a number of elements that can occur inside music-data (, , ...) but the exact ordering of the elements should not be forced in the Schema. Every element can occur either 0 times or any number of times. And the ordering of elements needs to be preserved. I.e. if I have: ... ...... ...... ... ... ... would be a valid MusicXML snippet. Currently, after xsdcxx serialisation of the above snippet, I get sonmething like: ...... ...... ... ... ... ... which is completely wrong in MusicXML context, since the elements can be thought of like statements in a procedural program, they depend on the order of things being preserved. I've read through the XML Schema specification documents on the web, tried a few variants of inside with various minOccurs and maxOccurs values, but nothing seems to instruct xsdcxx to generate a model that correctly serialized the data back out to XML without destroying element order. I am beginning to suspect that this is actually a XML Schema limitation or a limitation in xsdcxx that I am hitting here. This is what I tried (I tried various other variants as well): Is it possible to express a schema for sturcture like above and use it with xsdcxx? If so, what am I missing? I hope this kind of works and I just miss something. I at least think that this problem would be pretty common (think XHTML), but I failed to dig to the bottom of it... [1] http://www.musicxml.org/dtds/partwise.dtd -- Thanks, ????? | Debian Developer .''`. | Get my public key via finger mlang/key@db.debian.org : :' : | 1024D/7FC1A0854909BCCDBE6C102DDFFC022A6B113E44 `. `' `- From boris at codesynthesis.com Wed May 28 10:03:55 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:03 2009 Subject: [xsd-users] Preserving element order in MusicXML? In-Reply-To: <873ao2ee5g.fsf@x2.delysid.org> References: <873ao2ee5g.fsf@x2.delysid.org> Message-ID: <20080528140355.GC14026@karelia> Hi Mario, Mario Lang writes: > > ... > ...... > ...... > ... > ... > ... > > > would be a valid MusicXML snippet. > > Currently, after xsdcxx serialisation of the above snippet, I get > sonmething like: > > > ...... > ...... > ... > ... > ... > ... > > > which is completely wrong in MusicXML context, since the elements > can be thought of like statements in a procedural program, they > depend on the order of things being preserved. > > [...] > > I am beginning to suspect that this is actually a XML Schema limitation > or a limitation in xsdcxx that I am hitting here. This is a limitation of the C++/Tree mapping and it was a conscious trade-off between ease of use and being able to retain certain information that is sometimes required (like order). In essence, C++/Tree mapping flattens the schema model and groups several occurrences of the same element into a sequence. This works quite well for data-centric XML vocabularies but sometimes is insufficient for document-centric ones like XHTML or MusicXML. There is another mapping, C++/Parser, that by design allows you to capture the order information. It is, however, only supports parsing (the serialization-supporting counterpart, C++/Serializer, is on its way). > > > > > > > > > > > > > > > > > > > > > > > Is it possible to express a schema for sturcture like above and > use it with xsdcxx? If so, what am I missing? Since you have control over the schema, I can propose an elegant workaround which will allow you to retain order and use the C++/Tree mapping. It boils down to using XML Schema substitution groups to represent various music data elements. Here is an outline: ... In the OOP terms the above schema says that the music-data type contains a sequence of abstract music-element elements each of which can be note, backup, forward, etc. Once you compile this schema with the --generate-polymorphic option, you will get a "polymorphic sequence" of music-element items in the music-data type. While the static type in this sequence is music-element, actual objects stored are note, backup, etc. You can figure out which object it is by using, for example, dynamic_cast. For more information on working with polymorphic object models see Section 2.11, "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping Manual: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11 Boris From boris at codesynthesis.com Wed May 28 10:39:36 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:03 2009 Subject: [xsd-users] RE: Possible Oversight In-Reply-To: <20080528122721.1A38F21307A@relay3.relay.sat.mlsrvr.com> References: <20080528122721.1A38F21307A@relay3.relay.sat.mlsrvr.com> Message-ID: <20080528143936.GE14026@karelia> Hi Manav, Manav Rathi writes: > >...the code bloat which happens when you reference the same element with > anonymous type in two or more other types. In this situation the same nested > type will be generated in several places... > > This I did not know. So, if I use the same anonymous type within two > different elements, then xsd will recognize it as so, and emit only a > single instance of the common anonymous type. Nice. Not exactly. The scenario I was referring to is the following: ... Here, if we generate nested classes for anonymous types, you will end up with the following code: class a { class e { }; }; class b { class e { }; }; The way XSD works, you will only get one (global) class e which is used by both a and b. Boris From boris at codesynthesis.com Wed May 28 15:53:01 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:03 2009 Subject: [xsd-users] XSD accepted into Debian Message-ID: <20080528195301.GB15987@karelia> Hi, I am pleased to announce that thanks to the efforts of Debian developer Raphael Bossek, XSD has been accepted into the Debian package repository: http://packages.debian.org/xsdcxx Debian QA page for the package is: http://packages.qa.debian.org/xsd Note that due to a conflict with another package, the package and the compiler executable have been renamed from 'xsd' to 'xsdcxx'. The XSD runtime include paths remain unchanged therefore the only thing you need to do if you want to use the package from the Debian repository instead of the one from the Code Synthesis website is to change the XSD compiler name. Boris From manav.rathi at incainformatics.com Thu May 29 00:53:38 2008 From: manav.rathi at incainformatics.com (Manav Rathi) Date: Sun Oct 11 15:34:03 2009 Subject: [xsd-users] RE: Possible Oversight In-Reply-To: <20080528143936.GE14026@karelia> Message-ID: <20080529045446.9AEFC22B1FE@relay5.relay.sat.mlsrvr.com> > > >...the code bloat which happens when you reference the same element > with > > anonymous type in two or more other types. In this situation the same > nested > > type will be generated in several places... > > > > This I did not know. So, if I use the same anonymous type within two > > different elements, then xsd will recognize it as so, and emit only a > > single instance of the common anonymous type. Nice. > > Not exactly. The scenario I was referring to is the following: > > > > ... > > > > > > > > > > > > > > > > > Here, if we generate nested classes for anonymous types, you will end > up with the following code: > > class a > { > class e > { > }; > }; > > class b > { > class e > { > }; > }; > > The way XSD works, you will only get one (global) class e which is used > by both a and b. > What I was suggesting is something like this. ... ... ... ... ... ... results in generation of class root1 { class child {}; }; class root2 { class child {}; }; However, there will be a problem with this approach. We cannot have a nested class and a member function with the same name. So we try and rename the nested classes. class root1 { class child_type {}; child_type & child(); }; class root2 { class child_type {}; child_type & child(); }; Contrasting with the solution xsd currently uses class child_type {}; class child_type1 {}; class root1 { typedef child_type child_type; child_type & child(); }; class root2 { typedef child_type1 child_type; child_type & child(); }; I can see that we get the same syntax (i.e. one can refer to the nested types as root1::child_type and root2::child_type), but can still avoid all the complexity associated with deeply nested types. So the current design of XSD wins :) However, there *seems* to be a problem - the child types are now available in the global namespace (i.e. I can do ::child_type and ::child_type1). Whether this is good or bad, I am not too sure. The most obvious advantage is that I get to type less (i.e. child_type instead of root1::child_type). The most obvious disadvantage is that encapsulation is broken (i.e. child_type should not mean anything unless it is a root1::child_type). As I said before, right now I consider this as a problem. And as a solution, I am using the --anonymous-regex switch to rename the root1::child_type class to a much more verbose root1_child_type, so that programmers prefer the nested root1::child_type typedef to the global root1_child_type actual class. From manav.rathi at incainformatics.com Thu May 29 01:26:38 2008 From: manav.rathi at incainformatics.com (Manav Rathi) Date: Sun Oct 11 15:34:03 2009 Subject: [xsd-users] Need schema suggestions In-Reply-To: <20080528143936.GE14026@karelia> Message-ID: <20080529052747.08E4C22B195@relay5.relay.sat.mlsrvr.com> I wish to create a schema that will allow me to use both the following XML: 1) 2) Any XSD schema design suggestions? Right now, what I thinking of is ... ... But this seems to be overkill, especially considering the fact that bar is an anonymous type that can only occur with the context of foo. From boris at codesynthesis.com Thu May 29 09:01:55 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:03 2009 Subject: [xsd-users] Need schema suggestions In-Reply-To: <20080529052747.08E4C22B195@relay5.relay.sat.mlsrvr.com> References: <20080528143936.GE14026@karelia> <20080529052747.08E4C22B195@relay5.relay.sat.mlsrvr.com> Message-ID: <20080529130155.GA24115@karelia> Hi Manav, Manav Rathi writes: > I wish to create a schema that will allow me to use both the following XML: > > 1) > > > > > > > > 2) > > > > > > > > Any XSD schema design suggestions? This one should be pretty straightforward to handle with the choice compositor: Also note that this is a wrong list to ask general schema design questions. A better place would be the xml-dev and xmlschema-dev mailing lists: http://xml.org/xml/xmldev.shtml http://lists.w3.org/Archives/Public/xmlschema-dev/ As well as the comp.text.xml newsgroup. Boris From manav.rathi at incainformatics.com Fri May 30 08:29:22 2008 From: manav.rathi at incainformatics.com (Manav Rathi) Date: Sun Oct 11 15:34:03 2009 Subject: [xsd-users] Accessors for sequences Message-ID: <20080530123019.C5BB222B94A@relay5.relay.sat.mlsrvr.com> Presently the unbounded occurring elements like "" are translated to "member_sequence& member();" Thus, to use this sequence in, say, a BOOST_FOREACH, I have to write "foreach(member_type & member, e.member())" I would suggest the following variation. Accessors for sequences are named by appending a 's' at the end. So our example becomes "foreach(member_type & member, e.members())" This seems more 'natural'. Also, is there any way to do this currently (by using some sort of regex)? From boris at codesynthesis.com Fri May 30 10:44:47 2008 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:03 2009 Subject: [xsd-users] Accessors for sequences In-Reply-To: <20080530123019.C5BB222B94A@relay5.relay.sat.mlsrvr.com> References: <20080530123019.C5BB222B94A@relay5.relay.sat.mlsrvr.com> Message-ID: <20080530144447.GC2563@karelia> Hi Manav, Manav Rathi writes: > Presently the unbounded occurring elements like > "" > are translated to > "member_sequence& member();" > Thus, to use this sequence in, say, a BOOST_FOREACH, I have to write > "foreach(member_type & member, e.member())" > > I would suggest the following variation. Accessors for sequences are named > by appending a 's' at the end. So our example becomes > "foreach(member_type & member, e.members())" > This seems more 'natural'. Hm, I think I agree this might be a more natural naming convention. However: (1) Using a name other than the element name may result in conflicts (e.g., you could have both 'member' and 'members' elements in the same type). This, however, would probably happen seldom enough for us to ignore it. (2) Changing the default naming convention would break thing for hundreds of people. Probably the only practical way to support this is to add an option for custom regex transformations (see below). > Also, is there any way to do this currently (by using some sort of regex)? Kind of. There are --accessor-regex and --modifier-regex options but they don't distinguish between one/optional/sequence. So if you have two elements 'member' in two different types one is sequence and the other is not, then you are out of luck. You will also have to add a regex for each sequence element which can be quite a pain if you have a lot of them. I guess we could add a bunch more options (we already have almost a hundred options for the C++/Tree mapping so a few more, a few less, I am sure nobody will notice ;-)). Something along these lines: --one-accessor-regex --one-modifier-regex --opt-accessor-regex --opt-modifier-regex --seq-accessor-regex --seq-modifier-regex I've added this to my TODO list. If you would like to start using these new options I can probably implement them on Monday and build you a pre-release binary. Let me know if you would like that. And thanks for the suggestion. Boris