From Chang_Chen at sonic.com Sun Mar 1 23:17:21 2009 From: Chang_Chen at sonic.com (Chang Chen) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] taxonomy issue Message-ID: <51C471E6CBEC8148A08E065690F4DBDF03442D93@SHAEXC01.ent.sonic.com> Hi Boris I run the taxonomy example, but with following example.xml: Joe Dirt James "007" Bond Bruce Wayne The output is: Joe Dirt James "007" Bond Flying superman Bruce Wayne This is obvious issue! I guess the reason should be the type_factory_initializer static const ::xsd::cxx::tree::type_factory_initializer< 0, char, ~~superman_base~~ > _xsd_superman_base_type_factory_init ( "superman", "http://www.codesynthesis.com/people"); Should rename to static const ::xsd::cxx::tree::type_factory_initializer< 0, char, ~~superman~~ > _xsd_superman_base_type_factory_init ( "superman", "http://www.codesynthesis.com/people"); Thanks Chang From sir.costy at gmail.com Mon Mar 2 03:55:26 2009 From: sir.costy at gmail.com (Constantin Iacobescu) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] XSD cd-Tree - LandXML Wrong Serializing Message-ID: Hello, I had tried to parse and serialize an xml file which use the LandXML.xsd specifications. So the binding command was some like: xsd cxx-tree --generate-serialization --generate-polymorphic --generate-doxygen --generate-wildcard --generate-ostream --type-naming java --function-naming java --namespace-map http://www.landxml.org/schema/LandXML-1.2=NSXML LandXML-1.2.xsd The input xml fil start like this: But now is coming the bad think because the serialized file looks some different. Always has this "p1:" thing which I think is related with some namespace trouble. The code use to made that is very simple, just loading and parsing the xml file and then serializing it using namespace xercesc; XMLPlatformUtils::Initialize (); try { using namespace NSXML; namespace xml = xsd::cxx::xml; namespace tree = xsd::cxx::tree; std::auto_ptr objLandXML ( parseLandXML("InXML.xml", xml_schema::Flags::dont_initialize)); // and now serialize it std::ofstream ofs; ofs.open ("OutXML.xml"); serializeLandXML (ofs, *objLandXML) } Some simple thing but I don?t understand what?s going wrong by here that is generated that "p1" thing. Please help me. Regards, Constantin Iacobescu From Jason.Lee at syniverse.com Mon Mar 2 03:51:27 2009 From: Jason.Lee at syniverse.com (Jason Lee) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] reading directly from memory buffer instead of file or URL Message-ID: Hi, I am working on the xsd-tree helloworld sample. auto_ptr h (hello ("c:/hello.xml")); By reading the header file hello.hxx I realise the constructor only takes in 4 types of input: 1. std::string (a URI or a local file) 2. std::istream 3. xercesc::InputSource 4. xercesc::DOMDocument Is it possible to read and parse a xml source directly from a memory buffer instead of from a local file or a URL? Thanks and regards, Jason From sir.costy at gmail.com Mon Mar 2 04:37:44 2009 From: sir.costy at gmail.com (Constantin Iacobescu) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Fwd: XSD cd-Tree - LandXML Wrong Serializing In-Reply-To: References: Message-ID: Hi, I think i found where I have wrong. I supposed that the NamespaceInfomap is also saved and you don't have to create it again. So the working code shold be this. xml_schema::NamespaceInfomap infoMap; infoMap[""].name = "http://www.landxml.org/schema/LandXML-1.2"; infoMap[""].schema = " http://www.landxml.org/schema/LandXML-1.2/LandXML-1.2.xsd"; serializeLandXML (ofs, *objLandXML, infoMap ); Regards Costy ---------- Forwarded message ---------- From: Constantin Iacobescu Date: Mon, Mar 2, 2009 at 9:55 AM Subject: XSD cd-Tree - LandXML Wrong Serializing To: xsd-users@codesynthesis.com Hello, I had tried to parse and serialize an xml file which use the LandXML.xsd specifications. So the binding command was some like: xsd cxx-tree --generate-serialization --generate-polymorphic --generate-doxygen --generate-wildcard --generate-ostream --type-naming java --function-naming java --namespace-map http://www.landxml.org/schema/LandXML-1.2=NSXML LandXML-1.2.xsd The input xml fil start like this: But now is coming the bad think because the serialized file looks some different. Always has this "p1:" thing which I think is related with some namespace trouble. The code use to made that is very simple, just loading and parsing the xml file and then serializing it using namespace xercesc; XMLPlatformUtils::Initialize (); try { using namespace NSXML; namespace xml = xsd::cxx::xml; namespace tree = xsd::cxx::tree; std::auto_ptr objLandXML ( parseLandXML("InXML.xml", xml_schema::Flags::dont_initialize)); // and now serialize it std::ofstream ofs; ofs.open ("OutXML.xml"); serializeLandXML (ofs, *objLandXML) } Some simple thing but I don?t understand what?s going wrong by here that is generated that "p1" thing. Please help me. Regards, Constantin Iacobescu -- Constantin Iacobescu From boris at codesynthesis.com Mon Mar 2 08:03:24 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] taxonomy issue In-Reply-To: <51C471E6CBEC8148A08E065690F4DBDF03442D93@SHAEXC01.ent.sonic.com> References: <51C471E6CBEC8148A08E065690F4DBDF03442D93@SHAEXC01.ent.sonic.com> Message-ID: Hi Chang, Chang Chen writes: > static > const ::xsd::cxx::tree::type_factory_initializer< 0, char, ~~superman_base~~ > > _xsd_superman_base_type_factory_init ( > "superman", > "http://www.codesynthesis.com/people"); > > Should rename to > > static > const ::xsd::cxx::tree::type_factory_initializer< 0, char, ~~superman~~ > > _xsd_superman_base_type_factory_init ( > "superman", > "http://www.codesynthesis.com/people"); I assume you are customizing the superman type. If so, then, yes, this is a known bug in 3.2.0 that has been fixed for the next release. There is a pre-release binary for Windows with this fixed: http://codesynthesis.com/~boris/tmp/xsd-3.3.0.a4-i686-windows.zip I can also build you one for GNU/Linux if you would like. Thanks for reporting this! Boris From boris at codesynthesis.com Mon Mar 2 08:08:05 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] reading directly from memory buffer instead of file or URL In-Reply-To: References: Message-ID: Hi Jason, Jason Lee writes: > By reading the header file hello.hxx I realise the constructor only > takes in 4 types of input: > > 1. std::string (a URI or a local file) > > 2. std::istream > > 3. xercesc::InputSource > > 4. xercesc::DOMDocument > > Is it possible to read and parse a xml source directly from a memory > buffer instead of from a local file or a URL? Yes, you can use std::istringstream ( header) if you buffer is a simple string or you can use Xerces-C++ MemBufferInputSource for any kind of memory buffer. The 'performance' example shows how to use the latter (see the parsing.cxx file). Boris From sir.costy at gmail.com Tue Mar 3 11:38:47 2009 From: sir.costy at gmail.com (Constantin Iacobescu) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Error parsing nested elements Message-ID: Hi, I'm parsing a xml file which is made using the LandXML-1.2 schema. Till I did not had nested elements the things was ok. Then I thought to get a bit deeper. This is the binding command used: xsd cxx-tree --generate-serialization --generate-polymorphic --generate-doxygen --generate-wildcard --generate-ostream --root-element-all --type-naming java --function-naming java --namespace-map http://www.landxml.org/schema/LandXML-1.2=LandXML_12 LandXML-1.2.xsd After including in the xml file nested elements I get parser runing error like this: "InXML.xml:19:13 error: element 'CgPoint' is not allowed for content model '<,Feature>' The XSD CgPoints is like: A collection of COGO points. (Cg = COGO = Cordinate Geometry) And the xml file looks like this: 4837.18515853 4938.54608259 9.56751464 4814.57301769 4926.33931189 10.09267518 4768.07489136 4942.62719383 9.71152459 4720.62990560 4943.01498325 10.39206007 4672.47163351 4943.66059514 11.02326614 4640.62733892 4935.52350112 11.56814872 4608.96231647 4915.99543068 11.92946751 4577.45525920 4880.77770666 12.94695546 All the main function is doing is: XMLPlatformUtils::Initialize (); std::auto_ptr objLandXML ( parseLandXML(fileName, xml_schema::Flags::dont_initialize)); XMLPlatformUtils::Terminate (); I don`t know what I'm doin wrong and what that error mean. Please help me if anyone know what it is about. Thanks, Constantin Iacobescu From boris at codesynthesis.com Wed Mar 4 00:58:01 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Error parsing nested elements In-Reply-To: References: Message-ID: Hi Constantin, Constantin Iacobescu writes: > > > > > > > > > [...] > In plain English the content model of the CgPoints element is any number of CgPoint elements, followed by any number of CgPoints elements, followed by any number of Feature elements. > > 4837.18515853 4938.54608259 9.56751464 > 4814.57301769 4926.33931189 10.09267518 > 4768.07489136 4942.62719383 9.71152459 > > 4720.62990560 4943.01498325 10.39206007 > 4672.47163351 4943.66059514 11.02326614 > 4640.62733892 4935.52350112 11.56814872 > > 4608.96231647 4915.99543068 11.92946751 > 4577.45525920 4880.77770666 12.94695546 > Now if we look at your XML fragment, we can see that it does not conform to the above content model: you have two CgPoint elements following a CgPoints element. If you move the last two CgPoint elements before CgPoints, then everything should validate Ok. Boris From Laura_E_Fowler at raytheon.com Thu Mar 5 09:13:27 2009 From: Laura_E_Fowler at raytheon.com (Laura E Fowler) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType Message-ID: I'm using C++/Tree, XSD 3.1.0 and Xerces 2.6.0. We are using XML messages to command our system. I need to grab a copy of the received command and return a copy of it in a status message. The command copy is defined as anyType in the schema. I patterned my command parsing after the multiroot example using xml_schema::type as the base. I need to save the copy of the command until the status message is formatted at a later time. What is the best way to save a copy of the received command? Thanks, Laura Fowler From boris at codesynthesis.com Thu Mar 5 11:40:53 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType In-Reply-To: References: Message-ID: Hi Laura, Laura E Fowler writes: > We are using XML messages to command our system. I need to grab a copy of > the received command and return a copy of it in a status message. The > command copy is defined as anyType in the schema. > > I patterned my command parsing after the multiroot example using > xml_schema::type as the base. > > I need to save the copy of the command until the status message is > formatted at a later time. > > What is the best way to save a copy of the received command? Ok, let me see if I understood you correctly. You have various command messages (probably defined as types and/or elements in the schema) plus you have a special status message which embeds one of the commands as anyType content, something along these lines: ... ... ... ... Here, the content of command-a or command-b should be stored inside the command element in Status. As you probably know, anyType is special in that it can contain arbitrary content (elements, attributes, text, in any order). It would actually be more straightforward (and more flexible) to handle this case if you were using the any wildcard instead of anyType, for example: ... ... With the wildcard approach you get a convenient DOM-based mapping, as discussed in Section 2.12, "Mapping for any and anyAttribute" in the C++/Tree Mapping User Manual: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12 This way you could just serialize one of the commands into a DOM document fragment corresponding to the wildcard and then, when the Status message is serialized, everything is handled automatically. See the 'wildcard' example in the examples/cxx/tree/ directory for more information. If I had to handle anyType, I would do it like this: I would customize the Status class by (1) adding an additional member to store the command as an object model node or as a DOM document fragment, (2) overriding the parsing constructor to populate this member based on the data supplied for the command element (you will somehow need to know which command it is), and (3) overriding the serialization operator to serialize the command member to the command element. 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 is probably the closest to what you would want to achieve. Boris From Laura_E_Fowler at raytheon.com Thu Mar 5 13:15:08 2009 From: Laura_E_Fowler at raytheon.com (Laura E Fowler) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType In-Reply-To: References: Message-ID: Boris, Thanks for the information. You understood correctly what I'm trying to do. I have control over the schema, so I can change it. I'll look at the manual and the example and see if I can figure out how to use the any wildcard. Thanks, Laura Fowler From: Boris Kolpackov To: Laura E Fowler Cc: xsd-users@codesynthesis.com Date: 03/05/2009 10:51 AM Subject: Re: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType Hi Laura, Laura E Fowler writes: > We are using XML messages to command our system. I need to grab a copy of > the received command and return a copy of it in a status message. The > command copy is defined as anyType in the schema. > > I patterned my command parsing after the multiroot example using > xml_schema::type as the base. > > I need to save the copy of the command until the status message is > formatted at a later time. > > What is the best way to save a copy of the received command? Ok, let me see if I understood you correctly. You have various command messages (probably defined as types and/or elements in the schema) plus you have a special status message which embeds one of the commands as anyType content, something along these lines: ... ... ... ... Here, the content of command-a or command-b should be stored inside the command element in Status. As you probably know, anyType is special in that it can contain arbitrary content (elements, attributes, text, in any order). It would actually be more straightforward (and more flexible) to handle this case if you were using the any wildcard instead of anyType, for example: ... ... With the wildcard approach you get a convenient DOM-based mapping, as discussed in Section 2.12, "Mapping for any and anyAttribute" in the C++/Tree Mapping User Manual: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12 This way you could just serialize one of the commands into a DOM document fragment corresponding to the wildcard and then, when the Status message is serialized, everything is handled automatically. See the 'wildcard' example in the examples/cxx/tree/ directory for more information. If I had to handle anyType, I would do it like this: I would customize the Status class by (1) adding an additional member to store the command as an object model node or as a DOM document fragment, (2) overriding the parsing constructor to populate this member based on the data supplied for the command element (you will somehow need to know which command it is), and (3) overriding the serialization operator to serialize the command member to the command element. 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 is probably the closest to what you would want to achieve. Boris From Laura_E_Fowler at raytheon.com Thu Mar 5 17:32:27 2009 From: Laura_E_Fowler at raytheon.com (Laura E Fowler) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType In-Reply-To: References: Message-ID: Boris, I have been looking at this, but I think I'm not understanding the following statement you made: "This way you could just serialize one of the commands into a DOM document fragment corresponding to the wildcard and then, when the Status message is serialized, everything is handled automatically." I'm a little confused by "DOM document fragment corresponding to the wildcard". I've been looking at the wildcard example, but I'm just not getting it. My schema is similar to: ... ... I serialized my command to a DOMDocument (not a fragment), but I'm unclear as to how put it into commandEcho. I apologize for being slow, but I just haven't worked with XML and XSD enough to be fluent. Thanks, Laura Fowler From: Boris Kolpackov To: Laura E Fowler Cc: xsd-users@codesynthesis.com Date: 03/05/2009 10:51 AM Subject: Re: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType Hi Laura, Laura E Fowler writes: > We are using XML messages to command our system. I need to grab a copy of > the received command and return a copy of it in a status message. The > command copy is defined as anyType in the schema. > > I patterned my command parsing after the multiroot example using > xml_schema::type as the base. > > I need to save the copy of the command until the status message is > formatted at a later time. > > What is the best way to save a copy of the received command? Ok, let me see if I understood you correctly. You have various command messages (probably defined as types and/or elements in the schema) plus you have a special status message which embeds one of the commands as anyType content, something along these lines: ... ... ... ... Here, the content of command-a or command-b should be stored inside the command element in Status. As you probably know, anyType is special in that it can contain arbitrary content (elements, attributes, text, in any order). It would actually be more straightforward (and more flexible) to handle this case if you were using the any wildcard instead of anyType, for example: ... ... With the wildcard approach you get a convenient DOM-based mapping, as discussed in Section 2.12, "Mapping for any and anyAttribute" in the C++/Tree Mapping User Manual: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12 This way you could just serialize one of the commands into a DOM document fragment corresponding to the wildcard and then, when the Status message is serialized, everything is handled automatically. See the 'wildcard' example in the examples/cxx/tree/ directory for more information. If I had to handle anyType, I would do it like this: I would customize the Status class by (1) adding an additional member to store the command as an object model node or as a DOM document fragment, (2) overriding the parsing constructor to populate this member based on the data supplied for the command element (you will somehow need to know which command it is), and (3) overriding the serialization operator to serialize the command member to the command element. 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 is probably the closest to what you would want to achieve. Boris From angelo at cedeo.net Fri Mar 6 05:33:05 2009 From: angelo at cedeo.net (Angelo Difino) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Keep a xsd library small In-Reply-To: References: <499469A3.5020609@cedeo.net> Message-ID: <49B0FBE1.9060201@cedeo.net> Boris Kolpackov wrote: > Hi Angelo, > > Angelo Difino writes: > > >> first of all I'd like to say that xsd-codesynthesis rocks: after just few >> days of it i was able to create the c++ classes of a quite 'complicated' >> set of schemas (that was already posted here few mouths ago'). >> > > Thanks, I am glad you find it useful. > > > >> Since this set of schema suffer of cyclic dependencies with inheritance, >> I'm using the file-per-type option. I'm running the last release (3.2.0) >> of XSD on win32/vista... >> >> Everything works great, but the problem is the huge amount of files >> and its size when I try to compile it (i'm using MSVisual c++ 2003). >> The header and class file counts 872 and the built library is of 1GB >> of size >> > > You are probably building a static library. Unfortunately with > the file-per-type mode static libraries for non-trivial schemas > are bound to be quite large. This is due to the large number of > source files which, when compiled, all include instantiations of > some common templates (this is especialy true when the --generate- > polymorphic option is used). The static library is pretty much the > archive of all the object files. When it is linked to an executable, > the linker will remove all those duplicate template instantiations > so the resulting binary will have the same size as if you used the > file-per-schema mode. > > One solution to this problem is to use a shared library (DLL) > instead of a static library since a shared library is mode like > an executable in that all the duplicate template instantiations > are removed. For example, I compiled your schemas on my GNU/Linux > box and while the static library is 227MB, the shared library is > 10MB. > Hi Boris and all, thank you very much for the hint! nowadays, with shared library, on win32 with msvc 9.0 i've reached 8 MB in debug and 4 in release... that's pretty ok ;) > Here are some more tips for reducing the size/compilation time: > > 1. Specify root element with the --root-element option. In your > schema I eliminated about a hundred parsing/serialization > functions by adding '--root-element DIDL' to the command > line. > 'Unfortunally' i've to be able to use any of the root elemets (didl, rel-*, ...), so i've avoided to specify the DIDL (but i've used it since it includes all the other sub-schemas) type > 2. Your schema is composed of several lower-level schema subsets. > If only one of the lower-level subsets involve the cyclic > dependency, then you can compile only this subset in the > file-per-type mode and the rest in the default, file-per- > schema mode. Note that here the subset needs to be fairly > isolated in that all the schemas that it includes/imports > will be handled in the file-per-type mode. In your case, > there are two subsets that involve cyclic dependencies > (rel-*.xsd and ipmpmsg.xsd/ipmpinfo.xsd) so the bulk of > the schema has to be compiled in the file-per-type mode. > However, there are still a few files that can be compiled > in the file-per-schema mode, namely, didl.xsd, didl-msx.xsd, > and mpeg4smp.xsd. > > I compiled your schemas like so: > > xsd cxx-tree --file-per-type ... rel-r.xsd ipmpinfo.xsd > xsd cxx-tree ... didl.xsd didl-msx.xsd mpeg4smp.xsd > > And the static library size went down to 175Mb. > I see, but i prefer to manage all the schema on the same way > 3. You can also try to split the offending schemas into two or > more files so that they don't involve cyclic dependencies > with inheritance (the resulting schema will be semantically > equivalent to the original). Then you can use the file-per- > schema mode. > > 4. When using the file-per-type mode it is recommended to use > precompiled headers to speed-up compilation. You would normally > include xml-schema.hxx into the precompiled header and then > include the precompiled header into each generated source > file using the --cxx-prologue option. Ok, I've still to investigate on this issue! Last question :) since the number of classes is quite big (about 800 ), I've decided to organize this source code in several subfolders, labelled with the same name of the schema they belong to. I've wrote a batch file that simply move the files in the correct subfolder. Is there any way to automatize it (something like "--output-dir dir", but for the different namespaces)? I've included in attach an example of the batch file so you can look better what i need... (if there is any way to do it!!! :) ) -------------- next part -------------- A non-text attachment was scrubbed... Name: DIVIDE.rar Type: application/octet-stream Size: 4038 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090306/b4943498/DIVIDE.obj From boris at codesynthesis.com Fri Mar 6 07:40:30 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType In-Reply-To: References: Message-ID: Hi Laura, Laura E Fowler writes: > I have been looking at this, but I think I'm not understanding the > following statement you made: > "This way you could just serialize one of the commands into a DOM document > fragment corresponding to the wildcard and then, when the Status message > is serialized, everything is handled automatically." > > I'm a little confused by "DOM document fragment corresponding to the > wildcard". I've been looking at the wildcard example, but I'm just not > getting it. > > My schema is similar to: > > > > ... > > ... > > > > > > > > > > I serialized my command to a DOMDocument (not a fragment), but I'm unclear > as to how put it into commandEcho. If you compile the schemas with the --generate-wildcard option, the above commandEcho type will have a constructor that looks like this: class commandEcho { commandEcho (const xercesc::DOMElement& any); }; Here is sample code that shows how to construct the Status object provided you have a DOMDocument containing the command: DOMDocument* cmd_doc = ... auto_ptr ec ( new commandEcho (*cmd_doc->getDocumentElement ())); Status s (ec); The only problem with this approach is that it is quite wasteful; you first serialize the command into a DOMDocument and then the contents of this document are copied into the commandEcho object. It is also possible to serialize the command directly into a DOMElement corresponding to the wildcard. Something along these lines: const CommandA& cmd_a = ... // Create empty document with the correct root element. // DOMDocument* cmd_doc = impl->createDocument (xml::string ("").c_str ()), xml::string ("xxx:command-a").c_str ()); auto_ptr ec ( new commandEcho (*cmd_doc->getDocumentElement ())); cmd_doc->release (); // Don't need it anymore. // Serialize directly into wildcard element. // DOMElement& e = ec->any (); e << cmd_a; Status s (ec); Boris From boris at codesynthesis.com Fri Mar 6 08:03:15 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Keep a xsd library small In-Reply-To: <49B0FBE1.9060201@cedeo.net> References: <499469A3.5020609@cedeo.net> <49B0FBE1.9060201@cedeo.net> Message-ID: Hi Angelo, Angelo Difino writes: > Last question :) since the number of classes is quite big (about 800), > I've decided to organize this source code in several subfolders, labelled > with the same name of the schema they belong to. > > I've wrote a batch file that simply move the files in the correct > subfolder. Is there any way to automatize it (something like "--output-dir > dir", but for the different namespaces)? Take a look a the --type-file-regex and --type-file-regex-trace options in the XSD Compiler Command Line Manual: http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml The first option allows you to specify regular expressions that are used to transform type names into file names. They are run on a string that includes the namespace. While you won't be able to automatically place such files into different directories with this approach, you can add a namespace-specific prefix to the files and maybe later move them into a directory corresponding to the namespace with a simple(r) script. > I've included in attach an example ... You attachment is in the RAR format. Please see item #5 in the Posting Guidelines regarding this: http://www.codesynthesis.com/support/posting-guidelines.xhtml Boris From Laura_E_Fowler at raytheon.com Fri Mar 6 10:12:59 2009 From: Laura_E_Fowler at raytheon.com (Laura E Fowler) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType In-Reply-To: References: Message-ID: Boris, I'm trying to use the more efficient way, but when I create the commandEcho I get an exception at run time: Exception received: expected element '##targetNamespace#*' I'm assuming that means that I haven't formatted the DOMDocument correctly. I've tried several things, but I keep getting the error. I'm sure it's something stupid. Here is a code fragment for creating the document and commandEcho: DOMDocument *cmd_doc = impl->createDocument(xml::string ("").c_str(), xml::string ("XYZ:CommandA").c_str(), NULL); auto_ptr ec(new commandEcho (*cmd_doc->getDocumentElement(), 0 , NULL)); cmd_doc->release(); DOMElement& e = ec->any(); e << *lchc; If I don't put the three parameters on creating the commandEcho the compiler says the call is ambiguous. Thanks, Laura Fowler From: Boris Kolpackov To: Laura E Fowler Cc: xsd-users@codesynthesis.com Date: 03/06/2009 06:48 AM Subject: Re: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType Hi Laura, Laura E Fowler writes: > I have been looking at this, but I think I'm not understanding the > following statement you made: > "This way you could just serialize one of the commands into a DOM document > fragment corresponding to the wildcard and then, when the Status message > is serialized, everything is handled automatically." > > I'm a little confused by "DOM document fragment corresponding to the > wildcard". I've been looking at the wildcard example, but I'm just not > getting it. > > My schema is similar to: > > > > ... > > ... > > > > > > > > > > I serialized my command to a DOMDocument (not a fragment), but I'm unclear > as to how put it into commandEcho. If you compile the schemas with the --generate-wildcard option, the above commandEcho type will have a constructor that looks like this: class commandEcho { commandEcho (const xercesc::DOMElement& any); }; Here is sample code that shows how to construct the Status object provided you have a DOMDocument containing the command: DOMDocument* cmd_doc = ... auto_ptr ec ( new commandEcho (*cmd_doc->getDocumentElement ())); Status s (ec); The only problem with this approach is that it is quite wasteful; you first serialize the command into a DOMDocument and then the contents of this document are copied into the commandEcho object. It is also possible to serialize the command directly into a DOMElement corresponding to the wildcard. Something along these lines: const CommandA& cmd_a = ... // Create empty document with the correct root element. // DOMDocument* cmd_doc = impl->createDocument (xml::string ("").c_str ()), xml::string ("xxx:command-a").c_str ()); auto_ptr ec ( new commandEcho (*cmd_doc->getDocumentElement ())); cmd_doc->release (); // Don't need it anymore. // Serialize directly into wildcard element. // DOMElement& e = ec->any (); e << cmd_a; Status s (ec); Boris From boris at codesynthesis.com Fri Mar 6 10:30:18 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType In-Reply-To: References: Message-ID: Hi Laura, Laura E Fowler writes: > I'm assuming that means that I haven't formatted the DOMDocument > correctly. I've tried several things, but I keep getting the error. I'm > sure it's something stupid. Here is a code fragment for creating the > document and commandEcho: > > DOMDocument *cmd_doc = impl->createDocument(xml::string > ("").c_str(), > xml::string > ("XYZ:CommandA").c_str(), NULL); > auto_ptr ec(new commandEcho > (*cmd_doc->getDocumentElement(), 0 , NULL)); > cmd_doc->release(); > DOMElement& e = ec->any(); > e << *lchc; Ok, I know what's going on. Unfortunately when a type has a single required (minOccurs=maxOccurs=1) wildcard, the calls to the normal constructor and the parsing constructor are ambiguous (this problem is already in our defect list). The above code calls the parsing constructor and there is no way to call the other one, which is what we need. We can work around this problem like so: 1. Recompile the schema containing the commandEcho type with the --generate-default-ctor option. 2. Then the above code can be rewritten like this (it is actually simpler and more efficient): auto_ptr ec (new commandEcho); DOMDocument& doc = ec->dom_document (); DOMElement* e = doc.createElementNS ( xml::string ("").c_str (), xml::string ("XYZ:CommandA").c_str ()); *e << *lchc; ec->any (e); // Assumes ownership of e. Here, we create an element using the DOM document that holds DOM fragments for the wildcard. Because of that, we can let the commandEcho object simply adopt ownership of the element once we are done serializing the command into it. Let me know if there are any problems with this code. Boris From Laura_E_Fowler at raytheon.com Fri Mar 6 11:54:04 2009 From: Laura_E_Fowler at raytheon.com (Laura E Fowler) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType In-Reply-To: References: Message-ID: Boris, I'm getting closer, but when I execute following line: *e << *lchc; I receive the following exception: terminate called after throwing an instance of 'xsd::cxx::xml::dom::no_prefix' I saw in the archives where there had been a problem with no_prefix, but I wasn't sure if this was the same case. Thanks, Laura Fowler From: Boris Kolpackov To: Laura E Fowler Cc: xsd-users@codesynthesis.com Date: 03/06/2009 09:38 AM Subject: Re: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType Hi Laura, Laura E Fowler writes: > I'm assuming that means that I haven't formatted the DOMDocument > correctly. I've tried several things, but I keep getting the error. I'm > sure it's something stupid. Here is a code fragment for creating the > document and commandEcho: > > DOMDocument *cmd_doc = impl->createDocument(xml::string > ("").c_str(), > xml::string > ("XYZ:CommandA").c_str(), NULL); > auto_ptr ec(new commandEcho > (*cmd_doc->getDocumentElement(), 0 , NULL)); > cmd_doc->release(); > DOMElement& e = ec->any(); > e << *lchc; Ok, I know what's going on. Unfortunately when a type has a single required (minOccurs=maxOccurs=1) wildcard, the calls to the normal constructor and the parsing constructor are ambiguous (this problem is already in our defect list). The above code calls the parsing constructor and there is no way to call the other one, which is what we need. We can work around this problem like so: 1. Recompile the schema containing the commandEcho type with the --generate-default-ctor option. 2. Then the above code can be rewritten like this (it is actually simpler and more efficient): auto_ptr ec (new commandEcho); DOMDocument& doc = ec->dom_document (); DOMElement* e = doc.createElementNS ( xml::string ("").c_str (), xml::string ("XYZ:CommandA").c_str ()); *e << *lchc; ec->any (e); // Assumes ownership of e. Here, we create an element using the DOM document that holds DOM fragments for the wildcard. Because of that, we can let the commandEcho object simply adopt ownership of the element once we are done serializing the command into it. Let me know if there are any problems with this code. Boris From boris at codesynthesis.com Fri Mar 6 13:20:01 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] How to clone/copy an XML message and add it to a another message using anyType In-Reply-To: References: Message-ID: Hi Laura, Laura E Fowler writes: > I'm getting closer, but when I execute following line: > > *e << *lchc; > > I receive the following exception: > terminate called after throwing an instance of > 'xsd::cxx::xml::dom::no_prefix' This means that there are elements/attributes in lchc with a namespace for which there is no prefix established in e. You can establish a namespace-prefix mapping like so: e->setAttributeNS ( xml::string ("http://www.w3.org/2000/xmlns/").c_str (), xml::string ("xmlns:foo").c_str (), xml::string ("http://www.example.com/foo").c_str ()); Alternatively, you can upgrade to 3.2.0. In this version, if there is no prefix found for an element or attribute during serialization, a generic one (e.g., p1, p2) is automatically added. Boris From bertwagner at bertwagner.com Tue Mar 10 12:06:39 2009 From: bertwagner at bertwagner.com (Bert Wagner) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Receiving a build-0.3/bootstrap.make error during xsd build on mac Message-ID: <2ea56f30903100906t184a0c3crefdcb7d1654b1163@mail.gmail.com> Hi all, I am having trouble building xsd and can't make sense of the error I'm getting. I downloaded the xsd-3.2.0.tar.bz2 source and followed the build instructions at http://www.codesynthesis.com/projects/xsd/extras/build-unix.xhtml, but I receive the following error: ../build/bootstrap.make:8: build-0.3/bootstrap.make: No such file or > directory > make: *** No rule to make target `build-0.3/bootstrap.make'. Stop. I am stuck at this point and do not know what I should do to in order to get xsd to build. Any help would be greatly appreciated, thanks! Best, Bert From boris at codesynthesis.com Tue Mar 10 12:16:36 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Receiving a build-0.3/bootstrap.make error during xsd build on mac In-Reply-To: <2ea56f30903100906t184a0c3crefdcb7d1654b1163@mail.gmail.com> References: <2ea56f30903100906t184a0c3crefdcb7d1654b1163@mail.gmail.com> Message-ID: Hi Bert, Bert Wagner writes: > ../build/bootstrap.make:8: build-0.3/bootstrap.make: No such file or > directory I assume that you have installed build as prescribed in the instructions. If that's the case, then this error means that your GNU make for some reason does not search in the directory where you have installed build (by default /usr/include and /usr/local/include). In this case, I suggest that you verify that there is build-0.3/bootstrap.make in the installation directory and then use the MAKEFLAGS variable to make sure that make searches in the installation directory: $ make MAKEFLAGS=-I/path-to-where-build-was-installed BTW, you may also want to try the all-in-one package (xsd+dep-3.2.0) as mentioned in the instructions. This one does not require that you download all the dependencies (except Xerces-C++ and Boost) individually. Boris From Chang_Chen at sonic.com Wed Mar 11 23:59:12 2009 From: Chang_Chen at sonic.com (Chang Chen) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Output Message-ID: <51C471E6CBEC8148A08E065690F4DBDF034C18D5@SHAEXC01.ent.sonic.com> Hi Boris Can we generate header files and Source files into different folders? I only find --output-dir option. Thanks Chang From boris at codesynthesis.com Thu Mar 12 01:32:59 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Output In-Reply-To: <51C471E6CBEC8148A08E065690F4DBDF034C18D5@SHAEXC01.ent.sonic.com> References: <51C471E6CBEC8148A08E065690F4DBDF034C18D5@SHAEXC01.ent.sonic.com> Message-ID: Hi Chang, Chang Chen writes: > Can we generate header files and Source files into different folders? I > only find --output-dir option. No, there is no automatic way to do this though it should be trivial to achieve with a few shell commands. For example, you could place the generated files into a temporary directory and then move headers and sources to their respective places, for example, mv *.cxx ../src/ mv *.hxx ../include/ See also the --file-list* options. Boris From Michael.Forstner at cpg.de Fri Mar 13 07:51:19 2009 From: Michael.Forstner at cpg.de (Forstner Michael) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Defaults for minOccurs and maxOccurs Message-ID: Hi all, IMHO the default for minOccurs and maxOccurs is "1" for both if they are not supplied inside a XSD file. xsd.exe generates an XXX_optional field or every field insiede a XSD file which is missing minOccurs and maxOccurs attributes. Am I wrong (and xsd.exe right) or the opposite (which I think of)? Thanks in advance, Michael From boris at codesynthesis.com Fri Mar 13 09:13:15 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Defaults for minOccurs and maxOccurs In-Reply-To: References: Message-ID: Hi Michael, Forstner Michael writes: > IMHO the default for minOccurs and maxOccurs is "1" for both if they > are not supplied inside a XSD file. Correct. > xsd.exe generates an XXX_optional field or every field insiede a XSD > file which is missing minOccurs and maxOccurs attributes. I think what happens is you have an outer all or sequence compositor with minOccurs="0" or a choice compositor, for example: In the C++/Tree mapping the XSD compiler "flattens" the content model and computes what we call effective minOccurs and maxOccurs which are then used to decide which set of accessors/modifiers to generate. Boris From Michael.Forstner at cpg.de Tue Mar 17 04:40:03 2009 From: Michael.Forstner at cpg.de (Forstner Michael) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Refactoring of 3rd Party Schemas Message-ID: Hi again, I've got 4 3rd Party schemas. Each schema declares exactly the same types again and again an has it's own namespace. So I've refactored them to use one common schema for the common types. If this new common schema has it's own namespace and is imported by the 4 others, xsd.exe generates seperate sources for each schema but the XML documents can't be parsed because they are missing the namespace prefixes for the common types. If this new common schema has no namespace and is included by the 4 others, the XML documents can be parsed successfully but xsd.exe generates the common types for each schema inline (multiple again). Is there a possiblity to advise xsd.exe to handle includes like imports? Thanks in advance, Michael Forstner From boris at codesynthesis.com Tue Mar 17 05:00:21 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Refactoring of 3rd Party Schemas In-Reply-To: References: Message-ID: Hi Michael, Forstner Michael writes: > If this new common schema has it's own namespace and is imported by > the 4 others, xsd.exe generates seperate sources for each schema but > the XML documents can't be parsed because they are missing the namespace > prefixes for the common types. You probably mean prefixes for the elements contained in the common types. XML documents normally do not refer to type names defined in XML Schema, except for the xsi:type case. > If this new common schema has no namespace and is included by the 4 others, > the XML documents can be parsed successfully but xsd.exe generates the > common types for each schema inline (multiple again). > > Is there a possiblity to advise xsd.exe to handle includes like imports? No there is no way to do this and even if there were, it wouldn't work. The XML Schema spec prescribes that when a schema without a namespace is included into a schema with a namespace, then the definitions in the included schema assume the target namespace of the including schema (this case is called chameleon inclusion). To support this, XSD has to generate different code depending on the target namespace and that's the reason why this code is generated inline. I assume your schemas have elementFormDefault="qualified" which makes all local elements qualified. In this case there is not much you can do, except, perhaps factor out common simple types that don't have any elements. Boris From vinayashrestha at gmail.com Fri Mar 20 06:21:04 2009 From: vinayashrestha at gmail.com (Vinaya Shrestha) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Need some help Message-ID: <5aa2e3810903200321v429bae11kac2e9fc14793c0d0@mail.gmail.com> Hello, I am trying to generate a C++ class from XML document. My XML document is more complex, so I'll put my problem by putting op an analogous statement here. For instance, here's the XML document. ............ I created the skeleton class by using xsd command and inherited from the skeleton class to create concrete class. Here, Club and Member are XML complexTypes. So two classes club_pskel and member_pskel have been created. MY concrete classes are as follows: class Member_pimpl:public Member_pskel { private: string id; string name; string dob; ................. }; class Club_pimpl:public Club_pskel { private: Member_pimpl Member; // the Member object is a member of Club class ...... }; I have used these two classes to store the XML information. Things were fine, when there was a single member node. But as I added up more member nodes, I could not figure out how to store all the Member nodes. Little help on that subject would be very nice. From boris at codesynthesis.com Fri Mar 20 12:16:45 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Storing sequence data in C++/Parser In-Reply-To: <5aa2e3810903200321v429bae11kac2e9fc14793c0d0@mail.gmail.com> References: <5aa2e3810903200321v429bae11kac2e9fc14793c0d0@mail.gmail.com> Message-ID: Hi Vinaya, In the future please use a more descriptive subject line. For this and other posting guidelines, see: http://www.codesynthesis.com/support/posting-guidelines.xhtml Vinaya Shrestha writes: > class Member_pimpl: public Member_pskel > { > private: > string id; > string name; > string dob; > }; > > ... > > I have used these two classes to store the XML information. Things were > fine, when there was a single member node. But as I added up more member > nodes, I could not figure out how to store all the Member nodes. The Member_pimpl parser will be called for each member element in your XML document and it is up to you to make sure that the subsequent calls don't override the data stored on the current iterator. You can, for example, use std::vector to sore an entry for each member element: class Member_pimpl: public Member_pskel { private: struct Member { string id; string name; string dob; }; std::vector members_; }; You can do members_.push_back (Member ()); in pre() and then in id(), name(), and dob() fill in the members using members_.back (), for example: members_.back ().id = id; Boris From jan.klimke at hpi.uni-potsdam.de Sat Mar 21 11:13:25 2009 From: jan.klimke at hpi.uni-potsdam.de (Jan Klimke) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] prgram crashes on deletion xsd::cxx::tree::optional instance Message-ID: <49C50415.40709@hpi.uni-potsdam.de> Hi all, i got a Problem when trying to delete an instance of an Object which contains an xsd::cxx::tree::optional somewhere.. It seems like it tries to delete a pointer which is not set or already deleted. This does not happen every time whe i call delete on a csd-generated object instance. Do you have any hint where i could have a look at ? Here are the last lines of my call stack, maybe it helps to answer my question: wfs_debug.dll!xsd::cxx::tree::optional::~optional() Line 111 + 0x32 bytes C++ wfs_debug.dll!gml::FeaturePropertyTypeBase::~FeaturePropertyTypeBase() Line 659 + 0x83 bytes C++ wfs_debug.dll!gml::FeaturePropertyType::~FeaturePropertyType() + 0x2b bytes C++ wfs_debug.dll!gml::FeaturePropertyType::`vector deleting destructor'() + 0x69 bytes C++ > wfs_debug.dll!xsd::cxx::tree::sequence_common::ptr::~ptr() Line 772 + 0x36 bytes C++ wfs_debug.dll!xsd::cxx::tree::sequence_common::ptr::`scalar deleting destructor'() + 0x2b bytes C++ wfs_debug.dll!std::_Destroy(xsd::cxx::tree::sequence_common::ptr * _Ptr=0x0eb41e78) Line 60 C++ wfs_debug.dll!std::allocator::destroy(xsd::cxx::tree::sequence_common::ptr * _Ptr=0x0eb41e78) Line 160 + 0x9 bytes C++ wfs_debug.dll!std::_Destroy_range >(xsd::cxx::tree::sequence_common::ptr * _First=0x0eb41e78, xsd::cxx::tree::sequence_common::ptr * _Last=0x0eb41e7c, std::allocator & _Al={...}, std::_Nonscalar_ptr_iterator_tag __formal={...}) Line 234 + 0xc bytes C++ wfs_debug.dll!std::_Destroy_range >(xsd::cxx::tree::sequence_common::ptr * _First=0x0eb41e78, xsd::cxx::tree::sequence_common::ptr * _Last=0x0eb41e7c, std::allocator & _Al={...}) Line 225 + 0x2f bytes C++ wfs_debug.dll!std::vector >::_Destroy(xsd::cxx::tree::sequence_common::ptr * _First=0x0eb41e78, xsd::cxx::tree::sequence_common::ptr * _Last=0x0eb41e7c) Line 1119 + 0x14 bytes C++ wfs_debug.dll!std::vector >::_Tidy() Line 1132 C++ wfs_debug.dll!std::vector >::~vector >() Line 560 C++ wfs_debug.dll!xsd::cxx::tree::sequence_common::~sequence_common() + 0x2e bytes C++ wfs_debug.dll!xsd::cxx::tree::sequence::~sequence() + 0x2b bytes C++ wfs_debug.dll!schemas::coll::CommentBaseTypeBase::~CommentBaseTypeBase() Line 1755 + 0x8c bytes C++ wfs_debug.dll!schemas::coll::CommentBaseTypeImpl::~CommentBaseTypeImpl() + 0x2b bytes C++ wfs_debug.dll!schemas::coll::CommentType::~CommentType() Line 2005 + 0x2f bytes C++ wfs_debug.dll!schemas::coll::TextCommentTypeBase::~TextCommentTypeBase() Line 2194 + 0x1d bytes C++ wfs_debug.dll!schemas::coll::TextCommentTypeImpl::~TextCommentTypeImpl() + 0x2b bytes C++ wfs_debug.dll!schemas::coll::TextCommentTypeImpl::`vector deleting destructor'() + 0x6c bytes C++ Kind regards, Jan From vinayashrestha at gmail.com Mon Mar 23 01:35:43 2009 From: vinayashrestha at gmail.com (Vinaya Shrestha) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Storing sequence data in C++/Parser In-Reply-To: References: <5aa2e3810903200321v429bae11kac2e9fc14793c0d0@mail.gmail.com> Message-ID: <5aa2e3810903222235s6567f679rae52806f4ed66ce3@mail.gmail.com> Hey Boris, Thanks for your reply. I tried to implement as you told me to, but could not. I'm still trying. And I hope that you could help me better if i send u the work that i'm doing. I have attached here the sourcecode that I have used. What i want to achieve is be able to store the "Person" nodes variables. I hope you can help me. Thanks. Regards, Vinaya Lal Shrestha -------------- next part -------------- A non-text attachment was scrubbed... Name: people.zip Type: application/zip Size: 130313 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090323/f129d4a3/people.zip From hjzheng818 at 126.com Mon Mar 23 02:49:47 2009 From: hjzheng818 at 126.com (hjzheng818) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 45, Issue 13 References: <200903211600.n2LG05Fn016727@codesynthesis.com> Message-ID: <200903231449424682100@126.com> hello,i comple "exampels/cxx/tree/library/library.cxx" by command : #xlC -I/home/publib/xsd-3.2.0-powerpc-aix/libxsd -I/home/publib/xerces-c-3.0.1-powerpc-aix-xlc-7.0/include -c driver.cxx library.cxx error info : "/home/publib/xsd-3.2.0-powerpc-aix/libxsd/xsd/cxx/tree/serialization/unsigned-int.hxx", line 38.7: 1540-1283 (I) "template xsd::cxx::tree::operator<<(list_stream &, unsigned int)" is not a viable candidate. why? thanks. 2009-03-23 hjzheng818 ???? xsd-users-request ????? 2009-03-22 00:03:41 ???? xsd-users ??? ??? xsd-users Digest, Vol 45, Issue 13 Send xsd-users mailing list submissions to xsd-users@codesynthesis.com To subscribe or unsubscribe via the World Wide Web, visit http://codesynthesis.com/mailman/listinfo/xsd-users or, via email, send a message with subject or body 'help' to xsd-users-request@codesynthesis.com You can reach the person managing the list at xsd-users-owner@codesynthesis.com When replying, please edit your Subject line so it is more specific than "Re: Contents of xsd-users digest..." Today's Topics: 1. Re: Storing sequence data in C++/Parser (Boris Kolpackov) 2. prgram crashes on deletion xsd::cxx::tree::optional instance (Jan Klimke) ---------------------------------------------------------------------- Message: 1 Date: Fri, 20 Mar 2009 18:16:45 +0200 From: Boris Kolpackov Subject: Re: [xsd-users] Storing sequence data in C++/Parser To: Vinaya Shrestha Cc: xsd-users@codesynthesis.com Message-ID: Content-Type: text/plain; charset=us-ascii Hi Vinaya, In the future please use a more descriptive subject line. For this and other posting guidelines, see: http://www.codesynthesis.com/support/posting-guidelines.xhtml Vinaya Shrestha writes: > class Member_pimpl: public Member_pskel > { > private: > string id; > string name; > string dob; > }; > > ... > > I have used these two classes to store the XML information. Things were > fine, when there was a single member node. But as I added up more member > nodes, I could not figure out how to store all the Member nodes. The Member_pimpl parser will be called for each member element in your XML document and it is up to you to make sure that the subsequent calls don't override the data stored on the current iterator. You can, for example, use std::vector to sore an entry for each member element: class Member_pimpl: public Member_pskel { private: struct Member { string id; string name; string dob; }; std::vector members_; }; You can do members_.push_back (Member ()); in pre() and then in id(), name(), and dob() fill in the members using members_.back (), for example: members_.back ().id = id; Boris ------------------------------ Message: 2 Date: Sat, 21 Mar 2009 16:13:25 +0100 From: Jan Klimke Subject: [xsd-users] prgram crashes on deletion xsd::cxx::tree::optional instance To: xsd-users@codesynthesis.com Message-ID: <49C50415.40709@hpi.uni-potsdam.de> Content-Type: text/plain; charset=ISO-8859-15 Hi all, i got a Problem when trying to delete an instance of an Object which contains an xsd::cxx::tree::optional somewhere.. It seems like it tries to delete a pointer which is not set or already deleted. This does not happen every time whe i call delete on a csd-generated object instance. Do you have any hint where i could have a look at ? Here are the last lines of my call stack, maybe it helps to answer my question: wfs_debug.dll!xsd::cxx::tree::optional::~optional() Line 111 + 0x32 bytes C++ wfs_debug.dll!gml::FeaturePropertyTypeBase::~FeaturePropertyTypeBase() Line 659 + 0x83 bytes C++ wfs_debug.dll!gml::FeaturePropertyType::~FeaturePropertyType() + 0x2b bytes C++ wfs_debug.dll!gml::FeaturePropertyType::`vector deleting destructor'() + 0x69 bytes C++ > wfs_debug.dll!xsd::cxx::tree::sequence_common::ptr::~ptr() Line 772 + 0x36 bytes C++ wfs_debug.dll!xsd::cxx::tree::sequence_common::ptr::`scalar deleting destructor'() + 0x2b bytes C++ wfs_debug.dll!std::_Destroy(xsd::cxx::tree::sequence_common::ptr * _Ptr=0x0eb41e78) Line 60 C++ wfs_debug.dll!std::allocator::destroy(xsd::cxx::tree::sequence_common::ptr * _Ptr=0x0eb41e78) Line 160 + 0x9 bytes C++ wfs_debug.dll!std::_Destroy_range >(xsd::cxx::tree::sequence_common::ptr * _First=0x0eb41e78, xsd::cxx::tree::sequence_common::ptr * _Last=0x0eb41e7c, std::allocator & _Al={...}, std::_Nonscalar_ptr_iterator_tag __formal={...}) Line 234 + 0xc bytes C++ wfs_debug.dll!std::_Destroy_range >(xsd::cxx::tree::sequence_common::ptr * _First=0x0eb41e78, xsd::cxx::tree::sequence_common::ptr * _Last=0x0eb41e7c, std::allocator & _Al={...}) Line 225 + 0x2f bytes C++ wfs_debug.dll!std::vector >::_Destroy(xsd::cxx::tree::sequence_common::ptr * _First=0x0eb41e78, xsd::cxx::tree::sequence_common::ptr * _Last=0x0eb41e7c) Line 1119 + 0x14 bytes C++ wfs_debug.dll!std::vector >::_Tidy() Line 1132 C++ wfs_debug.dll!std::vector >::~vector >() Line 560 C++ wfs_debug.dll!xsd::cxx::tree::sequence_common::~sequence_common() + 0x2e bytes C++ wfs_debug.dll!xsd::cxx::tree::sequence::~sequence() + 0x2b bytes C++ wfs_debug.dll!schemas::coll::CommentBaseTypeBase::~CommentBaseTypeBase() Line 1755 + 0x8c bytes C++ wfs_debug.dll!schemas::coll::CommentBaseTypeImpl::~CommentBaseTypeImpl() + 0x2b bytes C++ wfs_debug.dll!schemas::coll::CommentType::~CommentType() Line 2005 + 0x2f bytes C++ wfs_debug.dll!schemas::coll::TextCommentTypeBase::~TextCommentTypeBase() Line 2194 + 0x1d bytes C++ wfs_debug.dll!schemas::coll::TextCommentTypeImpl::~TextCommentTypeImpl() + 0x2b bytes C++ wfs_debug.dll!schemas::coll::TextCommentTypeImpl::`vector deleting destructor'() + 0x6c bytes C++ Kind regards, Jan ------------------------------ _______________________________________________ xsd-users mailing list xsd-users@codesynthesis.com http://codesynthesis.com/mailman/listinfo/xsd-users End of xsd-users Digest, Vol 45, Issue 13 ***************************************** From boris at codesynthesis.com Mon Mar 23 10:39:00 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] prgram crashes on deletion xsd::cxx::tree::optional instance In-Reply-To: <49C50415.40709@hpi.uni-potsdam.de> References: <49C50415.40709@hpi.uni-potsdam.de> Message-ID: Hi Jan, Jan Klimke writes: > This does not happen every time whe i call delete on a csd-generated > object instance. > > Do you have any hint where i could have a look at? It is quite hard to end up with the same object being owned by two or more object models (and thus deleted twice) in C++/Tree. So I would say the most likely cause is memory corruption somewhere in your application. Try to run it under a memory access checker, such as Valgrind on Linux/UNIX. Also, if you can create a test case that reproduces this problem under Linux, I can take a look. Boris From jan.klimke at hpi.uni-potsdam.de Mon Mar 23 11:32:08 2009 From: jan.klimke at hpi.uni-potsdam.de (Jan Klimke) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] prgram crashes on deletion xsd::cxx::tree::optional instance In-Reply-To: References: <49C50415.40709@hpi.uni-potsdam.de> Message-ID: <49C7AB78.7050307@hpi.uni-potsdam.de> Hi Boris, i found a piece of code in my projekt where i try to resolve idrefs on cloning. gml::FeaturePropertyType::FeaturePropertyType( const FeaturePropertyType& fp, xml_schema::Flags f/*= 0*/, xml_schema::Container* c/*= 0*/ ):FeaturePropertyTypeBase(fp,f,c){ if(fp.getHref().present() && !fp.get_Feature().present()){ std::string gmlId = fp.getHref().get().substr(1,gmlId.size()-1); xml_schema::Idref ref(gmlId,0,this); //Check for existance in container AbstractFeatureType* feature = static_cast(ref.get()); if(feature){ //set a link if it allready extists this->setHref(fp.getHref()); }else{ //add the feature if it does not exist this->set_Feature(*fp.getFeature()); } } } Tt tries to copy the _Feature element from the old object model to the new one if they do not already exist. I implemented the method getFeature() to resolve idrefs and return a pointer to the referenced object or null if it does not exist. is it possible that children pointer are not copied when i do this like this ? Kind regards, Jan Boris Kolpackov schrieb: > Hi Jan, > > Jan Klimke writes: > > >> This does not happen every time whe i call delete on a csd-generated >> object instance. >> >> Do you have any hint where i could have a look at? >> > > It is quite hard to end up with the same object being owned by two > or more object models (and thus deleted twice) in C++/Tree. So I > would say the most likely cause is memory corruption somewhere in > your application. Try to run it under a memory access checker, such > as Valgrind on Linux/UNIX. Also, if you can create a test case that > reproduces this problem under Linux, I can take a look. > > Boris > From boris at codesynthesis.com Mon Mar 23 11:47:02 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] prgram crashes on deletion xsd::cxx::tree::optional instance In-Reply-To: <49C7AB78.7050307@hpi.uni-potsdam.de> References: <49C50415.40709@hpi.uni-potsdam.de> <49C7AB78.7050307@hpi.uni-potsdam.de> Message-ID: Hi Jan, Jan Klimke writes: > I implemented the method getFeature() to resolve idrefs and return > a pointer to the referenced object or null if it does not exist. The code fragment looks alright to me. What is the implementation of FeaturePropertyType::getFeature()? Boris From boris at codesynthesis.com Tue Mar 24 06:36:35 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 45, Issue 13 In-Reply-To: <200903231449424682100@126.com> References: <200903211600.n2LG05Fn016727@codesynthesis.com> <200903231449424682100@126.com> Message-ID: Hi, In the future please create a new email (instead of replying to a digest) and use a more descriptive subject, as discussed in the posting guidelines: http://codesynthesis.com/support/posting-guidelines.xhtml hjzheng818 writes: > #xlC -I/home/publib/xsd-3.2.0-powerpc-aix/libxsd -I/home/publib/xerces-c-3.0.1-powerpc-aix-xlc-7.0/include -c driver.cxx library.cxx > error info : > "/home/publib/xsd-3.2.0-powerpc-aix/libxsd/xsd/cxx/tree/serialization/unsigned-int.hxx", line 38.7: 1540-1283 (I) "template xsd::cxx::tree::operator<<(list_stream &, unsigned int)" is not a viable candidate. Which version of xlC are you using? Run "xlC -qversion" to find out. Boris From hjzheng818 at 126.com Tue Mar 24 22:21:30 2009 From: hjzheng818 at 126.com (hjzheng818) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Re: xsd-users Digest, Vol 45, Issue 16 References: <200903241600.n2OG066W027039@codesynthesis.com> Message-ID: <200903251021245624723@126.com> IBM XL C/C++ Enterprise Edition V8.0 for AIX Version: 08.00.0000.0021 2009-03-25 hjzheng818 ???? xsd-users-request ????? 2009-03-25 00:00:08 ???? xsd-users ??? ??? xsd-users Digest, Vol 45, Issue 16 Send xsd-users mailing list submissions to xsd-users@codesynthesis.com To subscribe or unsubscribe via the World Wide Web, visit http://codesynthesis.com/mailman/listinfo/xsd-users or, via email, send a message with subject or body 'help' to xsd-users-request@codesynthesis.com You can reach the person managing the list at xsd-users-owner@codesynthesis.com When replying, please edit your Subject line so it is more specific than "Re: Contents of xsd-users digest..." Today's Topics: 1. Re: Re: xsd-users Digest, Vol 45, Issue 13 (Boris Kolpackov) ---------------------------------------------------------------------- Message: 1 Date: Tue, 24 Mar 2009 12:36:35 +0200 From: Boris Kolpackov Subject: Re: [xsd-users] Re: xsd-users Digest, Vol 45, Issue 13 To: hjzheng818 Cc: xsd-users Message-ID: Content-Type: text/plain; charset=us-ascii Hi, In the future please create a new email (instead of replying to a digest) and use a more descriptive subject, as discussed in the posting guidelines: http://codesynthesis.com/support/posting-guidelines.xhtml hjzheng818 writes: > #xlC -I/home/publib/xsd-3.2.0-powerpc-aix/libxsd -I/home/publib/xerces-c-3.0.1-powerpc-aix-xlc-7.0/include -c driver.cxx library.cxx > error info : > "/home/publib/xsd-3.2.0-powerpc-aix/libxsd/xsd/cxx/tree/serialization/unsigned-int.hxx", line 38.7: 1540-1283 (I) "template xsd::cxx::tree::operator<<(list_stream &, unsigned int)" is not a viable candidate. Which version of xlC are you using? Run "xlC -qversion" to find out. Boris ------------------------------ _______________________________________________ xsd-users mailing list xsd-users@codesynthesis.com http://codesynthesis.com/mailman/listinfo/xsd-users End of xsd-users Digest, Vol 45, Issue 16 ***************************************** From vinayashrestha at gmail.com Wed Mar 25 00:27:46 2009 From: vinayashrestha at gmail.com (Vinaya Shrestha) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Storing sequence data in C++/Parser In-Reply-To: References: <5aa2e3810903200321v429bae11kac2e9fc14793c0d0@mail.gmail.com> Message-ID: <5aa2e3810903242127h47a469e4l2ba692a26bb3b797@mail.gmail.com> Hey, I was able to store the multiple elements using vector, but what I did was declare a Person vector vPerson outside a class and pushed the Person object inside the People class in the vPerson vector in the Person_post() class. If you have another solution for the same, you could still write to me, Thanks. Regards, Vinaya Lal Shrestha From boris at codesynthesis.com Wed Mar 25 02:55:14 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] IBM XL C++ 8.0 compilation problem In-Reply-To: <200903251021245624723@126.com> References: <200903241600.n2OG066W027039@codesynthesis.com> <200903251021245624723@126.com> Message-ID: Hi, hjzheng818 writes: > > #xlC -I/home/publib/xsd-3.2.0-powerpc-aix/libxsd -I/home/publib/xerces-c-3.0.1-powerpc-aix-xlc-7.0/include -c driver.cxx library.cxx > > error info : > > "libxsd/xsd/cxx/tree/serialization/unsigned-int.hxx", line 38.7: 1540-1283 (I) "template xsd::cxx::tree::operator<<(list_stream &, unsigned int)" is not a viable candidate. > > IBM XL C/C++ Enterprise Edition V8.0 for AIX > Version: 08.00.0000.0021 Hm, interesting. I think you sent only one line from the compiler output. Can you send the complete output with all the error messages? Also, can you show me how you compiled library.xsd? That is, show the XSD command line you used. Finally, have you made any modification to the example? Boris From dawhite32 at gmail.com Thu Mar 26 00:24:57 2009 From: dawhite32 at gmail.com (David White) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Calculating progress on "xsd-parser" parsed files Message-ID: <97823d5c0903252124x3b2147c5rd0dfd9af2aff889@mail.gmail.com> Hi all, thanks to xsd-parser and xerces, I have built a fast library for extracting data from extremely large xml files. What would be very beneficial is some way of retrieving an indication of the file-parsing progress. Is it possible to get an indication of conversion process with xsd / xerces? If not, is it possible to get a pointer to the file pointer created/used by xerces? That way, file progress could be retrieved by a relatively simple calc using _filelength, _fileno and ftell, eg: float percentComplete = (float) (ftell(filePointer)) / (float) fileLength * 100.0; Or is there another way??? Thanks in advance. Kind regards, David. From christopher.fuhrman at gmail.com Wed Mar 25 17:28:01 2009 From: christopher.fuhrman at gmail.com (Christopher Fuhrman) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Public XML schema that works in XJC (Java) but maybe not in CodeSynthesis XSD Message-ID: <955f8a1b0903251428q221a5b8aybf64bbfca0a554b1@mail.gmail.com> Hi, I'm trying to get CodeSynthesis XSD to work on the following complex schema for biometrics data interchange. Although these schemas are online at various URLs, the following ZIP file has correct (relative to the directory) import URLs for the dependent schemas. The root schema that I am trying to make work with XSD is called ITL-2007f-Package.xsd and it depends on a bunch of other schemas that model data used by various government agencies. http://www.doj.state.wi.us/les/NIST-ITL/Schema_docs_2007f/Package2007f.zip FYI, we have had success making this schema work with XJC (Java API for XML Binding, JAXB), so I believe it's a valid XML schema set. We also converted it to UML using XMLModeling's hyperModel with no errors. My attempts so far have not been successful. XSD complains that a type ' http://niem.gov/niem/ansi-nist/2.0:FingerprintType' is not found, although it's clearly defined in one of the included schemas. This set of schemas has cycles in some of its imports, which apparently is legal in XML. I tried the advice at http://www.codesynthesis.com/~boris/blog/2008/02/13/codesynthesis-xsd-3-1-0-released/but the undefined type problem still exists. I'd be happy to have any feedback on whether (or how) XSD can work with this to generate C++ code to parse/write XML. Cris From boris at codesynthesis.com Thu Mar 26 06:10:34 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Calculating progress on "xsd-parser" parsed files In-Reply-To: <97823d5c0903252124x3b2147c5rd0dfd9af2aff889@mail.gmail.com> References: <97823d5c0903252124x3b2147c5rd0dfd9af2aff889@mail.gmail.com> Message-ID: Hi David, David White writes: > Is it possible to get an indication of conversion process with > xsd / xerces? There is no built-in support for this though it is relatively easy to do. There are also several ways you can do it. You can use the underlying SAX2 parser's (SAX2XMLReader) getSrcOffset() function along with the total file length to determine the progress. Or you can use the file stream position to get the same information. In either case the overall structure of the code will be the same. You probably have a top-level parser with one of its callbacks being called periodically as parsing progresses. Something along these lines: ... You can pass the file stream or SAX2 parser reference to the parser for this top-level type and then calculate the progress each time the callback is called, something along these lines: struct root_pimpl: root_pskel { root_pimpl (std::ifstream& is, size_t size) : is_ (is), size_ (size) { } virtual void record (...) { // Callculate the progress. // size_t cur = is_.tellg (); ... } private: std::ifstream& is_; size size_; }; int main () { ifstream ifs; ifs.exceptions (ios_base::failbit); ifs.open (file, ios::in | ios::ate); size_t size (ifs.tellg ()); ifs.seekg (0, ios::beg); root_pimpl root_p (ifs, size); ... xml_schema::document doc (root_p, "root"); ... } Boris From boris at codesynthesis.com Thu Mar 26 11:50:28 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Public XML schema that works in XJC (Java) but maybe not in CodeSynthesis XSD In-Reply-To: <955f8a1b0903251428q221a5b8aybf64bbfca0a554b1@mail.gmail.com> References: <955f8a1b0903251428q221a5b8aybf64bbfca0a554b1@mail.gmail.com> Message-ID: Cris, Christopher Fuhrman writes: > My attempts so far have not been successful. XSD complains that a type ' > http://niem.gov/niem/ansi-nist/2.0:FingerprintType' is not found, although > it's clearly defined in one of the included schemas. At first sight I tend to agree, the error appears to be bogus. I will try to figure out what's going on though it may take a couple of days to analyze since the schema is quite complex. I will keep you posted. Boris From maiabhmg at gmail.com Thu Mar 26 15:01:50 2009 From: maiabhmg at gmail.com (Leandro Maia) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Problems Generanting XML with Optional Tag Message-ID: <49CBD11E.3000500@gmail.com> Hi, I have a XSD and the CXX and HXX files generated by CodeSynthesis tool... Everything works fine, but, SOMETIMES, when I generate the output, the tool generate a XML that is not according to the XSD. The XSD, XML with problem, CXX and HXX are attached. The problem is in the line 112 of the XML. May someone help me with this problem ? Regards. -- Leandro Maia -------------- next part -------------- A non-text attachment was scrubbed... Name: Identificador.xsd Type: application/xml Size: 1606 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090326/d7b37f57/Identificador.xml -------------- next part -------------- A non-text attachment was scrubbed... Name: Identificador.xml Type: text/xml Size: 54193 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20090326/d7b37f57/Identificador.bin -------------- next part -------------- // Copyright (C) 2005-2008 Code Synthesis Tools CC // // This program was generated by CodeSynthesis XSD, an XML Schema to // C++ data binding compiler. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // In addition, as a special exception, Code Synthesis Tools CC gives // permission to link this program with the Xerces-C++ library (or with // modified versions of Xerces-C++ that use the same license as Xerces-C++), // and distribute linked combinations including the two. You must obey // the GNU General Public License version 2 in all respects for all of // the code used other than Xerces-C++. If you modify this copy of the // program, you may extend this exception to your version of the program, // but you are not obligated to do so. If you do not wish to do so, delete // this exception statement from your version. // // Furthermore, Code Synthesis Tools CC makes a special exception for // the Free/Libre and Open Source Software (FLOSS) which is described // in the accompanying FLOSSE file. // // Begin prologue. // // // End prologue. #include #include "Identificador.hxx" namespace eIdentificador { // classType // classType:: classType (value v) : ::xml_schema::string (_xsd_classType_literals_[v]) { } classType:: classType (const char* v) : ::xml_schema::string (v) { } classType:: classType (const ::std::string& v) : ::xml_schema::string (v) { } classType:: classType (const ::xml_schema::string& v) : ::xml_schema::string (v) { } classType:: classType (const classType& v, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string (v, f, c) { } classType& classType:: operator= (value v) { static_cast< ::xml_schema::string& > (*this) = ::xml_schema::string (_xsd_classType_literals_[v]); return *this; } // idType // const idType::nome_type& idType:: nome () const { return this->nome_.get (); } idType::nome_type& idType:: nome () { return this->nome_.get (); } void idType:: nome (const nome_type& x) { this->nome_.set (x); } void idType:: nome (::std::auto_ptr< nome_type > x) { this->nome_.set (x); } const idType::eId_type& idType:: eId () const { return this->eId_.get (); } idType::eId_type& idType:: eId () { return this->eId_.get (); } void idType:: eId (const eId_type& x) { this->eId_.set (x); } void idType:: eId (::std::auto_ptr< eId_type > x) { this->eId_.set (x); } const idType::classe_type& idType:: classe () const { return this->classe_.get (); } idType::classe_type& idType:: classe () { return this->classe_.get (); } void idType:: classe (const classe_type& x) { this->classe_.set (x); } void idType:: classe (::std::auto_ptr< classe_type > x) { this->classe_.set (x); } const idType::obs_type& idType:: obs () const { return this->obs_.get (); } idType::obs_type& idType:: obs () { return this->obs_.get (); } void idType:: obs (const obs_type& x) { this->obs_.set (x); } void idType:: obs (::std::auto_ptr< obs_type > x) { this->obs_.set (x); } const idType::ativo_type& idType:: ativo () const { return this->ativo_.get (); } idType::ativo_type& idType:: ativo () { return this->ativo_.get (); } void idType:: ativo (const ativo_type& x) { this->ativo_.set (x); } const idType::filhos_optional& idType:: filhos () const { return this->filhos_; } idType::filhos_optional& idType:: filhos () { return this->filhos_; } void idType:: filhos (const filhos_type& x) { this->filhos_.set (x); } void idType:: filhos (const filhos_optional& x) { this->filhos_ = x; } void idType:: filhos (::std::auto_ptr< filhos_type > x) { this->filhos_.set (x); } const idType::id_type& idType:: id () const { return this->id_.get (); } idType::id_type& idType:: id () { return this->id_.get (); } void idType:: id (const id_type& x) { this->id_.set (x); } // childType // const childType::identificador_sequence& childType:: identificador () const { return this->identificador_; } childType::identificador_sequence& childType:: identificador () { return this->identificador_; } void childType:: identificador (const identificador_sequence& s) { this->identificador_ = s; } // idLstType // const idLstType::identificador_sequence& idLstType:: identificador () const { return this->identificador_; } idLstType::identificador_sequence& idLstType:: identificador () { return this->identificador_; } void idLstType:: identificador (const identificador_sequence& s) { this->identificador_ = s; } } #include namespace eIdentificador { // classType // classType:: classType (const xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string (e, f, c) { _xsd_classType_convert (); } classType:: classType (const xercesc::DOMAttr& a, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string (a, f, c) { _xsd_classType_convert (); } classType:: classType (const ::std::string& s, const xercesc::DOMElement* e, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string (s, e, f, c) { _xsd_classType_convert (); } classType* classType:: _clone (::xml_schema::flags f, ::xml_schema::container* c) const { return new class classType (*this, f, c); } classType::value classType:: _xsd_classType_convert () const { ::xsd::cxx::tree::enum_comparator< char > c (_xsd_classType_literals_); const value* i (::std::lower_bound ( _xsd_classType_indexes_, _xsd_classType_indexes_ + 7, *this, c)); if (i == _xsd_classType_indexes_ + 7 || _xsd_classType_literals_[*i] != *this) { throw ::xsd::cxx::tree::unexpected_enumerator < char > (*this); } return *i; } const char* const classType:: _xsd_classType_literals_[7] = { "GERAL", "MONTADORA", "VEICULO", "MOTOR_MODELO", "ANO", "INTERFACE", "SISTEMA" }; const classType::value classType:: _xsd_classType_indexes_[7] = { ::eIdentificador::classType::ANO, ::eIdentificador::classType::GERAL, ::eIdentificador::classType::INTERFACE, ::eIdentificador::classType::MONTADORA, ::eIdentificador::classType::MOTOR_MODELO, ::eIdentificador::classType::SISTEMA, ::eIdentificador::classType::VEICULO }; // idType // idType:: idType (const nome_type& nome, const eId_type& eId, const classe_type& classe, const obs_type& obs, const ativo_type& ativo, const id_type& id) : ::xml_schema::type (), nome_ (nome, ::xml_schema::flags (), this), eId_ (eId, ::xml_schema::flags (), this), classe_ (classe, ::xml_schema::flags (), this), obs_ (obs, ::xml_schema::flags (), this), ativo_ (ativo, ::xml_schema::flags (), this), filhos_ (::xml_schema::flags (), this), id_ (id, ::xml_schema::flags (), this) { } idType:: idType (const idType& x, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type (x, f, c), nome_ (x.nome_, f, this), eId_ (x.eId_, f, this), classe_ (x.classe_, f, this), obs_ (x.obs_, f, this), ativo_ (x.ativo_, f, this), filhos_ (x.filhos_, f, this), id_ (x.id_, f, this) { } idType:: idType (const xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type (e, f | ::xml_schema::flags::base, c), nome_ (f, this), eId_ (f, this), classe_ (f, this), obs_ (f, this), ativo_ (f, this), filhos_ (f, this), id_ (f, this) { if ((f & ::xml_schema::flags::base) == 0) { ::xsd::cxx::xml::dom::parser< char > p (e, true, true); this->parse (p, f); } } void idType:: parse (::xsd::cxx::xml::dom::parser< char >& p, ::xml_schema::flags f) { for (; p.more_elements (); p.next_element ()) { const xercesc::DOMElement& i (p.cur_element ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (i)); // nome // if (n.name () == "nome" && n.namespace_ ().empty ()) { ::std::auto_ptr< nome_type > r ( nome_traits::create (i, f, this)); if (!nome_.present ()) { this->nome_.set (r); continue; } } // eId // if (n.name () == "eId" && n.namespace_ ().empty ()) { ::std::auto_ptr< eId_type > r ( eId_traits::create (i, f, this)); if (!eId_.present ()) { this->eId_.set (r); continue; } } // classe // if (n.name () == "classe" && n.namespace_ ().empty ()) { ::std::auto_ptr< classe_type > r ( classe_traits::create (i, f, this)); if (!classe_.present ()) { this->classe_.set (r); continue; } } // obs // if (n.name () == "obs" && n.namespace_ ().empty ()) { ::std::auto_ptr< obs_type > r ( obs_traits::create (i, f, this)); if (!obs_.present ()) { this->obs_.set (r); continue; } } // ativo // if (n.name () == "ativo" && n.namespace_ ().empty ()) { if (!ativo_.present ()) { this->ativo_.set (ativo_traits::create (i, f, this)); continue; } } // filhos // if (n.name () == "filhos" && n.namespace_ ().empty ()) { ::std::auto_ptr< filhos_type > r ( filhos_traits::create (i, f, this)); if (!this->filhos_) { this->filhos_.set (r); continue; } } break; } if (!nome_.present ()) { throw ::xsd::cxx::tree::expected_element< char > ( "nome", ""); } if (!eId_.present ()) { throw ::xsd::cxx::tree::expected_element< char > ( "eId", ""); } if (!classe_.present ()) { throw ::xsd::cxx::tree::expected_element< char > ( "classe", ""); } if (!obs_.present ()) { throw ::xsd::cxx::tree::expected_element< char > ( "obs", ""); } if (!ativo_.present ()) { throw ::xsd::cxx::tree::expected_element< char > ( "ativo", ""); } while (p.more_attributes ()) { const xercesc::DOMAttr& i (p.next_attribute ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (i)); if (n.name () == "id" && n.namespace_ ().empty ()) { this->id_.set (id_traits::create (i, f, this)); continue; } } if (!id_.present ()) { throw ::xsd::cxx::tree::expected_attribute< char > ( "id", ""); } } idType* idType:: _clone (::xml_schema::flags f, ::xml_schema::container* c) const { return new class idType (*this, f, c); } idType:: ~idType () { } // childType // childType:: childType () : ::xml_schema::type (), identificador_ (::xml_schema::flags (), this) { } childType:: childType (const childType& x, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type (x, f, c), identificador_ (x.identificador_, f, this) { } childType:: childType (const xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type (e, f | ::xml_schema::flags::base, c), identificador_ (f, this) { if ((f & ::xml_schema::flags::base) == 0) { ::xsd::cxx::xml::dom::parser< char > p (e, true, false); this->parse (p, f); } } void childType:: parse (::xsd::cxx::xml::dom::parser< char >& p, ::xml_schema::flags f) { for (; p.more_elements (); p.next_element ()) { const xercesc::DOMElement& i (p.cur_element ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (i)); // identificador // if (n.name () == "identificador" && n.namespace_ ().empty ()) { ::std::auto_ptr< identificador_type > r ( identificador_traits::create (i, f, this)); this->identificador_.push_back (r); continue; } break; } } childType* childType:: _clone (::xml_schema::flags f, ::xml_schema::container* c) const { return new class childType (*this, f, c); } childType:: ~childType () { } // idLstType // idLstType:: idLstType () : ::xml_schema::type (), identificador_ (::xml_schema::flags (), this) { } idLstType:: idLstType (const idLstType& x, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type (x, f, c), identificador_ (x.identificador_, f, this) { } idLstType:: idLstType (const xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type (e, f | ::xml_schema::flags::base, c), identificador_ (f, this) { if ((f & ::xml_schema::flags::base) == 0) { ::xsd::cxx::xml::dom::parser< char > p (e, true, false); this->parse (p, f); } } void idLstType:: parse (::xsd::cxx::xml::dom::parser< char >& p, ::xml_schema::flags f) { for (; p.more_elements (); p.next_element ()) { const xercesc::DOMElement& i (p.cur_element ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (i)); // identificador // if (n.name () == "identificador" && n.namespace_ ().empty ()) { ::std::auto_ptr< identificador_type > r ( identificador_traits::create (i, f, this)); this->identificador_.push_back (r); continue; } break; } } idLstType* idLstType:: _clone (::xml_schema::flags f, ::xml_schema::container* c) const { return new class idLstType (*this, f, c); } idLstType:: ~idLstType () { } } #include namespace eIdentificador { ::std::ostream& operator<< (::std::ostream& o, classType::value i) { return o << classType::_xsd_classType_literals_[i]; } ::std::ostream& operator<< (::std::ostream& o, const classType& i) { return o << static_cast< const ::xml_schema::string& > (i); } ::std::ostream& operator<< (::std::ostream& o, const idType& i) { o << ::std::endl << "nome: " << i.nome (); o << ::std::endl << "eId: " << i.eId (); o << ::std::endl << "classe: " << i.classe (); o << ::std::endl << "obs: " << i.obs (); o << ::std::endl << "ativo: " << i.ativo (); if (i.filhos ()) { o << ::std::endl << "filhos: " << *i.filhos (); } o << ::std::endl << "id: " << i.id (); return o; } ::std::ostream& operator<< (::std::ostream& o, const childType& i) { for (childType::identificador_const_iterator b (i.identificador ().begin ()), e (i.identificador ().end ()); b != e; ++b) { o << ::std::endl << "identificador: " << *b; } return o; } ::std::ostream& operator<< (::std::ostream& o, const idLstType& i) { for (idLstType::identificador_const_iterator b (i.identificador ().begin ()), e (i.identificador ().end ()); b != e; ++b) { o << ::std::endl << "identificador: " << *b; } return o; } } #include #include #include namespace eIdentificador { ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (const ::std::string& u, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i ( (f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::tree::error_handler< char > h; ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::xsd::cxx::xml::dom::parse< char > (u, h, p, f)); h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > (); ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::eIdentificador::identificadores ( d, f | ::xml_schema::flags::own_dom, p)); return r; } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (const ::std::string& u, ::xml_schema::error_handler& h, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i ( (f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::xsd::cxx::xml::dom::parse< char > (u, h, p, f)); if (!d.get ()) throw ::xsd::cxx::tree::parsing< char > (); ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::eIdentificador::identificadores ( d, f | ::xml_schema::flags::own_dom, p)); return r; } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (const ::std::string& u, xercesc::DOMErrorHandler& h, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::xsd::cxx::xml::dom::parse< char > (u, h, p, f)); if (!d.get ()) throw ::xsd::cxx::tree::parsing< char > (); ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::eIdentificador::identificadores ( d, f | ::xml_schema::flags::own_dom, p)); return r; } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i ( (f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::xml::sax::std_input_source isrc (is); return ::eIdentificador::identificadores (isrc, f, p); } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, ::xml_schema::error_handler& h, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i ( (f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::xml::sax::std_input_source isrc (is); return ::eIdentificador::identificadores (isrc, h, f, p); } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, xercesc::DOMErrorHandler& h, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::sax::std_input_source isrc (is); return ::eIdentificador::identificadores (isrc, h, f, p); } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, const ::std::string& sid, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i ( (f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); return ::eIdentificador::identificadores (isrc, f, p); } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, const ::std::string& sid, ::xml_schema::error_handler& h, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i ( (f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); return ::eIdentificador::identificadores (isrc, h, f, p); } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, const ::std::string& sid, xercesc::DOMErrorHandler& h, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); return ::eIdentificador::identificadores (isrc, h, f, p); } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (xercesc::InputSource& i, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::tree::error_handler< char > h; ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::xsd::cxx::xml::dom::parse< char > (i, h, p, f)); h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > (); ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::eIdentificador::identificadores ( d, f | ::xml_schema::flags::own_dom, p)); return r; } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (xercesc::InputSource& i, ::xml_schema::error_handler& h, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::xsd::cxx::xml::dom::parse< char > (i, h, p, f)); if (!d.get ()) throw ::xsd::cxx::tree::parsing< char > (); ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::eIdentificador::identificadores ( d, f | ::xml_schema::flags::own_dom, p)); return r; } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (xercesc::InputSource& i, xercesc::DOMErrorHandler& h, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::xsd::cxx::xml::dom::parse< char > (i, h, p, f)); if (!d.get ()) throw ::xsd::cxx::tree::parsing< char > (); ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::eIdentificador::identificadores ( d, f | ::xml_schema::flags::own_dom, p)); return r; } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (const xercesc::DOMDocument& d, ::xml_schema::flags f, const ::xml_schema::properties& p) { if (f & ::xml_schema::flags::keep_dom) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > c ( static_cast< xercesc::DOMDocument* > (d.cloneNode (true))); ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::eIdentificador::identificadores ( c, f | ::xml_schema::flags::own_dom, p)); return r; } const xercesc::DOMElement& e (*d.getDocumentElement ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (e)); if (n.name () == "identificadores" && n.namespace_ () == "http://www.scanitec.com.br/eIdentificador") { ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::xsd::cxx::tree::traits< ::eIdentificador::idLstType, char >::create ( e, f, 0)); return r; } throw ::xsd::cxx::tree::unexpected_element < char > ( n.name (), n.namespace_ (), "identificadores", "http://www.scanitec.com.br/eIdentificador"); } ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::xml_schema::dom::auto_ptr< xercesc::DOMDocument >& d, ::xml_schema::flags f, const ::xml_schema::properties&) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > c ( ((f & ::xml_schema::flags::keep_dom) && !(f & ::xml_schema::flags::own_dom)) ? static_cast< xercesc::DOMDocument* > (d->cloneNode (true)) : 0); xercesc::DOMDocument& doc (c.get () ? *c : *d); const xercesc::DOMElement& e (*doc.getDocumentElement ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (e)); if (f & ::xml_schema::flags::keep_dom) doc.setUserData (::xml_schema::dom::tree_node_key, (c.get () ? &c : &d), 0); if (n.name () == "identificadores" && n.namespace_ () == "http://www.scanitec.com.br/eIdentificador") { ::std::auto_ptr< ::eIdentificador::idLstType > r ( ::xsd::cxx::tree::traits< ::eIdentificador::idLstType, char >::create ( e, f, 0)); return r; } throw ::xsd::cxx::tree::unexpected_element < char > ( n.name (), n.namespace_ (), "identificadores", "http://www.scanitec.com.br/eIdentificador"); } } #include #include #include namespace eIdentificador { void operator<< (xercesc::DOMElement& e, const classType& i) { e << static_cast< const ::xml_schema::string& > (i); } void operator<< (xercesc::DOMAttr& a, const classType& i) { a << static_cast< const ::xml_schema::string& > (i); } void operator<< (::xml_schema::list_stream& l, const classType& i) { l << static_cast< const ::xml_schema::string& > (i); } void operator<< (xercesc::DOMElement& e, const idType& i) { e << static_cast< const ::xml_schema::type& > (i); // nome // { xercesc::DOMElement& s ( ::xsd::cxx::xml::dom::create_element ( "nome", e)); s << i.nome (); } // eId // { xercesc::DOMElement& s ( ::xsd::cxx::xml::dom::create_element ( "eId", e)); s << i.eId (); } // classe // { xercesc::DOMElement& s ( ::xsd::cxx::xml::dom::create_element ( "classe", e)); s << i.classe (); } // obs // { xercesc::DOMElement& s ( ::xsd::cxx::xml::dom::create_element ( "obs", e)); s << i.obs (); } // ativo // { xercesc::DOMElement& s ( ::xsd::cxx::xml::dom::create_element ( "ativo", e)); s << i.ativo (); } // filhos // if (i.filhos ()) { xercesc::DOMElement& s ( ::xsd::cxx::xml::dom::create_element ( "filhos", e)); s << *i.filhos (); } // id // { xercesc::DOMAttr& a ( ::xsd::cxx::xml::dom::create_attribute ( "id", e)); a << i.id (); } } void operator<< (xercesc::DOMElement& e, const childType& i) { e << static_cast< const ::xml_schema::type& > (i); // identificador // for (childType::identificador_const_iterator b (i.identificador ().begin ()), n (i.identificador ().end ()); b != n; ++b) { xercesc::DOMElement& s ( ::xsd::cxx::xml::dom::create_element ( "identificador", e)); s << *b; } } void operator<< (xercesc::DOMElement& e, const idLstType& i) { e << static_cast< const ::xml_schema::type& > (i); // identificador // for (idLstType::identificador_const_iterator b (i.identificador ().begin ()), n (i.identificador ().end ()); b != n; ++b) { xercesc::DOMElement& s ( ::xsd::cxx::xml::dom::create_element ( "identificador", e)); s << *b; } } void identificadores (::std::ostream& o, const ::eIdentificador::idLstType& s, const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { ::xsd::cxx::xml::auto_initializer i ( (f & ::xml_schema::flags::dont_initialize) == 0); ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::eIdentificador::identificadores (s, m, f)); ::xsd::cxx::tree::error_handler< char > h; ::xsd::cxx::xml::dom::ostream_format_target t (o); if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) { h.throw_if_failed< ::xsd::cxx::tree::serialization< char > > (); } } void identificadores (::std::ostream& o, const ::eIdentificador::idLstType& s, ::xml_schema::error_handler& h, const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { ::xsd::cxx::xml::auto_initializer i ( (f & ::xml_schema::flags::dont_initialize) == 0); ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::eIdentificador::identificadores (s, m, f)); ::xsd::cxx::xml::dom::ostream_format_target t (o); if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) { throw ::xsd::cxx::tree::serialization< char > (); } } void identificadores (::std::ostream& o, const ::eIdentificador::idLstType& s, xercesc::DOMErrorHandler& h, const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::eIdentificador::identificadores (s, m, f)); ::xsd::cxx::xml::dom::ostream_format_target t (o); if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) { throw ::xsd::cxx::tree::serialization< char > (); } } void identificadores (xercesc::XMLFormatTarget& t, const ::eIdentificador::idLstType& s, const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::eIdentificador::identificadores (s, m, f)); ::xsd::cxx::tree::error_handler< char > h; if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) { h.throw_if_failed< ::xsd::cxx::tree::serialization< char > > (); } } void identificadores (xercesc::XMLFormatTarget& t, const ::eIdentificador::idLstType& s, ::xml_schema::error_handler& h, const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::eIdentificador::identificadores (s, m, f)); if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) { throw ::xsd::cxx::tree::serialization< char > (); } } void identificadores (xercesc::XMLFormatTarget& t, const ::eIdentificador::idLstType& s, xercesc::DOMErrorHandler& h, const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::eIdentificador::identificadores (s, m, f)); if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) { throw ::xsd::cxx::tree::serialization< char > (); } } void identificadores (xercesc::DOMDocument& d, const ::eIdentificador::idLstType& s, ::xml_schema::flags) { xercesc::DOMElement& e (*d.getDocumentElement ()); const ::xsd::cxx::xml::qualified_name< char > n ( ::xsd::cxx::xml::dom::name< char > (e)); if (n.name () == "identificadores" && n.namespace_ () == "http://www.scanitec.com.br/eIdentificador") { e << s; } else { throw ::xsd::cxx::tree::unexpected_element < char > ( n.name (), n.namespace_ (), "identificadores", "http://www.scanitec.com.br/eIdentificador"); } } ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > identificadores (const ::eIdentificador::idLstType& s, const ::xml_schema::namespace_infomap& m, ::xml_schema::flags f) { ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > d ( ::xsd::cxx::xml::dom::serialize< char > ( "identificadores", "http://www.scanitec.com.br/eIdentificador", m, f)); ::eIdentificador::identificadores (*d, s, f); return d; } } #include // Begin epilogue. // // // End epilogue. -------------- next part -------------- // Copyright (C) 2005-2008 Code Synthesis Tools CC // // This program was generated by CodeSynthesis XSD, an XML Schema to // C++ data binding compiler. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // In addition, as a special exception, Code Synthesis Tools CC gives // permission to link this program with the Xerces-C++ library (or with // modified versions of Xerces-C++ that use the same license as Xerces-C++), // and distribute linked combinations including the two. You must obey // the GNU General Public License version 2 in all respects for all of // the code used other than Xerces-C++. If you modify this copy of the // program, you may extend this exception to your version of the program, // but you are not obligated to do so. If you do not wish to do so, delete // this exception statement from your version. // // Furthermore, Code Synthesis Tools CC makes a special exception for // the Free/Libre and Open Source Software (FLOSS) which is described // in the accompanying FLOSSE file. // #ifndef CXX___SRC_IDENTIFICADOR_HXX #define CXX___SRC_IDENTIFICADOR_HXX // Begin prologue. // // // End prologue. #include #if (XSD_INT_VERSION != 3020000L) #error XSD runtime version mismatch #endif #include #ifndef XSD_USE_CHAR #define XSD_USE_CHAR #endif #ifndef XSD_CXX_TREE_USE_CHAR #define XSD_CXX_TREE_USE_CHAR #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace xml_schema { // anyType and anySimpleType. // typedef ::xsd::cxx::tree::type type; typedef ::xsd::cxx::tree::simple_type< type > simple_type; typedef ::xsd::cxx::tree::type container; // 8-bit // typedef signed char byte; typedef unsigned char unsigned_byte; // 16-bit // typedef short short_; typedef unsigned short unsigned_short; // 32-bit // typedef int int_; typedef unsigned int unsigned_int; // 64-bit // typedef long long long_; typedef unsigned long long unsigned_long; // Supposed to be arbitrary-length integral types. // typedef long long integer; typedef long long non_positive_integer; typedef unsigned long long non_negative_integer; typedef unsigned long long positive_integer; typedef long long negative_integer; // Boolean. // typedef bool boolean; // Floating-point types. // typedef float float_; typedef double double_; typedef double decimal; // String types. // typedef ::xsd::cxx::tree::string< char, simple_type > string; typedef ::xsd::cxx::tree::normalized_string< char, string > normalized_string; typedef ::xsd::cxx::tree::token< char, normalized_string > token; typedef ::xsd::cxx::tree::name< char, token > name; typedef ::xsd::cxx::tree::nmtoken< char, token > nmtoken; typedef ::xsd::cxx::tree::nmtokens< char, simple_type, nmtoken > nmtokens; typedef ::xsd::cxx::tree::ncname< char, name > ncname; typedef ::xsd::cxx::tree::language< char, token > language; // ID/IDREF. // typedef ::xsd::cxx::tree::id< char, ncname > id; typedef ::xsd::cxx::tree::idref< type, char, ncname > idref; typedef ::xsd::cxx::tree::idrefs< char, simple_type, idref > idrefs; // URI. // typedef ::xsd::cxx::tree::uri< char, simple_type > uri; // Qualified name. // typedef ::xsd::cxx::tree::qname< char, simple_type, uri, ncname > qname; // Binary. // typedef ::xsd::cxx::tree::buffer< char > buffer; typedef ::xsd::cxx::tree::base64_binary< char, simple_type > base64_binary; typedef ::xsd::cxx::tree::hex_binary< char, simple_type > hex_binary; // Date/time. // typedef ::xsd::cxx::tree::time_zone time_zone; typedef ::xsd::cxx::tree::date< char, simple_type > date; typedef ::xsd::cxx::tree::date_time< char, simple_type > date_time; typedef ::xsd::cxx::tree::duration< char, simple_type > duration; typedef ::xsd::cxx::tree::gday< char, simple_type > gday; typedef ::xsd::cxx::tree::gmonth< char, simple_type > gmonth; typedef ::xsd::cxx::tree::gmonth_day< char, simple_type > gmonth_day; typedef ::xsd::cxx::tree::gyear< char, simple_type > gyear; typedef ::xsd::cxx::tree::gyear_month< char, simple_type > gyear_month; typedef ::xsd::cxx::tree::time< char, simple_type > time; // Entity. // typedef ::xsd::cxx::tree::entity< char, ncname > entity; typedef ::xsd::cxx::tree::entities< char, simple_type, entity > entities; // Namespace information and list stream. Used in // serialization functions. // typedef ::xsd::cxx::xml::dom::namespace_info < char > namespace_info; typedef ::xsd::cxx::xml::dom::namespace_infomap < char > namespace_infomap; typedef ::xsd::cxx::tree::list_stream < char > list_stream; typedef ::xsd::cxx::tree::as_double < double_ > as_double; typedef ::xsd::cxx::tree::as_decimal < decimal > as_decimal; typedef ::xsd::cxx::tree::facet facet; // Flags and properties. // typedef ::xsd::cxx::tree::flags flags; typedef ::xsd::cxx::tree::properties< char > properties; // Exceptions. // typedef ::xsd::cxx::tree::exception< char > exception; typedef ::xsd::cxx::tree::bounds< char > bounds; typedef ::xsd::cxx::tree::duplicate_id< char > duplicate_id; typedef ::xsd::cxx::tree::parsing< char > parsing; typedef ::xsd::cxx::tree::expected_element< char > expected_element; typedef ::xsd::cxx::tree::unexpected_element< char > unexpected_element; typedef ::xsd::cxx::tree::expected_attribute< char > expected_attribute; typedef ::xsd::cxx::tree::unexpected_enumerator< char > unexpected_enumerator; typedef ::xsd::cxx::tree::expected_text_content< char > expected_text_content; typedef ::xsd::cxx::tree::no_prefix_mapping< char > no_prefix_mapping; typedef ::xsd::cxx::tree::serialization< char > serialization; // Parsing/serialization diagnostics. // typedef ::xsd::cxx::tree::severity severity; typedef ::xsd::cxx::tree::error< char > error; typedef ::xsd::cxx::tree::diagnostics< char > diagnostics; // Error handler callback interface. // typedef ::xsd::cxx::xml::error_handler< char > error_handler; // DOM interaction. // namespace dom { // Automatic pointer for DOMDocument. // using ::xsd::cxx::xml::dom::auto_ptr; #ifndef XSD_CXX_TREE_TREE_NODE_KEY_IN___XML_SCHEMA #define XSD_CXX_TREE_TREE_NODE_KEY_IN___XML_SCHEMA // DOM user data key for back pointers to tree nodes. // const XMLCh* const tree_node_key = ::xsd::cxx::tree::user_data_keys::node; #endif } } // Forward declarations. // namespace eIdentificador { class classType; class idType; class childType; class idLstType; } #include // std::auto_ptr #include // std::binary_search #include #include #include #include #include namespace eIdentificador { class classType: public ::xml_schema::string { public: enum value { GERAL, MONTADORA, VEICULO, MOTOR_MODELO, ANO, INTERFACE, SISTEMA }; classType (value v); classType (const char* v); classType (const ::std::string& v); classType (const ::xml_schema::string& v); classType (const xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); classType (const xercesc::DOMAttr& a, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); classType (const ::std::string& s, const xercesc::DOMElement* e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); classType (const classType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); virtual classType* _clone (::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; classType& operator= (value v); virtual operator value () const { return _xsd_classType_convert (); } protected: value _xsd_classType_convert () const; public: static const char* const _xsd_classType_literals_[7]; static const value _xsd_classType_indexes_[7]; }; class idType: public ::xml_schema::type { public: // nome // typedef ::xml_schema::string nome_type; typedef ::xsd::cxx::tree::traits< nome_type, char > nome_traits; const nome_type& nome () const; nome_type& nome (); void nome (const nome_type& x); void nome (::std::auto_ptr< nome_type > p); // eId // typedef ::xml_schema::string eId_type; typedef ::xsd::cxx::tree::traits< eId_type, char > eId_traits; const eId_type& eId () const; eId_type& eId (); void eId (const eId_type& x); void eId (::std::auto_ptr< eId_type > p); // classe // typedef ::eIdentificador::classType classe_type; typedef ::xsd::cxx::tree::traits< classe_type, char > classe_traits; const classe_type& classe () const; classe_type& classe (); void classe (const classe_type& x); void classe (::std::auto_ptr< classe_type > p); // obs // typedef ::xml_schema::string obs_type; typedef ::xsd::cxx::tree::traits< obs_type, char > obs_traits; const obs_type& obs () const; obs_type& obs (); void obs (const obs_type& x); void obs (::std::auto_ptr< obs_type > p); // ativo // typedef ::xml_schema::boolean ativo_type; typedef ::xsd::cxx::tree::traits< ativo_type, char > ativo_traits; const ativo_type& ativo () const; ativo_type& ativo (); void ativo (const ativo_type& x); // filhos // typedef ::eIdentificador::childType filhos_type; typedef ::xsd::cxx::tree::optional< filhos_type > filhos_optional; typedef ::xsd::cxx::tree::traits< filhos_type, char > filhos_traits; const filhos_optional& filhos () const; filhos_optional& filhos (); void filhos (const filhos_type& x); void filhos (const filhos_optional& x); void filhos (::std::auto_ptr< filhos_type > p); // id // typedef ::xml_schema::unsigned_int id_type; typedef ::xsd::cxx::tree::traits< id_type, char > id_traits; const id_type& id () const; id_type& id (); void id (const id_type& x); // Constructors. // idType (const nome_type&, const eId_type&, const classe_type&, const obs_type&, const ativo_type&, const id_type&); idType (const xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); idType (const idType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); virtual idType* _clone (::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; virtual ~idType (); // Implementation. // protected: void parse (::xsd::cxx::xml::dom::parser< char >&, ::xml_schema::flags); protected: ::xsd::cxx::tree::one< nome_type > nome_; ::xsd::cxx::tree::one< eId_type > eId_; ::xsd::cxx::tree::one< classe_type > classe_; ::xsd::cxx::tree::one< obs_type > obs_; ::xsd::cxx::tree::one< ativo_type > ativo_; filhos_optional filhos_; ::xsd::cxx::tree::one< id_type > id_; }; class childType: public ::xml_schema::type { public: // identificador // typedef ::eIdentificador::idType identificador_type; typedef ::xsd::cxx::tree::sequence< identificador_type > identificador_sequence; typedef xsd::cxx::tree::sequence< identificador_type >::iterator identificador_iterator; typedef xsd::cxx::tree::sequence< identificador_type >::const_iterator identificador_const_iterator; typedef ::xsd::cxx::tree::traits< identificador_type, char > identificador_traits; const identificador_sequence& identificador () const; identificador_sequence& identificador (); void identificador (const identificador_sequence& s); // Constructors. // childType (); childType (const xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); childType (const childType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); virtual childType* _clone (::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; virtual ~childType (); // Implementation. // protected: void parse (::xsd::cxx::xml::dom::parser< char >&, ::xml_schema::flags); protected: identificador_sequence identificador_; }; class idLstType: public ::xml_schema::type { public: // identificador // typedef ::eIdentificador::idType identificador_type; typedef ::xsd::cxx::tree::sequence< identificador_type > identificador_sequence; typedef xsd::cxx::tree::sequence< identificador_type >::iterator identificador_iterator; typedef xsd::cxx::tree::sequence< identificador_type >::const_iterator identificador_const_iterator; typedef ::xsd::cxx::tree::traits< identificador_type, char > identificador_traits; const identificador_sequence& identificador () const; identificador_sequence& identificador (); void identificador (const identificador_sequence& s); // Constructors. // idLstType (); idLstType (const xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); idLstType (const idLstType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); virtual idLstType* _clone (::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; virtual ~idLstType (); // Implementation. // protected: void parse (::xsd::cxx::xml::dom::parser< char >&, ::xml_schema::flags); protected: identificador_sequence identificador_; }; } #include namespace eIdentificador { ::std::ostream& operator<< (::std::ostream&, classType::value); ::std::ostream& operator<< (::std::ostream&, const classType&); ::std::ostream& operator<< (::std::ostream&, const idType&); ::std::ostream& operator<< (::std::ostream&, const childType&); ::std::ostream& operator<< (::std::ostream&, const idLstType&); } #include #include #include #include namespace eIdentificador { // Parse a URI or a local file. // ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (const ::std::string& uri, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (const ::std::string& uri, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (const ::std::string& uri, xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); // Parse std::istream. // ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, const ::std::string& id, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, const ::std::string& id, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::std::istream& is, const ::std::string& id, xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); // Parse xercesc::InputSource. // ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (xercesc::InputSource& is, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (xercesc::InputSource& is, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (xercesc::InputSource& is, xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); // Parse xercesc::DOMDocument. // ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (const xercesc::DOMDocument& d, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); ::std::auto_ptr< ::eIdentificador::idLstType > identificadores (::xml_schema::dom::auto_ptr< xercesc::DOMDocument >& d, ::xml_schema::flags f = 0, const ::xml_schema::properties& p = ::xml_schema::properties ()); } #include #include #include #include #include namespace eIdentificador { void operator<< (xercesc::DOMElement&, const classType&); void operator<< (xercesc::DOMAttr&, const classType&); void operator<< (::xml_schema::list_stream&, const classType&); void operator<< (xercesc::DOMElement&, const idType&); void operator<< (xercesc::DOMElement&, const childType&); void operator<< (xercesc::DOMElement&, const idLstType&); // Serialize to std::ostream. // void identificadores (::std::ostream& os, const ::eIdentificador::idLstType& x, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap (), const ::std::string& e = "UTF-8", ::xml_schema::flags f = 0); void identificadores (::std::ostream& os, const ::eIdentificador::idLstType& x, ::xml_schema::error_handler& eh, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap (), const ::std::string& e = "UTF-8", ::xml_schema::flags f = 0); void identificadores (::std::ostream& os, const ::eIdentificador::idLstType& x, xercesc::DOMErrorHandler& eh, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap (), const ::std::string& e = "UTF-8", ::xml_schema::flags f = 0); // Serialize to xercesc::XMLFormatTarget. // void identificadores (xercesc::XMLFormatTarget& ft, const ::eIdentificador::idLstType& x, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap (), const ::std::string& e = "UTF-8", ::xml_schema::flags f = 0); void identificadores (xercesc::XMLFormatTarget& ft, const ::eIdentificador::idLstType& x, ::xml_schema::error_handler& eh, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap (), const ::std::string& e = "UTF-8", ::xml_schema::flags f = 0); void identificadores (xercesc::XMLFormatTarget& ft, const ::eIdentificador::idLstType& x, xercesc::DOMErrorHandler& eh, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap (), const ::std::string& e = "UTF-8", ::xml_schema::flags f = 0); // Serialize to an existing xercesc::DOMDocument. // void identificadores (xercesc::DOMDocument& d, const ::eIdentificador::idLstType& x, ::xml_schema::flags f = 0); // Serialize to a new xercesc::DOMDocument. // ::xml_schema::dom::auto_ptr< xercesc::DOMDocument > identificadores (const ::eIdentificador::idLstType& x, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap (), ::xml_schema::flags f = 0); } #include // Begin epilogue. // // // End epilogue. #endif // CXX___SRC_IDENTIFICADOR_HXX From dawhite32 at gmail.com Thu Mar 26 19:45:25 2009 From: dawhite32 at gmail.com (David White) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Calculating progress on "xsd-parser" parsed files In-Reply-To: References: <97823d5c0903252124x3b2147c5rd0dfd9af2aff889@mail.gmail.com> Message-ID: <97823d5c0903261645jfe01d0byc2396309da0cfee8@mail.gmail.com> Excellent! I cannot think of one reason why I would want to use any other XML binding software! Keep up the good work on this great project. David. On Thu, Mar 26, 2009 at 9:10 PM, Boris Kolpackov wrote: > Hi David, > > David White writes: > >> Is it possible to get an indication of conversion process with >> xsd / xerces? > > There is no built-in support for this though it is relatively > easy to do. There are also several ways you can do it. You can > use the underlying SAX2 parser's (SAX2XMLReader) getSrcOffset() > function along with the total file length to determine the > progress. Or you can use the file stream position to get the > same information. In either case the overall structure of the > code will be the same. You probably have a top-level parser > with one of its callbacks being called periodically as parsing > progresses. Something along these lines: > > > ? > ? ? > > ? ? ?... > > ? ? > ? > > > > > You can pass the file stream or SAX2 parser reference to the > parser for this top-level type and then calculate the progress > each time the callback is called, something along these lines: > > struct root_pimpl: root_pskel > { > ?root_pimpl (std::ifstream& is, size_t size) > ? ?: is_ (is), size_ (size) > ?{ > ?} > > ?virtual void > ?record (...) > ?{ > ? ?// Callculate the progress. > ? ?// > ? ?size_t cur = is_.tellg (); > ? ?... > ?} > > private: > ?std::ifstream& is_; > ?size size_; > }; > > int > main () > { > ?ifstream ifs; > ?ifs.exceptions (ios_base::failbit); > ?ifs.open (file, ios::in | ios::ate); > ?size_t size (ifs.tellg ()); > ?ifs.seekg (0, ios::beg); > > ?root_pimpl root_p (ifs, size); > > ?... > > ?xml_schema::document doc (root_p, "root"); > > ?... > } > > Boris > From boris at codesynthesis.com Thu Mar 26 23:42:51 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Problems Generanting XML with Optional Tag In-Reply-To: <49CBD11E.3000500@gmail.com> References: <49CBD11E.3000500@gmail.com> Message-ID: Hi Leandro, Leandro Maia writes: > I have a XSD and the CXX and HXX files generated by CodeSynthesis > tool... Everything works fine, but, SOMETIMES, when I generate the > output, the tool generate a XML that is not according to the XSD. We will need to see the code that generates the XML to figure out what the problem is. My guess is that you set a 'filhos' object without adding its (required) 'identificador' sub-objects. > The XSD, XML with problem, CXX and HXX are attached. You don't need to send the generated .cxx and .hxx files since they are big and we can easily generate them from the schema. For this and other posting guidelines see: http://www.codesynthesis.com/support/posting-guidelines.xhtml Boris From maiabhmg at gmail.com Fri Mar 27 08:36:36 2009 From: maiabhmg at gmail.com (Leandro Maia) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Problems Generanting XML with Optional Tag In-Reply-To: References: <49CBD11E.3000500@gmail.com> Message-ID: <49CCC854.8020007@gmail.com> Hi Boris, You are right... I really has a 'filhos' seted, but no 'identificador' in it's list. The problem is because I remove the last 'identificar' from 'filhos'. How can I "unset" 'filhos' ? Regards. Boris Kolpackov escreveu: Hi Leandro, Leandro Maia [1] writes: I have a XSD and the CXX and HXX files generated by CodeSynthesis tool... Everything works fine, but, SOMETIMES, when I generate the output, the tool generate a XML that is not according to the XSD. We will need to see the code that generates the XML to figure out what the problem is. My guess is that you set a 'filhos' object without adding its (required) 'identificador' sub-objects. The XSD, XML with problem, CXX and HXX are attached. You don't need to send the generated .cxx and .hxx files since they are big and we can easily generate them from the schema. For this and other posting guidelines see: [2]http://www.codesynthesis.com/support/posting-guidelines.xhtml Boris References 1. mailto:maiabhmg@gmail.com 2. http://www.codesynthesis.com/support/posting-guidelines.xhtml From maiabhmg at gmail.com Fri Mar 27 08:53:01 2009 From: maiabhmg at gmail.com (Leandro Maia) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Problems Generanting XML with Optional Tag In-Reply-To: References: <49CBD11E.3000500@gmail.com> Message-ID: <49CCCC2D.4020405@gmail.com> Thanks Boris. I fixed the problem. refPaiAntigo.filhos(eIdentificador::idType::filhos_optional()); where refPaiAntigo = &eIdentificador::idType. Thanks a lot. Boris Kolpackov escreveu: Hi Leandro, Leandro Maia [1] writes: I have a XSD and the CXX and HXX files generated by CodeSynthesis tool... Everything works fine, but, SOMETIMES, when I generate the output, the tool generate a XML that is not according to the XSD. We will need to see the code that generates the XML to figure out what the problem is. My guess is that you set a 'filhos' object without adding its (required) 'identificador' sub-objects. The XSD, XML with problem, CXX and HXX are attached. You don't need to send the generated .cxx and .hxx files since they are big and we can easily generate them from the schema. For this and other posting guidelines see: [2]http://www.codesynthesis.com/support/posting-guidelines.xhtml Boris References 1. mailto:maiabhmg@gmail.com 2. http://www.codesynthesis.com/support/posting-guidelines.xhtml From boris at codesynthesis.com Fri Mar 27 09:38:14 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Problems Generanting XML with Optional Tag In-Reply-To: <49CCCC2D.4020405@gmail.com> References: <49CBD11E.3000500@gmail.com> <49CCCC2D.4020405@gmail.com> Message-ID: Hi Leandro, Leandro Maia writes: > refPaiAntigo.filhos(eIdentificador::idType::filhos_optional()); A more straightforward way that achieves the same would be: refPaiAntigo.filhos().reset (); Boris From boris at codesynthesis.com Sun Mar 29 14:56:58 2009 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:34:08 2009 Subject: [xsd-users] Public XML schema that works in XJC (Java) but maybe not in CodeSynthesis XSD In-Reply-To: References: <955f8a1b0903251428q221a5b8aybf64bbfca0a554b1@mail.gmail.com> Message-ID: Cris, I did some digging and it appears the error is caused by two schemas (ansi-nist.xsd and ansi-nist_itl_constraint.xsd) that define the same set of types both being imported from different sub-schemas when loading the top-level ITL-2007f-Package.xsd schema. According to the XML Schema spec, a schema processor can treat subsequent imports with the same namespace in two ways: (1) it can ignore the subsequent imports assuming the first schema provides all the definitions for the vocabulary or (2) it can process the subsequent imported files. In the second case there are two further options regarding redefinitions: the schema processor can ignore redefinitions or it can issue an error. By default Xerces-C++ (and XSD, which is built on top of Xerces-C++) uses the first approach. The internal schema repository organization in Xerces-C++ also assumes that all subsequent imported schemas for the namespace are imported by the first schema (natural assumption since otherwise whatever is provided by schemas in the subsequent imports will be ignored). In case of ITL, we have two "parallel" schema files imported at different points in the include/import graph which breaks this assumption and as a result we get the unresolved type error. Starting with version 3.0.0, Xerces-C++ also supports the second approach, the variant with an error on redefinition. Turning on this mode doesn't help ITL since the second version of ansi-nist redefines all the types in the first. The easiest way to resolve this issue is to modify the niem-code.xsd and jxdm.xsd schemas to import ansi-nist_itl_constraint.xsd instead of ansi-nist.xsd. With this change the ITL schema can be compiled in the file-per-type mode without any problems. It is also possible to achieve the same effect without modifying the schemas. During compilation you can use the --location-map XSD compiler option to re-map ansi-nist.xsd to ansi-nist_itl_constraint.xsd. If you enable XML Schema validation during parsing, then you will also need to setup your own XML-to-DOM parsing and install a custom entity resolver which returns ansi-nist_itl_constraint.xsd instead of ansi-nist.xsd when requested by the parser. To test the generated code I created a simple round-trip driver which parses XML to object model and serializes the object model back to XML. One difference that I noticed was that a few element names were different compared to the original. It appears that the ITL schema is its use of substitution groups as some sort of application-significant IDs rather than just a way to specify the element types. For example, elements PackageUserDefinedImageRecord, PackageLantentImageRecord, etc., all substitute PackageDataRecord but are all of the same PackageImageRecordType type. During serialization the generated code uses object model types to automatically figure out which element name to use based on the substitution group information from the schemas. As a result, the generated code always uses the first element name from the above group since the object types are the same. One way to overcome this in the C++/Tree mapping is to customize the xml_schema::type class (which is the base type for all the generated classes) by adding a custom type id member (which is just the substituting element name). This type id is automatically extracted during parsing, can be queried/modified by the application, and is used during serialization to make sure the right element name is used. With this change the serialized XML is equivalent to the original. I've created a page on our Wiki for the NIST-ITL schema which contains some of the information I provided above: http://wiki.codesynthesis.com/Schemas/NIST-ITL I've also uploaded a package which contains the fixed-up NIST-ITL schemas, custom xml_schema::type implementation, the test driver, XSD option files, as well as the README which explains how to compile everything. The link is provided on the above Wiki page. Boris