From boris at codesynthesis.com Mon Jun 1 04:17:29 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] unable to build on Freebsd 6.4 - (CPU amd64) In-Reply-To: <15913612.151451243687317657.JavaMail.root@webmail6> References: <15913612.151451243687317657.JavaMail.root@webmail6> Message-ID: Hi, abc writes: > when I download the source code, and extracted it into /tmp foler, > then goes into /tmp/xsd-3.2.0-2/xsd and issue command "make install", > however I only got: > "makefile", line 6: Could not find There are a number of prerequisites that you need to install before you can build XSD from source. For more information, see the build instructions for UNIX: http://www.codesynthesis.com/projects/xsd/extras/build-unix.xhtml I suggest that you try to use the xsd+dep package which includes all the prerequisites except Boost and Xerces-C++ which you will need to build and install separately (unless you have already done so). > By the way, I've downloaded cd xsd-3.2.0-x86_64-linux-gnu, however, > the command line tool xsd can not run, error msg: > freebsd64# bin/xsd > ELF binary type "0" not known. > bin/xsd: Exec format error. Binary file not executable. This is expected: you are trying to run a Linux binary on FreeBSD. We currently do not provide pre-built binaries for this platform so you will have try and build the XSD compiler from source. Let us know if you run into any problems. Boris From boris at codesynthesis.com Mon Jun 1 04:23:10 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Troubles while parsing XML documents with XSD In-Reply-To: References: Message-ID: Hi Artem, Artem Shubovych writes: > But how to tell COLLADA XML document, which XSD to use? There are several ways to do this as described in Section 5.1, "XML Schema Validation and Searching" in the C++/Tree Mapping Getting Started Guide: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#5.1 > I tried many variants, like: > > xsi:schemaLocation="collada_schema_1_4.xsd" version="1.4.1"> The xsi:schemaLocation attribute must contain namespace-schema pairs so in your case it should be: xsi:schemaLocation="http://www.collada.org/2005/11/COLLADASchema collada_schema_1_4.xsd" Boris From yilu at 21cn.com Tue Jun 2 11:02:31 2009 From: yilu at 21cn.com (abc) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Re: unable to build on Freebsd 6.4 - (CPU amd64) Message-ID: <29295355.17601243954952083.JavaMail.root@webmail2> Hi Boris: Thanks for the instruction. Howerver, I actually trie got the same error. The following is my env: OS: FreeBSD freebsd64# ls -l /usr/local/lib/libxerces-c1_7_0.so - al/lib/libxerces-c1_7_0.so freebsd64# ls /usr/local/lib/ | grep boost libboost_date_time.a libboost_date_time.so libboost_date_time.so.4libboost_filesystem.a libboost_filesystem.so libboost_filesystem.so libboost_graph.a libboost_graph.so libboost_graph.so.4 libbo libboost_iostreams.so libboost_iostreams.so.4 freebsd64# ls README &n sp; libfrontend build-0.3.3-1 & d-elements-1.6.1 libxsd-frontend-1.15.0 build.sh &nb nbsp; xsd-3.2.0-2 freebsd64# . "makefile", line 6: Could not find Error expanding embedded --- In reply to -- Hi, abc when I download the source foler, > then goes install", > & > "makefile", line There are a number of prerequisites that you need you can build XSD from source. For more information, s instructions for UNIX: http://www.codesynthesis.com/ I suggest that you try to use t the prerequisites except Boost and build and install separately (unless > By the way, I' however, > &n > & > ELF binary type "0" not > bin/xsd: Exec format error. Binary file no This is expected: you are trying to run a Linux binary currently do not provide pre-built binaries for this pla will have try and build the XSD compiler from source. Let u you run into any problems. References Visible links Hidden links: 1. 3D"http: From boris at codesynthesis.com Wed Jun 3 04:40:15 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Re: unable to build on Freebsd 6.4 - (CPU amd64) In-Reply-To: <29295355.17601243954952083.JavaMail.root@webmail2> References: <29295355.17601243954952083.JavaMail.root@webmail2> Message-ID: Hi, abc writes: > freebsd64# ls -l /usr/local/lib/libxerces-c1_7_0.so This is a really, really old version of Xerces-C++. To build XSD you will need at least 2.6.0. I recommend that you use the latest (3.0.1), though. > freebsd64# .= /build.sh > "makefile", line 6: Could not find > Error expanding embedded= variable. I think you have BSD make while the XSD build system requires GNU make. Here is the relevant excerpt from the README file accompanying the xsd+dep package: "The following GNU tools are required to build XSD. Any fairly recent GNU/Linux distribution should have these already installed: GNU bash >= 2.00 (bash --version) http://www.gnu.org/software/bash/ GNU m4 >= 1.4 (m4 --version) http://www.gnu.org/software/m4/ GNU make >= 3.81 (make --version) http://www.gnu.org/software/make/ GNU g++ >= 3.4.3 (g++ --version) http://gcc.gnu.org/" If you install GNU make as gmake then you will need to edit the build.sh script. Boris From bschindler at inf.ethz.ch Thu Jun 4 07:33:14 2009 From: bschindler at inf.ethz.ch (Benjamin Schindler) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] dynamic xs:include's in schemas Message-ID: <4A27B0FA.4080804@inf.ethz.ch> Hi We're building a client-server system which uses xml to pass the data around. We use xsd to access and parse the data which is being passed around. Now the idea of a plugin-system came up. Right now, the main schema used for validation just has an include for every part component of the system like this: .... .... Now when I dynamically load a plugin, I cannot hardcode these includes into the xsd anymore. Is there a way to tell the parser about more includes in any way without actually modifying the xsd directly on disk? Thanks Benjamin Schindler From boris at codesynthesis.com Thu Jun 4 10:09:34 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] dynamic xs:include's in schemas In-Reply-To: <4A27B0FA.4080804@inf.ethz.ch> References: <4A27B0FA.4080804@inf.ethz.ch> Message-ID: Hi Benjamin, Benjamin Schindler writes: > We're building a client-server system which uses xml to pass the data > around. We use xsd to access and parse the data which is being passed > around. > Now the idea of a plugin-system came up. Right now, the main schema used > for validation just has an include for every part component of the > system like this: > .... > schemaLocation="../../../views/views/schema/ScatterSettings.xsd" /> > .... > Now when I dynamically load a plugin, I cannot hardcode these includes > into the xsd anymore. > Is there a way to tell the parser about more includes in any way without > actually modifying the xsd directly on disk? There is no such include facility but there is a way to get rid of the xs:include altogether by using XML Schema wildcards (xs:any and xs:anyAttribute). The idea is to define an "extension point" in the schema as a wildcard. You can then define independent schemas that define the concrete extensions used in its place. The 'wildcard' example in the examples/cxx/tree/ directory shows how this might work. If you need validation you may also need to manually load all the "concrete" schemas (see the 'caching' example on how to do this). Another, more OO, alternative is to used substitution groups. In this case your define an abstract type and element that are then derived from in separate schemas (in this case the "concrete" schemas will include the "base" but not vice-verse). See the 'polymorphism' example for information on how this might work. The advantage of this method is that everything is handled for you under the hood (i.e., you don't need to work with DOM to parse the data matched by wildcards). Boris From Batya.Hacohen at tadirantele.com Mon Jun 8 10:47:10 2009 From: Batya.Hacohen at tadirantele.com (Batya Hacohen) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] G2S protocol with confilicting type Message-ID: Hi, I am trying to use the xsd c++/tree for ECMA CSTA-xml. Do you know if someone has done it already and may have the xsd command line and also some example of using it? Thanks a lot Batya Tadiran telecomm From Batya.Hacohen at tadirantele.com Tue Jun 9 11:03:26 2009 From: Batya.Hacohen at tadirantele.com (Batya Hacohen) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Compiling CSTA XSD files Message-ID: I am trying to compile the ECMA CSTA XSD files. I get the following: Performing xsd "d:\xmlCompiler\CstaXMLLib\xsdsrc\accept-call.xsd" d:\xmlCompiler\CstaXMLLib\xsdsrc\security.xsd:16:34: error: element name 'SecurityInfo/string' creates an unstable conflict when used as a type name d:\xmlCompiler\CstaXMLLib\xsdsrc\device-feature-types.xsd:43:25: info: conflicting type is defined here d:\xmlCompiler\CstaXMLLib\xsdsrc\security.xsd:16:34: info: use --anonymous-regex to resolve this conflict d:\xmlCompiler\CstaXMLLib\xsdsrc\security.xsd:16:34: info: and don't forget to pass the same option when translating 'security.xsd' and all the schemas that refer to it d:\xmlCompiler\CstaXMLLib\xsdsrc\security.xsd:21:35: error: element name 'SecurityInfo/private' creates an unstable conflict when used as a type name d:\xmlCompiler\CstaXMLLib\xsdsrc\device-feature-types.xsd:53:26: info: conflicting type is defined here d:\xmlCompiler\CstaXMLLib\xsdsrc\security.xsd:21:35: info: use --anonymous-regex to resolve this conflict d:\xmlCompiler\CstaXMLLib\xsdsrc\security.xsd:21:35: info: and don't forget to pass the same option when translating 'security.xsd' and all the schemas that refer to it d:\xmlCompiler\CstaXMLLib\xsdsrc\extension-types.xsd:15:34: error: element name 'CSTAPrivateData/string' creates an unstable conflict when used as a type name d:\xmlCompiler\CstaXMLLib\xsdsrc\device-feature-types.xsd:43:25: info: conflicting type is defined here d:\xmlCompiler\CstaXMLLib\xsdsrc\extension-types.xsd:15:34: info: use --anonymous-regex to resolve this conflict d:\xmlCompiler\CstaXMLLib\xsdsrc\extension-types.xsd:15:34: info: and don't forget to pass the same option when translating 'extension-types.xsd' and all the schemas that refer to it d:\xmlCompiler\CstaXMLLib\xsdsrc\extension-types.xsd:20:35: error: element name 'CSTAPrivateData/private' creates an unstable conflict when used as a type name d:\xmlCompiler\CstaXMLLib\xsdsrc\device-feature-types.xsd:53:26: info: conflicting type is defined here d:\xmlCompiler\CstaXMLLib\xsdsrc\extension-types.xsd:20:35: info: use --anonymous-regex to resolve this conflict d:\xmlCompiler\CstaXMLLib\xsdsrc\extension-types.xsd:20:35: info: and don't forget to pass the same option when translating 'extension-types.xsd' and all the schemas that refer to it Project : error PRJ0019: A tool returned an error code from "Performing xsd "d:\xmlCompiler\CstaXMLLib\xsdsrc\accept-call.xsd"" Build log was saved at "file://d:\xmlCompiler\CstaXMLLib\Debug\BuildLog.htm" CstaXmlLib - 5 error(s), 0 warning(s) My Command line is: xsd cxx-tree --extern-xml-schema ../src/csta.hxx --generate-serialization --generate-inline --generate-ostream --output-dir ".\src" "$(InputPath)" I also was trying to add --anonymous-regex "#.* (.+)/(.+)#$1_$2#" but it did not work. Attached are the files. (not all CSTA files) Please advice Regards Batya Hacohen -------------- next part -------------- A non-text attachment was scrubbed... Name: device-feature-types.xsd Type: application/octet-stream Size: 21324 bytes Desc: device-feature-types.xsd Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090609/895baf34/device-feature-types.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: security.xsd Type: application/octet-stream Size: 1857 bytes Desc: security.xsd Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090609/895baf34/security.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: extension-types.xsd Type: application/octet-stream Size: 1482 bytes Desc: extension-types.xsd Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090609/895baf34/extension-types.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: accept-call.xsd Type: application/octet-stream Size: 1232 bytes Desc: accept-call.xsd Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090609/895baf34/accept-call.obj From boris at codesynthesis.com Tue Jun 9 14:18:04 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Compiling CSTA XSD files In-Reply-To: References: Message-ID: Hi Batya, Batya Hacohen writes: > I am trying to compile the ECMA CSTA XSD files. I get the following: > > d:\xmlCompiler\CstaXMLLib\xsdsrc\security.xsd:16:34: error: element name > 'SecurityInfo/string' creates an unstable conflict when used as a type > name > > [...] > > My Command line is: xsd cxx-tree --extern-xml-schema ../src/csta.hxx > --generate-serialization --generate-inline --generate-ostream > --output-dir ".\src" "$(InputPath)" > > I also was trying to add --anonymous-regex "#.* (.+)/(.+)#$1_$2#" but > it did not work. It should be: "#.* .* (.+)/(.+)#$1_$2#". With this regex I compiled all the 251 schema files without problems. I also added these two options: --root-element-all --namespace-map http://www.ecma-international.org/standards/ecma-323/csta/ed4=CSTA4 If you don't need parsing/serialization functions for all the root elements, then you can use one of the --root-element-* options to specify which ones you need. Boris From dian.aa.du at gmail.com Tue Jun 9 18:52:43 2009 From: dian.aa.du at gmail.com (Dian Du) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Print all information for one xml without knowing all tag names Message-ID: Hello: >From the example at http://www.codesynthesis.com/products/xsd/ ? John Doe ? j@doe.com ? 555 12345 auto_ptr c = contact ("c.xml"); cout << c->name () << ", " ???? << c->email () << ", " ???? << c->phone () << endl; We have to know the name of each tag before calling one of the function named as tag, such as c->name (). How do I implement a more genetic way, as? as auto_ptr c = contact ("c.xml"); while (not end of tags) { ?? cout << c->one of tay(); ?? next tag } Thank you for you reply. Dian From ermias.ayale at planet.nl Wed Jun 10 08:24:47 2009 From: ermias.ayale at planet.nl (Ermias Ayale) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] In need of some examples how to implement map files etc for cxx-parser Message-ID: Hi everyone, I am new to XSD cxx-parser. I am planning to use it to parse xml files which are complexer than the ones included in cxx-parser exmples. I am in need of some examples that parse complexer xml files, that implement the map files when using the --type-map option and the coressponding *.hxx file. Is there anyone willing to help? :-) Thanks in advance, Yeshi From boris at codesynthesis.com Wed Jun 10 13:03:51 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Print all information for one xml without knowing all tag names In-Reply-To: References: Message-ID: Hi Dian, Dian Du writes: > > ? John Doe > ? j@doe.com > ? 555 12345 > > > > auto_ptr c = contact ("c.xml"); > cout << c->name () << ", " > ???? << c->email () << ", " > ???? << c->phone () << endl; > > We have to know the name of each tag before calling one of the > function named as tag, such as c->name (). That's correct. > How do I implement a more genetic way, as? as > > auto_ptr c = contact ("c.xml"); > > while (not end of tags) { > ?? cout << c->one of tay(); > ?? next tag > } The whole point of the C++/Tree object model is that it is not "generic" but rather vocabulary-specific. That is, you call functions corresponding to element/attribute names in your XML vocabulary to access the data. If your application needs a generic XML access API then DOM or SAX are the better ways to do it. Now, for cases where you mostly need a vocabulary-specific access but have a small part where a generic API is more suitable, the C++/Tree mapping allows you to maintain a bi-directional association between object model nodes and corresponding DOM nodes. This way you can "switch" between using DOM API and C++/Tree API to access the same data. For more information on this feature see Section 5.1, "DOM Association" in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#5.1 Boris From boris at codesynthesis.com Wed Jun 10 13:17:34 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] In need of some examples how to implement map files etc for cxx-parser In-Reply-To: References: Message-ID: Hi Ermias, Ermias Ayale writes: > I am new to XSD cxx-parser. I am planning to use it to parse xml files > which are complexer than the ones included in cxx-parser exmples. I am > in need of some examples that parse complexer xml files, that implement > the map files when using the --type-map option and the coressponding > *.hxx file. I suggest that you start by reading the C++/Parser Mapping Getting Started Guide: http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/ In particular, Chapter 4 deals with type maps in great detail. Once you read and understand this chapter, you shouldn't have any problems writing a type map file for a schema of any complexity. And if you encounter any concrete problems then you can always ask for help on this mailing list. Boris From boris at codesynthesis.com Thu Jun 11 14:06:36 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Compiling CSTA XSD files In-Reply-To: References: Message-ID: Hi Batya, In the future please keep your replies CC'ed to the xsd-users mailing list. See the Posting Guidelines for more information: http://www.codesynthesis.com/support/posting-guidelines.xhtml Batya Hacohen writes: > I know that once I may decode/encode one CSTA service/event the rest > will be easier. I am struggling the first. > > My XML input is a string, not in file. > > So if I have make-call string: > char *makeCall = " xmlns=\"http://www.ecma-international.org/standards/ecma-323/csta/ed4\"> > tel:+2001;ext=2001 > tel:4001;phone-context=dialstringd > oNotPrompt"; > > How can I decode it? You would first need to make sure that the parsing functions for the MakeCall element are generated (add --root-element-all or --root-element MakeCall). Then you can use, for example, std::istringstream to parse from a string: #include std::istringstream istr (makeCall); std::auto_ptr mc (MakeCall_ (istr)); If you don't know the root element of the XML document you are about to parse, then see the 'multiroot' example in the examples/cxx/tree/ directory for more information on how to handle this situation. Boris From Al.Niessner at jpl.nasa.gov Thu Jun 11 18:45:42 2009 From: Al.Niessner at jpl.nasa.gov (Al Niessner) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] xsd:include Message-ID: <1244760342.3032.183.camel@morte.jpl.nasa.gov> I am using xsd:include to bring together 3 schema files that complete each other (have some inner relationship amongst them). When I compile with XSD ('xsd cxx-tree d.xsd') I get a header with three #include directives in it. Not really what I was looking for. Is it possible through the long list of XSD options that I thumbed through tom make XSD actually include all of hte xsd:includes into a larger more complete schema and map that new thing to C++? I find this to be the behavior when mapping to Java and Python with different tools for each of those languages. I tried --file-per-type but that did not do it either. It still crashed when it hit an unknown in b.xsd that was referencing a.xsd even though a.xsd was included just before b.xsd. Here is the structure that I am working with d.xsd: where b needs a and c needs both a and b. Again, did I just miss the XSD option that would turn d.xsd into a bigger and fully complete schema and then map that to C++? Thanks in advance for all and any help. -- Al Niessner 818.354.0859 -------- | dS | >= 0 -------- From boris at codesynthesis.com Fri Jun 12 04:34:53 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Compiling CSTA XSD files In-Reply-To: <892a207d0906111429q3cfae54ch643edd0cf3adcbaf@mail.gmail.com> References: <892a207d0906111429q3cfae54ch643edd0cf3adcbaf@mail.gmail.com> Message-ID: Hi Batya, Again, I ask you to keep your replies CC'ed to the xsd-users mailing list. See the Posting Guidelines for more information: http://www.codesynthesis.com/support/posting-guidelines.xhtml Batya Hacohen writes: > I am trying for hours to start my CSTA project and failed to call the > parsing method. > I am starting with make-call.xsd and I do not see in the make-call.cxx and > make-call.hxx a method for parsing. > I was looking at the examples and see method like: > > // Parse a URI or a local file. > > ::std::auto_ptr< ::hello_t > > > hello (const ::std::string& uri, > > ::xml_schema::flags f = 0, > > const ::xml_schema::properties& p = ::xml_schema::properties ()); > > I don't see anything like this in my files. If you don't see these methods then it means you have disabled their generation with either --suppress-parsing or one of the --root-element-* options. If I compile make-call.xsd without --suppress-parsing and with just --root-element-all, then I get the parsing functions for MakeCall and MakeCallResponse generated. Boris From boris at codesynthesis.com Fri Jun 12 04:51:39 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] xsd:include In-Reply-To: <1244760342.3032.183.camel@morte.jpl.nasa.gov> References: <1244760342.3032.183.camel@morte.jpl.nasa.gov> Message-ID: Hi Al, Al Niessner writes: > Is it possible through the long list of XSD options that I thumbed > through tom make XSD actually include all of hte xsd:includes into a > larger more complete schema and map that new thing to C++? No there is no such option. Normally, when people split their schemas into several files it is to make them more manageable and facilitate reuse. It makes sense to preserve the same properties when generating the corresponding C++ code. For cases like yours, where included schemas are invalid by themselves, there is the file-per-type mode. > I tried --file-per-type but that did not do it either. It still crashed > when it hit an unknown in b.xsd that was referencing a.xsd even though > a.xsd was included just before b.xsd. In the file-per-type mode you only compile the "top" schema, that is, the schema that includes all other schemas (d.xsd in your case). If that schema is complete then you shouldn't get any errors. See this article for more information: http://www.codesynthesis.com/~boris/blog/2008/02/13/codesynthesis-xsd-3-1-0-released/ If you are still getting errors while compiling your d.xsd with the --file-per-type option, then I will need to take a look at your schemas or a test case that reproduces the problem. Boris From bbhacohen at gmail.com Fri Jun 12 10:35:06 2009 From: bbhacohen at gmail.com (Batya Hacohen) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Compiling CSTA XSD files In-Reply-To: References: <892a207d0906111429q3cfae54ch643edd0cf3adcbaf@mail.gmail.com> Message-ID: <892a207d0906120735j503bd007j96185396b4178e18@mail.gmail.com> Hi Boris, Sorry about the CC I did reply and not reply-all. I was compiling the the file with the following: "C:\Program Files\CodeSynthesis XSD 3.2\bin\xsd" cxx-tree --root-element-none --anonymous-regex "#.* .* (.+)/(.+)#$1_$2#" --root-element-all --namespace-map http://www.ecma-international.org/standards/ecma-323/csta/ed4=CSTA4--generate-serialization --generate-inline --output-dir ".\src" "$(InputPath)" Now I see that I did it with --root-element-none :-( Thanks a lot Boris On Fri, Jun 12, 2009 at 11:34 AM, Boris Kolpackov wrote: > Hi Batya, > > Again, I ask you to keep your replies CC'ed to the xsd-users > mailing list. See the Posting Guidelines for more information: > > http://www.codesynthesis.com/support/posting-guidelines.xhtml > > > Batya Hacohen writes: > > > I am trying for hours to start my CSTA project and failed to call the > > parsing method. > > I am starting with make-call.xsd and I do not see in the make-call.cxx > and > > make-call.hxx a method for parsing. > > I was looking at the examples and see method like: > > > > // Parse a URI or a local file. > > > > ::std::auto_ptr< ::hello_t > > > > > hello (const ::std::string& uri, > > > > ::xml_schema::flags f = 0, > > > > const ::xml_schema::properties& p = ::xml_schema::properties ()); > > > > I don't see anything like this in my files. > > If you don't see these methods then it means you have disabled their > generation with either --suppress-parsing or one of the --root-element-* > options. If I compile make-call.xsd without --suppress-parsing and > with just --root-element-all, then I get the parsing functions for > MakeCall and MakeCallResponse generated. > > Boris > From Al.Niessner at jpl.nasa.gov Fri Jun 12 12:16:32 2009 From: Al.Niessner at jpl.nasa.gov (Al Niessner) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] xsd:include In-Reply-To: References: <1244760342.3032.183.camel@morte.jpl.nasa.gov> Message-ID: <1244823392.3032.197.camel@morte.jpl.nasa.gov> On Fri, 2009-06-12 at 01:51 -0700, Boris Kolpackov wrote: > Hi Al, > > Al Niessner writes: > > > Is it possible through the long list of XSD options that I thumbed > > through tom make XSD actually include all of hte xsd:includes into a > > larger more complete schema and map that new thing to C++? > > No there is no such option. Normally, when people split their schemas > into several files it is to make them more manageable and facilitate > reuse. It makes sense to preserve the same properties when generating > the corresponding C++ code. For cases like yours, where included > schemas are invalid by themselves, there is the file-per-type mode. Unfortunate, but I can deal with it. It is interesting that you point out reuse as a reason for the include. I am reusing a.xsd in the sense that b.xsd builds a more complex type that uses what is defined in a.xsd. In some sense, b.xsd inherits a.xsd. Not really and nor does it extend a.xsd but it certainly requires it. Hence, I am making my schema more manageable and reusing it to its fullest. I just find it surprising that your first statement implies that people make a bunch of atomic types and then include those in one final schema rather than layering it and adding complexity slowly. Ah well, it does not really matter in the end. The tool is what it is and I want to use it to its fullest as built rather than wish that it did something else. -- Al Niessner 818.354.0859 -------- | dS | >= 0 -------- From Al.Niessner at jpl.nasa.gov Fri Jun 12 12:23:44 2009 From: Al.Niessner at jpl.nasa.gov (Al Niessner) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] xsd:include In-Reply-To: References: <1244760342.3032.183.camel@morte.jpl.nasa.gov> Message-ID: <1244823824.3032.200.camel@morte.jpl.nasa.gov> On Fri, 2009-06-12 at 01:51 -0700, Boris Kolpackov wrote: > Hi Al, > > Al Niessner writes: > > I tried --file-per-type but that did not do it either. It still crashed > > when it hit an unknown in b.xsd that was referencing a.xsd even though > > a.xsd was included just before b.xsd. > > In the file-per-type mode you only compile the "top" schema, that is, > the schema that includes all other schemas (d.xsd in your case). If > that schema is complete then you shouldn't get any errors. See this > article for more information: > > http://www.codesynthesis.com/~boris/blog/2008/02/13/codesynthesis-xsd-3-1-0-released/ > > If you are still getting errors while compiling your d.xsd with the > --file-per-type option, then I will need to take a look at your > schemas or a test case that reproduces the problem. > > Boris When I type the compile command correctly (I was compiling the wrong schema previously), it all works just fine with the -file-per-type option. It all compiles and runs without any changes. Thanks for your help. -- Al Niessner 818.354.0859 -------- | dS | >= 0 -------- From m1eberha at itec.uni-klu.ac.at Mon Jun 15 10:06:05 2009 From: m1eberha at itec.uni-klu.ac.at (Michael Eberhard) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Error using generated mapping-files for schema MPEG-21 DIA Message-ID: <005301c9edc2$6c77aaf0$456700d0$@uni-klu.ac.at> Hi Boris, I am trying to use CodeSynthesis XSD to access XML documents formatted according to MPEG-21 Digital Item Adaptation (DIA). I am using the xsd-3.2.0-i686-linux-gnu distribution and compile the generated mapping files using g++. The mapping files are generated based on the following XML schemes and with the following commands: - MPEG-21 DIA: xsd cxx-tree --namespace-map urn:mpeg:mpeg21:2003:01-DIA-NS=dia --namespace-map urn:mpeg:mpeg7:schema:2001=mpeg7 --namespace-map urn:mpeg:mpqf:schema:2008=mpqf MXM-DIA+UCD.xsd - MPEG-7 UDP: xsd cxx-tree --namespace-map urn:mpeg:mpeg7:schema:2001=mpeg7 mpeg7-udp-2004.xsd - MPEG Query Format: xsd cxx-tree --namespace-map urn:mpeg:mpqf:schema:2008=mpqf mpqf-acap.xsd - XML: xsd cxx-tree xml-1998.xsd To make the generation of the mapping files work, I had to replace the AudioPresentationPreferencesType in the MPEG-21 DIA scheme in lines 222-322 with the dummy type in lines 217-221 (I was not able to find out why this type lead to an error, but as it is not essential for my work I moved on without it). With the changes and commands mentioned above I was able to successfully create the mapping files. However, whenever I try to access the attributes for this UED-example as illustrated in the polymorphism-example, I get an error that I could not backtrack so far. I don't really know what else I could try to get the schema mappings to work, so I would be grateful for any help. Thanks & best regards, Michael From boris at codesynthesis.com Mon Jun 15 14:50:06 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] xsd:include In-Reply-To: <1244823392.3032.197.camel@morte.jpl.nasa.gov> References: <1244760342.3032.183.camel@morte.jpl.nasa.gov> <1244823392.3032.197.camel@morte.jpl.nasa.gov> Message-ID: Hi Al, Al Niessner writes: > Unfortunate, but I can deal with it. It is interesting that you point > out reuse as a reason for the include. I am reusing a.xsd in the sense > that b.xsd builds a more complex type that uses what is defined in > a.xsd. In some sense, b.xsd inherits a.xsd. Not really and nor does it > extend a.xsd but it certainly requires it. Hence, I am making my schema > more manageable and reusing it to its fullest. Yes, that's the technique that I refer to, provided you xsd:include a.xsd in b.xsd. There are, however, cases where people would have a.xsd and b.xsd depend on types from each other. From the re-usability point of view, such an arrangement is the same as where everything is defined in one schema. > I just find it surprising that your first statement implies that people > make a bunch of atomic types and then include those in one final schema > rather than layering it and adding complexity slowly. I certainly didn't mean to imply this ;-). The XSD compiler provides good support for common use cases of xsd:include and provides fall-back support (the file-per-type mode) for others. The well supported approach boils down to having self-sufficient schema files (i.e., they include all the schemas that they use instead of relying on one "top" schema to include everything) and they don't have include cycles (actually, XSD is able to generate working code for mutually included schemas as long as the dependencies do not involve type inheritance). Boris From boris at codesynthesis.com Mon Jun 15 15:56:06 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Error using generated mapping-files for schema MPEG-21 DIA In-Reply-To: <005301c9edc2$6c77aaf0$456700d0$@uni-klu.ac.at> References: <005301c9edc2$6c77aaf0$456700d0$@uni-klu.ac.at> Message-ID: Hi Michael, Michael Eberhard writes: > To make the generation of the mapping files work, I had to replace the > AudioPresentationPreferencesType in the MPEG-21 DIA scheme in lines 222-322 > with the dummy type in lines 217-221 (I was not able to find out why this > type lead to an error, but as it is not essential for my work I moved on > without it). Hm, with the original schema the compiler crashes. I will take a closer look at this and will let you know what I find. > With the changes and commands mentioned above I was able to successfully > create the mapping files. However, whenever I try to access the attributes > for this UED-example > as illustrated in the polymorphism-example, I get an error that I could not > backtrack so far. Your XML document uses xsi:type while you compiled your schemas without --generate-polymorphic. I am pretty sure this is the cause of your problems. See Section 2.11, "Mapping for xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual for details: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11 Boris From Batya.Hacohen at tadirantele.com Tue Jun 16 03:53:09 2009 From: Batya.Hacohen at tadirantele.com (Batya Hacohen) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] getting "different target namespace " for CSTA XML files In-Reply-To: References: Message-ID: Hi Boris, I am trying to parse the ConnectionClearedEvent XML, that I have produced by my program. I added the following in my code: xml_schema::properties props; props.no_namespace_schema_location ("file:///" + std::string (cwd) + "\\"+"connection-cleared-event.xsd"); props.schema_location ("http://www.w3.org/2001/XMLSchema", "file:///" + std::string (cwd) + "\\"+"connection-cleared-event.xsd"); using namespace CSTA4; cout << msg << endl; std::istringstream istr (msg); std::auto_ptr mc (ConnectionClearedEvent_ (istr, 0, props)); This is the input XML: 23aaabbbhhhaCDBusy :1:153 error: schema document 'file:///D:\xmlCompiler\CstaXMLLib\xsdsrc\connecti on-cleared-event.xsd' has different target namespace from the one specified in i nstance document '' :1:153 error: no declaration found for element 'ConnectionClearedEvent' Please Advice Batya From boris at codesynthesis.com Tue Jun 16 06:58:44 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Re: getting "different target namespace " for CSTA XML files In-Reply-To: References: Message-ID: Hi Batya, Batya Hacohen writes: > I am trying to parse the ConnectionClearedEvent XML, that I have > produced by my program. > > I added the following in my code: > > xml_schema::properties props; > > props.no_namespace_schema_location ("file:///" + std::string (cwd) + > "\\"+"connection-cleared-event.xsd"); This is wrong. If you look into connection-cleared-event.xsd you will see that it has target namespace http://www.ecma-international.org/standards/ecma-323/csta/ed4 So the above statement should be: props.schema_location ( "http://www.ecma-international.org/standards/ecma-323/csta/ed4", "file:///" + std::string (cwd) + "\\"+"connection-cleared-event.xsd"); > props.schema_location ("http://www.w3.org/2001/XMLSchema", > > "file:///" + std::string (cwd) + > "\\"+"connection-cleared-event.xsd"); This is wrong and unnecessary. Simply remove this statement. > This is the input XML: > > > xmlns:p1="http://www.ecma-international.org/standards/ecma-323/csta/ed4"> > ... This XML document is invalid per the connection-cleared-event.xsd schema. The ConnectionClearedEvent element should be in the http://www.ecma-international.org/standards/ecma-323/csta/ed4 namespace while in the above document it is unqualified. A valid document beginning would look like this: Or like this: Boris From olof.tangrot at telia.com Thu Jun 18 15:28:33 2009 From: olof.tangrot at telia.com (olof.tangrot@telia.com) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Tree-parser constructor fails Message-ID: <23995270.213261245353313706.JavaMail.defaultUser@defaultHost> Hi, there. I have written the xsd (which I belive is correct since XML-notepad parses it without problems): Then I tried to build the parser using: xsd cxx-tree --root-element CANRepos CANRepos.xsd That the generated code (based on the hello-example) is used to parse the content (which I also belive is correct since it was entered using XML-nodpad and verified using the above xsd): CCAN_Frame1 CCAN_DataVX But then the constructor auto_ptr h (CANRepos (argv [1])); fails emitting error messages like: C:\Documents and Settings\olof\Mina dokument\project\FreeCAN\XML- parser\RepositoryParser\Debug>RepositoryParser.exe ../../.. /XML/CANrepos2.xml C:\Documents and Settings\olof\Mina dokument\project\FreeCAN/XML/CANrepos2.xml:2:11 error: no declaration found for element 'CANRepos' C:\Documents and Settings\olof\Mina dokument\project\FreeCAN/XML/CANrepos2.xml:3:13 error: no declaration found for element 'CANFrame' C:\Documents and Settings\olof\Mina dokument\project\FreeCAN/XML/CANrepos2.xml:4:19 error: no declaration found for element 'CANFrameName' C:\Documents and Settings\olof\Mina dokument\project\FreeCAN/XML/CANrepos2.xml:6:13 error: no declaration found for element 'CANFrame' C:\Documents and Settings\olof\Mina dokument\project\FreeCAN/XML/CANrepos2.xml:7:19 error: no declaration found for element 'CANFrameName' I just don't get it. What have I done wrong? Regards Olof From boris at codesynthesis.com Thu Jun 18 17:57:57 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Tree-parser constructor fails In-Reply-To: <23995270.213261245353313706.JavaMail.defaultUser@defaultHost> References: <23995270.213261245353313706.JavaMail.defaultUser@defaultHost> Message-ID: Hi Olof, olof.tangrot@telia.com writes: > But then the constructor auto_ptr h (CANRepos (argv)); > fails emitting error messages like: > > CANrepos2.xml:2:11 error: no declaration found for element 'CANRepos' > ... This is FAQ #2.1: http://wiki.codesynthesis.com/Tree/FAQ Boris From olof.tangrot at telia.com Fri Jun 19 01:22:23 2009 From: olof.tangrot at telia.com (Olof =?ISO-8859-1?Q?T=E5ngrot?=) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Tree-parser constructor fails In-Reply-To: References: <23995270.213261245353313706.JavaMail.defaultUser@defaultHost> Message-ID: <1245388943.2801.2.camel@localhost.localdomain> Thanks! For my futre understanding of other faults that might occur. Why is this not required in the hello-example? On Thu, 2009-06-18 at 23:57 +0200, Boris Kolpackov wrote: > Hi Olof, > > olof.tangrot@telia.com writes: > > > But then the constructor auto_ptr h (CANRepos (argv)); > > fails emitting error messages like: > > > > CANrepos2.xml:2:11 error: no declaration found for element 'CANRepos' > > ... > > This is FAQ #2.1: > > http://wiki.codesynthesis.com/Tree/FAQ > > Boris From boris at codesynthesis.com Fri Jun 19 04:26:19 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Tree-parser constructor fails In-Reply-To: <1245388943.2801.2.camel@localhost.localdomain> References: <23995270.213261245353313706.JavaMail.defaultUser@defaultHost> <1245388943.2801.2.camel@localhost.localdomain> Message-ID: Hi Olof, Olof T?ngrot writes: > For my futre understanding of other faults that might occur. > > Why is this not required in the hello-example? The hello.xml file in the hello example uses the noNamespaceSchemaLocation attribute to specify the schema. If you remove it you will get similar errors. Boris From bpringle at sympatico.ca Fri Jun 19 13:18:54 2009 From: bpringle at sympatico.ca (Bill Pringlemeir) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Non-xml data in attributes with xsd:string, xsd:normalizedString In-Reply-To: (Boris Kolpackov's message of "Sun, 22 Feb 2009 19:42:25 +0200") References: <87r61vb2ni.fsf@sympatico.ca> <87bpsye6yz.fsf@sympatico.ca> Message-ID: <87eitgb0qp.fsf@sympatico.ca> On 22 Feb 2009, boris@codesynthesis.com wrote: > Bill Pringlemeir writes: >> It appears that 'tab', etc are escaped. I guess that there is no >> allowable XML character reference for some values. I thought that >> only 'null'/zero would be disallowed. > XML 1.0 disallows quite a few control characters. XML 1.1 only > disallows zero. I have used the FAQ, http://wiki.codesynthesis.com/Tree/FAQ section "3.2 How do I serialize a Xerces-C++ DOM document to XML?" to specify the XML 1.1 as the destination. This works well. >> So it seems if the data contains this range, you must use >> 'base64Binary'? > Correct. Or XML 1.1 which is supported by Xerces-C++. There are still some issue, if one just converts to XML 1.1. It seems that 'transcode()' converts to either UTF-8 or UTF-16. Are these the default encoding for XMLChar* that Xerces expects? The 'transcode()' method will throw exceptions for a large amount (perhaps all) characters over 0x80. These are the UTF-8 escapes. There is no documentation on this in section 4.4 of the user manual (ie, the transcode() exceptions). I have read the FAQ on encodings. I think that there are several different places that encodings can be used. std::string -> locale or straight binary? xml_schema::string -> UTF-8 or identical to std::string. If I am using the generated accessors and place '8-bit' data there, is it the callers responsibility to replace these by entities? The transcode() functionality will seem to interpret these as UTF-8 multiple character encodings. Xerces -> UTF-8, UTF-16 dependant on wchar_t. resultant XML -> as specified in xml header. I guess that Xerces mandates a UTF-? encoding. Does Xereces then convert to the specified encoding, for instance 'US-ASCII' [called 'USASCII' by XSD information **1]. It is still unclear to me if this is simple a string put in the XML header or if Xerces actually performs translation. Is the best tact to create a DOM tree and walk this converting all strings to entity declarations above 0x7f or can one replace/extend the transcode functionality to do this? Is this the most effective way to do this if the source/destination for the XML are in the same locale and binary preservation is a goal? Thanks, Bill Pringlemeir. ** 1 The IANA recommendation is to use 'US-ASCII'. And this seems to be popular with other XML decoders. Where is 'USASCII' from. This seems to be a defacto encoding naming and is not specified by W3C. -- Little girls, like butterflies need no excuses. - Robert Heinlein From atteeela at gmail.com Sat Jun 20 17:10:29 2009 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Just want to create an instance of an element and populate sub-elements Message-ID: <4aeb04aa0906201410m1703fcbbta5999718b1158de1@mail.gmail.com> Hi, Say I have a Person object which is composed of a choice between the following 2 string elements: RealName or Nickname. I would like to instantiate an empty Person object and set the RealName or Nickname and then serialize it to a std::string. How can I accomplish this? Thank you -- Attila Software Developer atteeela@gmail.com From atteeela at gmail.com Sat Jun 20 23:31:15 2009 From: atteeela at gmail.com (Attila) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Re: Just want to create an instance of an element and populate sub-elements In-Reply-To: <4aeb04aa0906201410m1703fcbbta5999718b1158de1@mail.gmail.com> References: <4aeb04aa0906201410m1703fcbbta5999718b1158de1@mail.gmail.com> Message-ID: <4aeb04aa0906202031t16513efcs1d6da4be1b6a2576@mail.gmail.com> Thanks I figured it out! On Sat, Jun 20, 2009 at 5:10 PM, Attila wrote: > Hi, > > Say I have a Person object which is composed of a choice between the > following 2 string elements: RealName or Nickname. > > I would like to instantiate an empty Person object and set the RealName or > Nickname and then serialize it to a std::string. > How can I accomplish this? > > Thank you > > -- > Attila > Software Developer > atteeela@gmail.com > -- Attila Software Developer atteeela@gmail.com From kmarianski at mikronika.com.pl Thu Jun 25 06:42:22 2009 From: kmarianski at mikronika.com.pl (=?ISO-8859-2?Q?Krzysztof_Maria=F1ski?=) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] XSD wildcard content Message-ID: <4A43548E.50002@mikronika.pl> Hi Boris and xsd-users, I've encountered a problem with 'any' element. Consider following example: my text cant read this value Element 'Private' has element 'any' with sequence cardinality class (see attached schema). Problem is I cannot read a value of element. I can't also write (serialize) such an element, because in code (according to http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12.3) I must create element, which I don't want to do. If I create element (for example ) and then set its text content I get something like this: some value Is there any possibility to get rid of 'dummy' and to write (and read!) the value directly to 'Private' element? Thanks in advance Krzysiek -------------- next part -------------- A non-text attachment was scrubbed... Name: xsd-wildcard.zip Type: application/x-zip-compressed Size: 2171 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090625/3fc886af/xsd-wildcard.bin From boris at codesynthesis.com Thu Jun 25 23:09:23 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] XSD wildcard content In-Reply-To: <4A43548E.50002@mikronika.pl> References: <4A43548E.50002@mikronika.pl> Message-ID: Hi Krzysztof, Krzysztof Maria?ski writes: > cant read this value > > [...] > > Element 'Private' has element 'any' with sequence cardinality class (see > attached schema). > Problem is I cannot read a value of element. > I can't also write (serialize) such an element, because in code > (according to > http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12.3) > I must create element, which I don't want to do. If I create element > (for example ) and then set its text content I get something like > this: > > some value > > > Is there any possibility to get rid of 'dummy' and to write (and read!) > the value directly to 'Private' element? The reason why the 'Private' element can have text content (the one which you want to read/write) is because it has mixed content, not because it has the 'any' wildcard. The recommended way to handle types with mixed content in C++/Tree is to customize them and read/write the data using the DOM interface in the parsing c-tor and in the serialization operator, respectively. For more information on type customization see the C++/Tree Mapping Customization Guide: http://wiki.codesynthesis.com/Tree/Customization_guide As well as the examples in the examples/cxx/tree/custom/ directory. The 'wildcard' example in this directory does something very similar to what you want to do so your can use it as a reference point. Boris From boris at codesynthesis.com Fri Jun 26 01:03:57 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Re: Questions & Propositions for CodeSynthesis XSD developer(s) In-Reply-To: <4A433D8B.8060702@mail.ru> References: <4A433D8B.8060702@mail.ru> Message-ID: Hi, In the future please send questions about CodeSynthesis XSD to the xsd-users@codesynthesis.com mailing list instead of to me directly. See the posting guidelines for more information: http://www.codesynthesis.com/support/posting-guidelines.xhtml zanneo writes: > I have some questions and propositions for CodeSynthesis XSD developer(s): > 1. Can further XSD version generate C++ classes that use some abstract > interface for parser. For example, now classes and templates use strict > binding to Xerces C++. We considered this idea but decided against implementing something like this because the C++/Tree API is "integrated" with the underlying DOM API in several areas, namely: - wildcard content (xs:any/xs:anyAttribute) - DOM node association / XPath processing - object model customization Supporting this properly would require providing a fairly complete wrapping of the native DOM API which would add a significant amount of code and slow things down. So we decided to go for simplicity rather than flexibility in this area. Plus, the C++/Tree mapping relies on the XML Schema validation in the underlying XML parser and there are no other open-source parsers that have working (let alone mature) XML Schema support other than Xerces-C++. > I want to use TinyXml parser for DOM. Note that TinyXML is not a conforming XML 1.0 parser. It can only parse a subset of valid XML documents. See this blog post for details: http://www.codesynthesis.com/~boris/blog/2008/05/19/real-xml-parser/ If size is the reason for you wanting to use TinyXML instead of Xerces-C++ then you may want to consider XSD/e and its C++/Hybrid mapping: http://www.codesynthesis.com/products/xsde/ You will get an API similar to C++/Tree with a much smaller footprint, even smaller than if you were using C++/Tree with TinyXML instead of Xerces-C++. > 2. I don't understand, how I can use generated classes that interpret > enumeration from XML Schema. Some generated class has two static arrays: > first with values, second - with names. But I've drawn attention that > values by indexes from one array don't match with values by even(!) > indexes from other array. String-based enumerations in C++/Tree are mapped to C++ classes that provides a dual interface: that of the base type (e.g., string or token) and of the type that behaves similar to a C++ enum. See Section 2.6.4, "Mapping for Enumerations" in the C++/Tree Mapping User Manual: http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.6.2 In particular, if you have the following enumeration defined in schema: Then you can get the enum value as a string: color c = ... std::string& sc = c; Or as a C++ enum value: color c = ... color::value ec = c; switch (ec) { case color::red: { ... } case color::green: { ... } } The arrays that you see are internal implementation details. Boris From boris at codesynthesis.com Fri Jun 26 15:13:28 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:10 2009 Subject: [xsd-users] Non-xml data in attributes with xsd:string, xsd:normalizedString In-Reply-To: <87eitgb0qp.fsf@sympatico.ca> References: <87r61vb2ni.fsf@sympatico.ca> <87bpsye6yz.fsf@sympatico.ca> <87eitgb0qp.fsf@sympatico.ca> Message-ID: Hi Bill, Bill Pringlemeir writes: > There are still some issue, if one just converts to XML 1.1. It seems > that 'transcode()' converts to either UTF-8 or UTF-16. Are these the > default encoding for XMLChar* that Xerces expects? I assume you are talking about xercesc::XMLString::transcode(). XMLCh in Xerces-C++ always contains UTF-16. XMLString::transcode() converts to the "local code page" encoding. What that means depends on the operating system. On some platforms (e.g., UNIX-like) you could set the local code page with the call to setlocale. On other platforms (e.g., Windows), the local code page is preset and cannot be changed. Then there are xsd::cxx::xml::transcode() (from XMLCh* to char* or wchar_t*) and xsd::cxx::xml::transcode_to_xmlch() (from char* or wchar_t* to XMLCh*; the xsd::cxx::xml::string class is normally used instead of using this function directly). These two functions assume that char* is UTF-8 unless the application is compiled with the XSD_USE_LCP macro. See FAQ #1.2 for more information: http://wiki.codesynthesis.com/Tree/FAQ > The 'transcode()' method will throw exceptions for a large amount > (perhaps all) characters over 0x80. These are the UTF-8 escapes. Yes, by default (and when the character type is 'char') all the text in the object model is expected to be in UTF-8. > There is no documentation on this in section 4.4 of the user manual > (ie, the transcode() exceptions). Will address for the next release, thanks. > I have read the FAQ on encodings. I think that there are several > different places that encodings can be used. > > std::string -> locale or straight binary? > xml_schema::string -> UTF-8 or identical to std::string. Not sure what you mean here. All the text data in the object model is stored in types that are derived (directly or indirectly) from std::string. They all by default contain and are expect to contain UTF-8-encoded text. > If I am using the generated accessors and place '8-bit' data there, > is it the callers responsibility to replace these by entities? No, entities are handled by the serializer. The caller's responsibility is to place valid UTF-8 data in there. I guess in your situation, if you can control the local code page, it might be more straightforward to use XSD_USE_LCP and set the code page to something like US-ASCII. > I guess that Xerces mandates a UTF-? encoding. Does Xereces then > convert to the specified encoding, for instance 'US-ASCII'. There are three encoding at play here, the second is normally not visible to the end-user, except for some situations: 1. The encoding in the object model. This is by default UTF-8. 2. The UTF-16 encoding used in Xerces-C++. 3. The encoding of the resulting XML document. This can be specified in the serialization function. Conversion between (1) and (2) is performed by the object model, between (2) and (3) -- by Xerces-C++. > Is the best tact to create a DOM tree and walk this converting all > strings to entity declarations above 0x7f or can one replace/extend > the transcode functionality to do this? No, the entities are handled automatically by the XML serializer. All you need to do is provide the correctly encoded text in the object model. > Is this the most effective way to do this if the source/destination > for the XML are in the same locale and binary preservation is a goal? I think the simplest way would be to use XSD_USE_LCP and set the local code page to US-ASCII. But the availability of this approach depends on the OS(es) you are targeting. Otherwise you will need to make sure your binary data is properly UTF-8-encoded (i.e., characters above 0x7F are replaced with two-byte sequences). > ** 1 The IANA recommendation is to use 'US-ASCII'. And this seems to > be popular with other XML decoders. Where is 'USASCII' from. This > seems to be a defacto encoding naming and is not specified by W3C. Xerces-C++ supports both US-ASCII and USASCII. I am not sure why they use USASCII in their documentation. I have updated the XSD documentation to use US-ASCII. Thanks for letting me know. Boris