From boris at codesynthesis.com Wed Nov 1 12:37:39 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Re: Loading URLs In-Reply-To: <1162351447.19732.185.camel@pbslinux01> References: <1161977731.8532.193.camel@pbslinux01> <20061030071209.GA5607@karelia> <1162329923.19732.162.camel@pbslinux01> <1162351447.19732.185.camel@pbslinux01> Message-ID: <20061101173739.GB13649@karelia> Hi Patrick, Thanks for resending this to xsd-users. Patrick Shinpaugh writes: > I was actually wrong about the root element but the site was useful. I > have it working now except for one possible issue. I was expecting to be > able to pass a url to the root instantiation loader: > > auto_ptr inst (x3d::X3D_ (argv[1], xml_schema::flags::keep_dom > | xml_schema::flags::dont_initialize, props )); > > However, it prepends the current working directory: > > ./x3d https://someserver/file.x3d > :0:0 error: An exception occurred! Type:RuntimeException, Message:The > primary document entity could not be opened. > Id=/home/patrick/projects/x3dosg/sample_implementation/code_synthesis_xsd/cxx-tree/https://someserver/file.x3d > > Any ideas what I may be doing wrong? XSD does not support HTTPS protocol in URLs (HTTP and FTP are supported if you build Xerces-C++ with network enabled). You will need to use a third- party library for HTTPS. Libcurl[1] seems like a good candidate. You can read the data using the third-party library and then present it to XSD as either std::istream or xercesc::InputSource. If the file is not very big you can also read it in as a string and then parse it using std::istringstream. [1] http://curl.haxx.se/libcurl/ hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061101/d6607f6b/attachment.pgp From Remsy.Schmilinsky at ccra-adrc.gc.ca Wed Nov 1 14:43:01 2006 From: Remsy.Schmilinsky at ccra-adrc.gc.ca (Schmilinsky, Remsy) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] constructor In-Reply-To: <20061031184946.GB10762@karelia> Message-ID: Thank you Boris, it worked. I followed your recommendation. By the way, just a minor correction: the last line of this block: // Construct contact in-place. // contacts::contact _contact ("123456", "name", "email", "888-888-888"); cr.push_back (_contact); should read: cr.contact().push_back (_contact); Remsy -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: October 31, 2006 1:50 PM To: Schmilinsky, Remsy Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] constructor Hi Remsy, Schmilinsky, Remsy writes: > > > > > > > > > > > > ...and I don't understand the generated constructors: > > queryResponse (const message::type&); This is the constructor that you would normally use to create an object from scratch. Its arguments are all required members (attributes and elements). In your case you have one required element (message) and one optional (catalog). You can read more about this constructor in Section 2.7, "Mapping for Complex Types" of the C++/Tree Mapping Manual: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.7 > queryResponse (const ::xercesc::DOMElement&, > ::xml_schema::flags = 0, > ::xml_schema::type* = 0); This is the constructor that is responsible for creating an instance from its XML representation. You would normally not use this c-tor directly though you may need to if you choose to interface with some other code that exposes its data model as Xerces-C++ DOM (e.g., the Berkeley DB XML database). > queryResponse (const queryResponse&, > ::xml_schema::flags = 0, > ::xml_schema::type* = 0); This is a copy constructor. > My test code is this: > > contacts::catalog _catalog; > contacts::contact _contact("123456", "name", "email", "888-888-888"); > _catalog.contact().push_back(_contact); > > // ERROR: inappropiate constructor > query::queryResponse myQueryResponse = query::queryResponse( > std::string("message"), _catalog); To make your code work you will need to change your last line like this: query::queryResponse myQueryResponse ("message"); myQueryResponse.catalog (_catalog); In other words you use modifier member functions to set optional members. Also note that your code is not optimal since it does quite a bit of copying which can be avoided. I would rewrite your code like this: query::queryResponse myQueryResponse ("message"); // Set to an empty container. // myQueryResponse.catalog (contacts::catalog ()); // Get a refernce to myQueryResponse's catalog container. // contacts::catalog& cr (myQueryResponse.catalog ().get ()); // Construct contact in-place. // contacts::contact _contact ("123456", "name", "email", "888-888-888"); cr.push_back (_contact); The idea is to add items to myQueryResponse's catalog in-place rather than creating them on the side and then copying to myQueryResponse. HTH, -Boris From david.fisher at lehman.com Wed Nov 1 14:42:05 2006 From: david.fisher at lehman.com (Fisher, David) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Supported environments Message-ID: <25E765EF2947214B96ACD0AD9CE9CE1E04777263@njpcmg1exms307.leh.lbcorp.lehman.com> Do you have a version of code synthesis xsd that can be used on solaris 5.8 (sparc ), Sun C++ 5.3, and xerces-c 2.7.0. Thanks. ------------------------------------------------------------------------------ This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -------- IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. From boris at codesynthesis.com Wed Nov 1 16:29:02 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Supported environments In-Reply-To: <25E765EF2947214B96ACD0AD9CE9CE1E04777263@njpcmg1exms307.leh.lbcorp.lehman.com> References: <25E765EF2947214B96ACD0AD9CE9CE1E04777263@njpcmg1exms307.leh.lbcorp.lehman.com> Message-ID: <20061101212902.GC13649@karelia> Hi David, Fisher, David writes: > Do you have a version of code synthesis xsd that can be used on solaris > 5.8 (sparc ), Sun C++ 5.3, and xerces-c 2.7.0. Thanks. Solaris 8 should work however Sun C++ 5.3 is a fairly old version which probably won't be able to compile XSD-generated code. You can give it a try by downloading the xsd-2.3.0-sparc-solaris package and trying to build examples. If it does not work you may want to consider upgrading to Sun C++ 5.8 (Studio 11) which is free (as in no fees): http://developers.sun.com/sunstudio/index.jsp This version of Sun C++ is known to work and is fully supported. Regards, -Boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061101/3d92fc18/attachment.pgp From shpatric at vt.edu Thu Nov 2 09:51:24 2006 From: shpatric at vt.edu (Patrick Shinpaugh) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Re: Loading URLs In-Reply-To: <20061101173739.GB13649@karelia> References: <1161977731.8532.193.camel@pbslinux01> <20061030071209.GA5607@karelia> <1162329923.19732.162.camel@pbslinux01> <1162351447.19732.185.camel@pbslinux01> <20061101173739.GB13649@karelia> Message-ID: <1162479084.19732.408.camel@pbslinux01> Hi Boris, Thanks for the heads up about lack of https support - I guess I assumed Xerces would support it being an Apache project. The libcurl solution should be good and easy to implement. Unfortunately I have run into another problem which I cannot be sure is XSD specific. Basically I am traversing the DOMNodes using a recursive function and as a test if the node is a x3d::Transform then grab it and print out the info accessed directly from the Transform xsd-generated class and compare it to the data printed directly from the DOMNodes. So as I traverse the nodes, everything works great - I am able to grab the data from the first Transform - until I reach the second Transform and attempt to print its info. The data output is indented for the DOMNode output and not indented for the Transform direct access. ... ... Transform bboxCenter 0 0 0 bboxSize -1 -1 -1 center 0 0 0 containerField children rotation 0 0 1 0 scale 0.875 0.875 0.875 scaleOrientation 0 0 1 0 translation 0 3 0 Transform containerField: children bboxCenter: 0 0 0 bboxSize: -1 -1 -1 center: 0 0 0 rotation: 0 0 1 0 scale: 0.875 0.875 0.875 scaleOrientation: 0 0 1 0 translation: 0 3 0 LOD bboxCenter 0 0 0 bboxSize -1 -1 -1 center 0 0 0 containerField children range 200 2000 20000 Transform bboxCenter 0 0 0 bboxSize -1 -1 -1 center 0 0 0 containerField children rotation 0 1 0 1.57 scale 0.45 0.45 0.45 scaleOrientation 0 0 1 0 translation 0 0 0 Segmentation fault (core dumped) Unfortunately, it segfaults with gdb backtrace: (gdb) bt #0 0x054fdc70 in __dynamic_cast () at /usr/local/xsd/libxsd/xsd/cxx/tree/types.hxx:1214 #1 0x0804b4eb in printX3DNodeData (current=0x9c62058) at driver.cxx:28 #2 0x0804b8fa in getChildren (current=0x9c61820, indent=6) at driver.cxx:76 #3 0x0804b780 in getChildren (current=0x9c609c8, indent=4) at driver.cxx:97 #4 0x0804b780 in getChildren (current=0x9c99ea8, indent=2) at driver.cxx:97 #5 0x0804b780 in getChildren (current=0x9c98200, indent=0) at driver.cxx:97 #6 0x0804bbb7 in main (argc=0, argv=0x0) at driver.cxx:148 The code in question looks like this: int printX3DNodeData( DOMNode* current ) { xml_schema::type& t ( *reinterpret_cast ( current->getUserData (xml_ schema::tree_node_key))); x3d::Transform& current_transform (dynamic_cast (t)); cout << "Transform" << endl; cout << "containerField: " << current_transform.containerField() << endl; cout << "bboxCenter: " << current_transform.bboxCenter() << endl; cout << "bboxSize: " << current_transform.bboxSize() << endl; cout << "center: " << current_transform.center() << endl; cout << "rotation: " << current_transform.rotation() << endl; cout << "scale: " << current_transform.scale() << endl; cout << "scaleOrientation: " << current_transform.scaleOrientation() << endl; cout << "translation: " << current_transform.translation() << endl; } int getChildren( DOMNode* current, int indent = 0 ) { try { for( DOMNode* cur = current->getFirstChild(); cur != 0; cur = cur->getNextSibling() ) { for( int i=0;igetNodeName() ) << endl; switch( cur->getNodeType() ) { case DOMNode::ELEMENT_NODE: { if( cur->hasAttributes() ) { DOMNamedNodeMap* attributes = cur->getAttributes(); if( attributes ) { for( int i=0;igetLength();i++ ) { for( int j=0;jitem(i); cout << XMLString::transcode( attr->getNodeName() ); if( attr->getNodeValue() ) { cout << " " << XMLString::transcode( attr->getNodeValue() ) << endl; } } } } if( XMLString::transcode( cur->getNodeName() ) == std::string( "Transform" ) ) { if( cur->hasAttributes() ) { printX3DNodeData( cur ); } } break; } case DOMNode::ATTRIBUTE_NODE: case DOMNode::TEXT_NODE: case DOMNode::CDATA_SECTION_NODE: case DOMNode::ENTITY_REFERENCE_NODE: case DOMNode::ENTITY_NODE: case DOMNode::PROCESSING_INSTRUCTION_NODE: case DOMNode::COMMENT_NODE: case DOMNode::DOCUMENT_NODE: case DOMNode::DOCUMENT_TYPE_NODE: case DOMNode::DOCUMENT_FRAGMENT_NODE: case DOMNode::NOTATION_NODE : default: break; } cout << endl; if( cur->hasChildNodes() ) getChildren( cur, indent + 2 ); } } catch (const xml_schema::exception& e) { cerr << "HELP ME " << e << endl; return 1; } } Because the error is within /usr/local/xsd/libxsd/xsd/cxx/tree/types.hxx I figured I'd contact you about it first though at the same time I am wondering if it might be an issue with gcc or perhaps with my code. Any help or advice would be greatly appreciated. Thanks for your help in the past and in advance. Pat On Wed, 2006-11-01 at 19:37 +0200, Boris Kolpackov wrote: > Hi Patrick, > > Thanks for resending this to xsd-users. > > Patrick Shinpaugh writes: > > > I was actually wrong about the root element but the site was useful. I > > have it working now except for one possible issue. I was expecting to be > > able to pass a url to the root instantiation loader: > > > > auto_ptr inst (x3d::X3D_ (argv[1], xml_schema::flags::keep_dom > > | xml_schema::flags::dont_initialize, props )); > > > > However, it prepends the current working directory: > > > > ./x3d https://someserver/file.x3d > > :0:0 error: An exception occurred! Type:RuntimeException, Message:The > > primary document entity could not be opened. > > Id=/home/patrick/projects/x3dosg/sample_implementation/code_synthesis_xsd/cxx-tree/https://someserver/file.x3d > > > > Any ideas what I may be doing wrong? > > XSD does not support HTTPS protocol in URLs (HTTP and FTP are supported if > you build Xerces-C++ with network enabled). You will need to use a third- > party library for HTTPS. Libcurl[1] seems like a good candidate. > > You can read the data using the third-party library and then present it > to XSD as either std::istream or xercesc::InputSource. If the file is > not very big you can also read it in as a string and then parse it using > std::istringstream. > > > [1] http://curl.haxx.se/libcurl/ > > > hth, > -boris -- Patrick Shinpaugh Virginia Tech UVAG System Administrator/Programmer 540-231-2054 From boris at codesynthesis.com Thu Nov 2 10:27:35 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Re: Loading URLs In-Reply-To: <1162479084.19732.408.camel@pbslinux01> References: <1161977731.8532.193.camel@pbslinux01> <20061030071209.GA5607@karelia> <1162329923.19732.162.camel@pbslinux01> <1162351447.19732.185.camel@pbslinux01> <20061101173739.GB13649@karelia> <1162479084.19732.408.camel@pbslinux01> Message-ID: <20061102152735.GB18600@karelia> Hi Patrick, Patrick Shinpaugh writes: > Unfortunately I have run into another problem which I cannot be sure is > XSD specific. Basically I am traversing the DOMNodes using a recursive > function and as a test if the node is a x3d::Transform then grab it and > print out the info accessed directly from the Transform xsd-generated > class and compare it to the data printed directly from the DOMNodes. So > as I traverse the nodes, everything works great - I am able to grab the > data from the first Transform - until I reach the second Transform and > attempt to print its info. > > [...] > > Unfortunately, it segfaults with gdb backtrace: > > (gdb) bt > #0 0x054fdc70 in __dynamic_cast () > at /usr/local/xsd/libxsd/xsd/cxx/tree/types.hxx:1214 > > [...] > > Because the error is within /usr/local/xsd/libxsd/xsd/cxx/tree/types.hxx > I figured I'd contact you about it first I check the code around line 1214 in types.hxx and there is nothing that calls dynamic_cast. This could mean one of the two things: 1. You are compiling with optimization and the debug info does not correspond to the code. 2. We are looking at different versions of XSD. I checked 2.3.1.a1 and 2.3.1.b1. > though at the same time I am wondering if it might be an issue with gcc > or perhaps with my code. I could not spot anything in your code. Would it possible for you to send a complete but minimal test case that reproduces this problem? I might then be able to debug it further. thanks, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061102/5b7b726b/attachment.pgp From shpatric at vt.edu Thu Nov 2 11:20:41 2006 From: shpatric at vt.edu (Patrick Shinpaugh) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Re: Loading URLs In-Reply-To: <20061102152735.GB18600@karelia> References: <1161977731.8532.193.camel@pbslinux01> <20061030071209.GA5607@karelia> <1162329923.19732.162.camel@pbslinux01> <1162351447.19732.185.camel@pbslinux01> <20061101173739.GB13649@karelia> <1162479084.19732.408.camel@pbslinux01> <20061102152735.GB18600@karelia> Message-ID: <1162484441.19732.428.camel@pbslinux01> Hi Boris, See below. On Thu, 2006-11-02 at 17:27 +0200, Boris Kolpackov wrote: > Hi Patrick, > > Patrick Shinpaugh writes: > > > Unfortunately I have run into another problem which I cannot be sure is > > XSD specific. Basically I am traversing the DOMNodes using a recursive > > function and as a test if the node is a x3d::Transform then grab it and > > print out the info accessed directly from the Transform xsd-generated > > class and compare it to the data printed directly from the DOMNodes. So > > as I traverse the nodes, everything works great - I am able to grab the > > data from the first Transform - until I reach the second Transform and > > attempt to print its info. > > > > [...] > > > > Unfortunately, it segfaults with gdb backtrace: > > > > (gdb) bt > > #0 0x054fdc70 in __dynamic_cast () > > at /usr/local/xsd/libxsd/xsd/cxx/tree/types.hxx:1214 > > > > [...] > > > > Because the error is within /usr/local/xsd/libxsd/xsd/cxx/tree/types.hxx > > I figured I'd contact you about it first > > I check the code around line 1214 in types.hxx and there is nothing that > calls dynamic_cast. This could mean one of the two things: > > 1. You are compiling with optimization and the debug info does not > correspond to the code. > I compile my code with -O2 -g as follows: gcc -O2 -g -I /usr/local/xsd/libxsd driver.cxx -c gcc -O2 -g -I /usr/local/xsd/libxsd x3d-3.0.cxx -c gcc -O2 -g -I /usr/local/xsd/libxsd x3d-3.0-Web3dExtensionsPrivate.cxx -c gcc -O2 -g -I /usr/local/xsd/libxsd x3d-3.0-Web3dExtensionsPublic.cxx -c gcc -O2 -g -lstdc++ -lxerces-c driver.o x3d-3.0.o x3d-3.0-Web3dExtensionsPrivate.o x3d-3.0-Web3dExtensionsPublic.o -o x3d > 2. We are looking at different versions of XSD. I checked 2.3.1.a1 and > 2.3.1.b1. > I am using the prebuilt binaries 2.3.1.a1 > > > though at the same time I am wondering if it might be an issue with gcc > > or perhaps with my code. > > I could not spot anything in your code. Would it possible for you to send > a complete but minimal test case that reproduces this problem? I might > then be able to debug it further. > I'll see what I can do and send a tarball sometime later today. > > thanks, > -boris Thanks -- Patrick Shinpaugh Virginia Tech UVAG System Administrator/Programmer 540-231-2054 From Remsy.Schmilinsky at ccra-adrc.gc.ca Thu Nov 2 16:49:07 2006 From: Remsy.Schmilinsky at ccra-adrc.gc.ca (Schmilinsky, Remsy) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] assign enumeration to string In-Reply-To: <20061031184946.GB10762@karelia> Message-ID: Perhaps this is rather a question for a C++ forum, but I wonder if you can help me put the value of a generated enumeration value in a string, for instance, a section from my schema is this: How can I assign the generated value corresponding to an xsd::enumeration to a std::string variable? I try to do this in my test file: // Parse the tree std::auto_ptr s(service::request_(file, 0, queryProps)); std::string requestType = s->requestType(); of course I get the error: test.cpp:37: error: conversion from `xsd::cxx::tree::optional' to non-scalar type `std::basic_st ring, std::allocator >' requested tnx Remsy From shpatric at vt.edu Thu Nov 2 18:01:48 2006 From: shpatric at vt.edu (Patrick Shinpaugh) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Re: Loading URLs In-Reply-To: <20061102152735.GB18600@karelia> References: <1161977731.8532.193.camel@pbslinux01> <20061030071209.GA5607@karelia> <1162329923.19732.162.camel@pbslinux01> <1162351447.19732.185.camel@pbslinux01> <20061101173739.GB13649@karelia> <1162479084.19732.408.camel@pbslinux01> <20061102152735.GB18600@karelia> Message-ID: <1162508508.19732.467.camel@pbslinux01> Hi Boris, Unfortunately I wasn't able to create a simple case which would match the complexity of the x3d schema. What I did was remove the majority of the unused elements and types from the x3d schema. I hope this is ok - if not let me know and I will try to create something more to your liking. Included is a tarball (bzip2) containing README, Makefile, driver.cxx, x3d-3.0.xsd (reduced), and test.x3d. Let me know if you need anything else. Thanks, Pat On Thu, 2006-11-02 at 17:27 +0200, Boris Kolpackov wrote: > Hi Patrick, > > Patrick Shinpaugh writes: > > > Unfortunately I have run into another problem which I cannot be sure is > > XSD specific. Basically I am traversing the DOMNodes using a recursive > > function and as a test if the node is a x3d::Transform then grab it and > > print out the info accessed directly from the Transform xsd-generated > > class and compare it to the data printed directly from the DOMNodes. So > > as I traverse the nodes, everything works great - I am able to grab the > > data from the first Transform - until I reach the second Transform and > > attempt to print its info. > > > > [...] > > > > Unfortunately, it segfaults with gdb backtrace: > > > > (gdb) bt > > #0 0x054fdc70 in __dynamic_cast () > > at /usr/local/xsd/libxsd/xsd/cxx/tree/types.hxx:1214 > > > > [...] > > > > Because the error is within /usr/local/xsd/libxsd/xsd/cxx/tree/types.hxx > > I figured I'd contact you about it first > > I check the code around line 1214 in types.hxx and there is nothing that > calls dynamic_cast. This could mean one of the two things: > > 1. You are compiling with optimization and the debug info does not > correspond to the code. > > 2. We are looking at different versions of XSD. I checked 2.3.1.a1 and > 2.3.1.b1. > > > > though at the same time I am wondering if it might be an issue with gcc > > or perhaps with my code. > > I could not spot anything in your code. Would it possible for you to send > a complete but minimal test case that reproduces this problem? I might > then be able to debug it further. > > > thanks, > -boris -- Patrick Shinpaugh Virginia Tech UVAG System Administrator/Programmer 540-231-2054 -------------- next part -------------- A non-text attachment was scrubbed... Name: testcase-x3d-3.0.tar.bz2 Type: application/x-bzip-compressed-tar Size: 12813 bytes Desc: not available Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061102/37ce0c68/testcase-x3d-3.0.tar.bin From MEL at DISC.com Thu Nov 2 20:22:22 2006 From: MEL at DISC.com (Mark Lofdahl) Date: Sun Oct 11 15:33:50 2009 Subject: CXX-DEV: (forw) [xsd-users] hpux 11.11 basic_string abort Message-ID: Apparently we were linking with Oracle, which is not single-threaded. Since we could not remove that link (we have to use Oracle), we changed our compiles/links to do everything multi-threaded, and it fixed the problem. Thanks to both Boris and Dennis for your help! Mark mel@disc.com -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, October 31, 2006 4:04 AM To: Mark Lofdahl Cc: xsd-users@codesynthesis.com Subject: Re: CXX-DEV: (forw) [xsd-users] hpux 11.11 basic_string abort Hi Mark, Were you able to resolve your problem based in Dennis' feedback? It seems like you need to find out who links in libpthread and get rid of that. Please let us know how it all works out. Regards, -Boris From boris at codesynthesis.com Fri Nov 3 01:05:21 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] assign enumeration to string In-Reply-To: References: <20061031184946.GB10762@karelia> Message-ID: <20061103060521.GA22826@karelia> Hi Remsy, Schmilinsky, Remsy writes: > How can I assign the generated value corresponding to an > xsd::enumeration to a std::string variable? > > I try to do this in my test file: > > // Parse the tree > std::auto_ptr s(service::request_(file, 0, > queryProps)); > std::string requestType = s->requestType(); > > of course I get the error: > > test.cpp:37: error: conversion from > `xsd::cxx::tree::optional' to non-scalar > type `std::basic_st > ring, std::allocator >' requested From the error message above I can see that you are using the container instead of a value (notice how the error says that it cannot convert xsd::cxx::tree::optional<...> to std::string instead of service::requestType to std::string). If you change your last line to be: if (s->requestType().present ()) { std::string requestType = s->requestType().get (); ) then it will work. hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061103/744c8e22/attachment.pgp From boris at codesynthesis.com Fri Nov 3 02:57:18 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Re: Loading URLs In-Reply-To: <1162508508.19732.467.camel@pbslinux01> References: <1161977731.8532.193.camel@pbslinux01> <20061030071209.GA5607@karelia> <1162329923.19732.162.camel@pbslinux01> <1162351447.19732.185.camel@pbslinux01> <20061101173739.GB13649@karelia> <1162479084.19732.408.camel@pbslinux01> <20061102152735.GB18600@karelia> <1162508508.19732.467.camel@pbslinux01> Message-ID: <20061103075718.GC22826@karelia> Hi Patrick, Patrick Shinpaugh writes: > Unfortunately I wasn't able to create a simple case which would match > the complexity of the x3d schema. What I did was remove the majority of > the unused elements and types from the x3d schema. I hope this is ok - > if not let me know and I will try to create something more to your > liking. The test was perfect, thanks very much. The test crashes due to a bug in the DOM association handling code. It's been already reported by one of our clients and it is fixed in the first beta of 2.3.1. I suggest that you upgrade to 2.3.1.b1, which you can get here: http://www.codesynthesis.com/products/xsd/download.xhtml hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061103/4fa9a90e/attachment.pgp From mattis at sonic.net Tue Nov 7 22:14:07 2006 From: mattis at sonic.net (Mattis Fjallstrom) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Mpeg-7 schema support? Problem: Message-ID: <14058.192.26.91.227.1162955647.squirrel@webmail.sonic.net> Hi all, I've browsed the mailing list archives looking for a similar problem to mine, but I've come up empty handed. So I write to see if someone on the list has got a clue... I have several documents in Mpeg-7 format that I would like to be able to parse and perform data binding on. I'd like to create C++ objects based on the schema for Mpeg-7 (found here: http://m7itb.nist.gov/M7Validation.html), then marshall the Mpeg-7 data-files into C++ objects. I've done similar things in Java before, using Castor. However, I stumble on the very first step. --- bash:~/downloads/Mpeg-7 Schema Files$ xsd cxx-tree Mpeg7-2001.xsd :0:0: error: Complex type 'ShotEditingTemporalDecompositionType' violates the Unique Particle Attribution rule in its components 'CompositionTransition' and 'CompositionTransition' --- So ... two questions, I guess - has anyone made XSD parse Mpeg-7 schemas? And second, does anyone know what this error really means? Thanks in advance, Mattis From boris at codesynthesis.com Wed Nov 8 06:27:33 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Mpeg-7 schema support? Problem: In-Reply-To: <14058.192.26.91.227.1162955647.squirrel@webmail.sonic.net> References: <14058.192.26.91.227.1162955647.squirrel@webmail.sonic.net> Message-ID: <20061108112733.GD21413@kolpackov.net> Hi Mattis, On Tue, Nov 07, 2006 at 07:14:07PM -0800, Mattis Fjallstrom wrote: > bash:~/downloads/Mpeg-7 Schema Files$ xsd cxx-tree Mpeg7-2001.xsd > :0:0: error: Complex type 'ShotEditingTemporalDecompositionType' violates > the Unique Particle Attribution rule in its components > 'CompositionTransition' and 'CompositionTransition' > > --- > > So ... two questions, I guess - has anyone made XSD parse Mpeg-7 schemas? > And second, does anyone know what this error really means? The error says that the schema violates the Unique Particle Attribution rule (UPA for short). The UPA rule requires that there is only one way to associate, e.g., an element in an XML instance to an element declaration in a schema. For instance, consider the following XML Schema fragment: And this instance: foo bar Here the parser can associate both elements to the second declaration in the schema or it can associate the first element to the first declaration (the one with minOccurs="0") and the second element to the second declaration. Thus this schema violates the UPA rule. I won't be able to try your schema with XSD until Monday. I will let you know about my results. hth, -boris From mattis at acm.org Wed Nov 8 06:35:49 2006 From: mattis at acm.org (Mattis Fjallstrom) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Mpeg-7 schema support? Problem: In-Reply-To: <20061108112733.GD21413@kolpackov.net> References: <14058.192.26.91.227.1162955647.squirrel@webmail.sonic.net> <20061108112733.GD21413@kolpackov.net> Message-ID: <4551C115.3000203@acm.org> Hi Boris, Thank you. I understand the problem much better now. I'm still surprised that the mpeg-7 schema would have a problem like this ... it is supposed to be some sort of standard, after all. :-) I'll see if I can find an email address to ask an expert on mpeg-7 as well. If I find something, I'll let you know. Cheers, Mattis Boris Kolpackov wrote: > Hi Mattis, > > On Tue, Nov 07, 2006 at 07:14:07PM -0800, Mattis Fjallstrom wrote: > >> bash:~/downloads/Mpeg-7 Schema Files$ xsd cxx-tree Mpeg7-2001.xsd >> :0:0: error: Complex type 'ShotEditingTemporalDecompositionType' violates >> the Unique Particle Attribution rule in its components >> 'CompositionTransition' and 'CompositionTransition' >> >> --- >> >> So ... two questions, I guess - has anyone made XSD parse Mpeg-7 schemas? >> And second, does anyone know what this error really means? > > The error says that the schema violates the Unique Particle Attribution > rule (UPA for short). The UPA rule requires that there is only one way > to associate, e.g., an element in an XML instance to an element > declaration in a schema. For instance, consider the following XML Schema > fragment: > > > > > > > And this instance: > > foo > bar > > Here the parser can associate both elements to the second declaration > in the schema or it can associate the first element to the first > declaration (the one with minOccurs="0") and the second element to the > second declaration. Thus this schema violates the UPA rule. > > I won't be able to try your schema with XSD until Monday. I will let you > know about my results. > > hth, > -boris > > From abu.marcose at gmail.com Wed Nov 8 15:52:29 2006 From: abu.marcose at gmail.com (Abu Marcose) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Looking for an AIX port of xsd Message-ID: <471f96130611081252qb8c95b8oc19858e3a60c7f3e@mail.gmail.com> Looking for a port of xsd on AIX 5.2 using xlC v6 compiler.. Thanks, Abu. From boris at codesynthesis.com Mon Nov 13 03:24:57 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Looking for an AIX port of xsd In-Reply-To: <471f96130611081252qb8c95b8oc19858e3a60c7f3e@mail.gmail.com> References: <471f96130611081252qb8c95b8oc19858e3a60c7f3e@mail.gmail.com> Message-ID: <20061113082457.GE5324@karelia> Hi Abu, Abu Marcose writes: > Looking for a port of xsd on AIX 5.2 using xlC v6 compiler.. We are working on building the AIX binary of XSD. Meantime you can compile your schemas on a different box (e.g., GNU/Linux or Windows) and copy them to AIX since the generated code is platform-independent. I will let you know when the AIX binary is ready. HTH, -Boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061113/fb792407/attachment.pgp From boris at codesynthesis.com Mon Nov 13 11:11:41 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Mpeg-7 schema support? Problem: In-Reply-To: <4551C115.3000203@acm.org> References: <14058.192.26.91.227.1162955647.squirrel@webmail.sonic.net> <20061108112733.GD21413@kolpackov.net> <4551C115.3000203@acm.org> Message-ID: <20061113161141.GA6805@karelia> Hi Mattis, Mattis Fjallstrom writes: > Thank you. I understand the problem much better now. I'm still surprised > that the mpeg-7 schema would have a problem like this ... it is supposed > to be some sort of standard, after all. :-) I'll see if I can find an > email address to ask an expert on mpeg-7 as well. If I find something, > I'll let you know. I finally got around to checking the mpeg-7 schemas and it seems they indeed violate the UPA rule. Consider this fragment from mds-2001.xsd, line 3999: In particular the last sequence and choice. When parser sees a CompositionTransition element it does not know (without looking ahead) which branch it happens to belong (sequence of choice). It is interesting to note that quite a few XML Schema processors report that this schema is valid. In particular I tried Xerces-J, Jing, and MSV from this service: http://www.mel.nist.gov/msid/validation/ All three of them reported that the schema is valid. I was wondering how they were going to handle an instance for such a schema so I created a small test schema that reproduces the questionable structure found in the mpeg-7 schemas: And a test XML instance document: a Again, the above three processors all reported that the schema is valid. However, when I tried to validate the instance against the schema all of them failed saying that the instance is not valid (all of them assumed the first branch and expected to see CompositionShot or CompositionShotRef elements). Strangely enough, after reporting that the instance is not valid, Jing also reported that the schema violates the UPA rule: ~/test.xsd:4:58: error: cos-nonambig: "":CompositionTransition and "":CompositionTransition (or elements from their substitution group) violate "Unique Particle Attribution". hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061113/84447f8f/attachment.pgp From mattis at acm.org Mon Nov 13 18:59:24 2006 From: mattis at acm.org (Mattis Fjallstrom) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Mpeg-7 schema support? Problem: In-Reply-To: <20061113161141.GA6805@karelia> References: <14058.192.26.91.227.1162955647.squirrel@webmail.sonic.net> <20061108112733.GD21413@kolpackov.net> <4551C115.3000203@acm.org> <20061113161141.GA6805@karelia> Message-ID: <455906DC.7030207@acm.org> Hi Boris, Thank you very much. This is very interesting - the code I am dealing with is currently using Xerces, as a SAX parser, and that works. For our application, however, SAX is a poor choice. I'd like to switch to a data binding model of some sort ... that's why I wanted to use xsd. I will see if I can find someone on the mpeg-7 side of things and inform them of this. They might want to know. Again, thank you so much for your time. I really appreciate it. Cheers, Mattis Boris Kolpackov wrote: > Hi Mattis, > > > Mattis Fjallstrom writes: > >> Thank you. I understand the problem much better now. I'm still surprised >> that the mpeg-7 schema would have a problem like this ... it is supposed >> to be some sort of standard, after all. :-) I'll see if I can find an >> email address to ask an expert on mpeg-7 as well. If I find something, >> I'll let you know. > > I finally got around to checking the mpeg-7 schemas and it seems they > indeed violate the UPA rule. Consider this fragment from mds-2001.xsd, > line 3999: > > > > > > > > > > > > > > > > > > > > > > > In particular the last sequence and choice. When parser sees a > CompositionTransition element it does not know (without looking ahead) > which branch it happens to belong (sequence of choice). > > It is interesting to note that quite a few XML Schema processors report > that this schema is valid. In particular I tried Xerces-J, Jing, and MSV > from this service: > > http://www.mel.nist.gov/msid/validation/ > > All three of them reported that the schema is valid. I was wondering how > they were going to handle an instance for such a schema so I created a > small test schema that reproduces the questionable structure found in > the mpeg-7 schemas: > > > xmlns:t="test" > targetNamespace="test"> > > > > > > > > > > > > > > > > > > > > > > > > > And a test XML instance document: > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="test test.xsd"> > > a > > > > Again, the above three processors all reported that the schema is valid. > However, when I tried to validate the instance against the schema all of > them failed saying that the instance is not valid (all of them assumed > the first branch and expected to see CompositionShot or CompositionShotRef > elements). Strangely enough, after reporting that the instance is not > valid, Jing also reported that the schema violates the UPA rule: > > ~/test.xsd:4:58: error: cos-nonambig: "":CompositionTransition and > "":CompositionTransition (or elements from their substitution group) > violate "Unique Particle Attribution". > > > hth, > -boris From uchida.hitoshi at canon.co.jp Tue Nov 14 01:42:06 2006 From: uchida.hitoshi at canon.co.jp (UCHIDA Hitoshi) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] constraint of expat using Message-ID: <20061114152747.B576.UCHIDA.HITOSHI@canon.co.jp> Dear all, I have searched the mailing list archives, but I couldn't find a similar question. Are there function constraints if Expat as the underlying XML parser is used ? -- Best regards, Hitoshi Uchida From boris at codesynthesis.com Tue Nov 14 03:38:47 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] constraint of expat using In-Reply-To: <20061114152747.B576.UCHIDA.HITOSHI@canon.co.jp> References: <20061114152747.B576.UCHIDA.HITOSHI@canon.co.jp> Message-ID: <20061114083847.GC8461@karelia> Hi, UCHIDA Hitoshi writes: > Are there function constraints > if Expat as the underlying XML parser is used ? At the moment Expat can only be used as an underlying parser for the C++/Parser mapping. There is no difference between Xerces-C++ and Expat from the C++/Parser mapping point of view. Which constraints in particular you are looking into? hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061114/328637ce/attachment.pgp From uchida.hitoshi at canon.co.jp Tue Nov 14 04:43:22 2006 From: uchida.hitoshi at canon.co.jp (UCHIDA Hitoshi) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] constraint of expat using In-Reply-To: <20061114083847.GC8461@karelia> References: <20061114152747.B576.UCHIDA.HITOSHI@canon.co.jp> <20061114083847.GC8461@karelia> Message-ID: <20061114180352.B579.UCHIDA.HITOSHI@canon.co.jp> Dear Boris, Thank you for your quick reply. > > Are there function constraints > > if Expat as the underlying XML parser is used ? > > At the moment Expat can only be used as an underlying parser for the > C++/Parser mapping. There is no difference between Xerces-C++ and > Expat from the C++/Parser mapping point of view. Which constraints > in particular you are looking into? I'm looking into the XSD function constraint in using Expat as a parser compared with using Xerces-C++ . Can Expat be used for C++/Tree mapping in future ? -- Hitoshi Uchida From boris at codesynthesis.com Tue Nov 14 05:03:24 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] constraint of expat using In-Reply-To: <20061114180352.B579.UCHIDA.HITOSHI@canon.co.jp> References: <20061114152747.B576.UCHIDA.HITOSHI@canon.co.jp> <20061114083847.GC8461@karelia> <20061114180352.B579.UCHIDA.HITOSHI@canon.co.jp> Message-ID: <20061114100324.GD8461@karelia> Hi, UCHIDA Hitoshi writes: > I'm looking into the XSD function constraint in using Expat as a parser > compared with using Xerces-C++ . > Can Expat be used for C++/Tree mapping in future ? Most likely it won't be the existing C++/Tree mapping but a new hybrid mapping which will combine the functionality of both the C++/Tree and C++/Parser mappings and allow you to choose to which degree you want to be event-driven vs in-memory. What are the reasons that make you prefer Expat over Xerces-C++? hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061114/911c9d42/attachment.pgp From uchida.hitoshi at canon.co.jp Tue Nov 14 20:10:54 2006 From: uchida.hitoshi at canon.co.jp (UCHIDA Hitoshi) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] constraint of expat using In-Reply-To: <20061114100324.GD8461@karelia> References: <20061114180352.B579.UCHIDA.HITOSHI@canon.co.jp> <20061114100324.GD8461@karelia> Message-ID: <20061115093413.5A5E.UCHIDA.HITOSHI@canon.co.jp> Hi, > What are the reasons that make you prefer Expat over Xerces-C++? I care about the library size and the parsing speed though I'm mainly looking into the various posibilities of XSD. -- Best regards, Hitoshi Uchida From harish_tak at yahoo.com Tue Nov 14 17:23:31 2006 From: harish_tak at yahoo.com (Harish Prasad) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] automating xsd build from source Message-ID: <20061114222331.91152.qmail@web33103.mail.mud.yahoo.com> Hi All, I downloaded XSD and it's prerequisites packages on my Linux machine and followed the build document for Unix provided on codesynthesis website. Does anybody have automated way of doing entire xsd build including installation of prerequisites packages ? Installation of libcult, libfrontend etc. are interactive, it asks for lots of questions like below. Please select the C++ compiler you would like to use: (1) GNU C++ (g++) (2) Intel C++ (icc) [1]: 1 Would you like the C++ compiler to optimize generated code? [y]: n Would you like the C++ compiler to generate debug information? [y]: n Please enter any extra C++ preprocessor options. []: Please enter any extra C++ compiler options. []: Please enter any extra C++ linker options. []: Please enter any extra C++ libraries. []: Would you like to build a multi-threaded version of 'libcult'? [y]: n Would you like to build the network subsystem of 'libcult'? [y]: n Would you like to build the data representation subsystem of 'libcult'? [y]: n Please select the default library type: (1) archive (2) shared object [2]: 2 Please enter the g++ binary you would like to use, for example 'g++-3.4', '/usr/local/bin/g++' or 'distcc g++'. [g++]: g++ Appreciate your expert comments. Regards, Harish From Gidis at radcom.com Wed Nov 15 04:18:50 2006 From: Gidis at radcom.com (Gidi Sidis) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] urgent problem - impelmenting polymorphism Message-ID: <72E31CBDD28B29418986A01998EAC72D01B256BA@rad-w2ksrv11.radcom.co.il> Dear Support, I am trying to implement a polymorphic program (schema) which by structure resembles the polymorphism project you have published under examples in xsd-2.3.0-i686-windows package. I encountered some problems so I decided to investigate the polymorphism project. When I ran the project as you published, with already built schema.cxx and schema.hxx files than the program worked and printed: John Doe James "007" Bond, superman Bruce Wayne, flying superman However, when I replaced the existing schema.cxx and schema.hxx files with new schema.cxx and schema.hxx that were generated via executing the command: xsd cxx-tree schema.xsd with the same schema.xsd file you published, the program ran and printed: John Doe The person container in the main function in driver.cxx held only the person element and not the derived elements. Comparing the old and new schema.cxx and schema.hxx files reviled that they were not identical and had some different code sections. Can you advise me? Perhaps I need to perform some other build/execute actions? I will appreciate if you could get back to me as soon as possible, since I have to implement such a polymorphic program. Best regards, Gidi Sidis, p.s. I am running on windows XP operating system, using Visual Studio.Net 2003 editor. From boris at codesynthesis.com Wed Nov 15 10:26:20 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] urgent problem - impelmenting polymorphism In-Reply-To: <72E31CBDD28B29418986A01998EAC72D01B256BA@rad-w2ksrv11.radcom.co.il> References: <72E31CBDD28B29418986A01998EAC72D01B256BA@rad-w2ksrv11.radcom.co.il> Message-ID: <20061115152620.GA11536@karelia> Hi Gidi, Gidi Sidis writes: > When I ran the project as you published, with already built schema.cxx > and schema.hxx files than the program worked and printed: > > > > John Doe > > James "007" Bond, superman > > Bruce Wayne, flying superman > > > > However, when I replaced the existing schema.cxx and schema.hxx files > with new schema.cxx and schema.hxx that were generated via executing the > command: > > xsd cxx-tree schema.xsd If your schemas use polymorphism (substitution groups and/or xsi:type dynamic typing) then you need to compile them with the --generate-polymorphic option: xsd cxx-tree --generate-polymorphic schema.xsd hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061115/f6cf299c/attachment.pgp From Remsy.Schmilinsky at ccra-adrc.gc.ca Wed Nov 15 14:56:12 2006 From: Remsy.Schmilinsky at ccra-adrc.gc.ca (Schmilinsky, Remsy) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] construct object from iterator In-Reply-To: <20061103060521.GA22826@karelia> Message-ID: Hi. From the library example: for (catalog::book::const_iterator bi (c->book ().begin ()); bi != c->book ().end (); ++bi) I want to save each book in dbxml as a separate document instead of the whole catalog. can I convert iterator bi to catalog::book object and then use it to save a document in dbxml? I am following the dbxml example, it shows how to save the catalog as a document instead of a document for each book. thanks, Remsy -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: November 3, 2006 1:05 AM To: Schmilinsky, Remsy Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] assign enumeration to string Hi Remsy, Schmilinsky, Remsy writes: > How can I assign the generated value corresponding to an > xsd::enumeration to a std::string variable? > > I try to do this in my test file: > > // Parse the tree > std::auto_ptr s(service::request_(file, 0, > queryProps)); > std::string requestType = s->requestType(); > > of course I get the error: > > test.cpp:37: error: conversion from > `xsd::cxx::tree::optional' to non-scalar > type `std::basic_st > ring, std::allocator >' requested >From the error message above I can see that you are using the container instead of a value (notice how the error says that it cannot convert xsd::cxx::tree::optional<...> to std::string instead of service::requestType to std::string). If you change your last line to be: if (s->requestType().present ()) { std::string requestType = s->requestType().get (); ) then it will work. hth, -boris From boris at codesynthesis.com Wed Nov 15 23:21:02 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] constraint of expat using In-Reply-To: <20061115093413.5A5E.UCHIDA.HITOSHI@canon.co.jp> References: <20061114180352.B579.UCHIDA.HITOSHI@canon.co.jp> <20061114100324.GD8461@karelia> <20061115093413.5A5E.UCHIDA.HITOSHI@canon.co.jp> Message-ID: <20061116042102.GA13570@karelia> Hi, UCHIDA Hitoshi writes: > > What are the reasons that make you prefer Expat over Xerces-C++? > > I care about the library size and the parsing speed > though I'm mainly looking into the various posibilities of XSD. It is true that Expat is a smaller (footprint-wise) and faster XML parser. At the same time Expat is a fairly minimal parser supporting only SAX and a handful of character encodings while Xerces-C++ is probably the most comprehensive XML parser for C++ there is. Here are some of the features that you can find in Xerces-C++ but not in Expat: - Supports for DOM - Supports for DTD and XML Schema validation - Supports for a large number of character encodings both internally and via external Unicode libraries - Support for network access The C++/Tree mapping is designed to work from DOM and provides tight integration with the Xerces-C++ DOM at certain points (e.g., the ability to associate DOM nodes with tree nodes and constructors that accept DOMElement and DOMAttr). While such tight integration may be viewed as a bad thing, you would be surprised how many people find the features that such integration provides useful, especially while handling typeless content (mixed content, any/anyAttribute, etc.), partial content, and integration with third-party libraries that expose their internal data model as Xerces-C++ DOM (e.g., Berkeley DB XML database). As you can see, adding Expat as another underlying XML parser to the C++/Tree mapping would not be a trivial task. Rather we are planning to leave the existing C++/Tree mapping as is (i.e., comprehensive, feature-rich, with extra benefits from the close integration with the underlying XML parser) and design and implement a new, light-weight (to the point that it is suitable for embedded systems), hybrid mapping that will use Expat as the underlying parser and provide most of the features you can find in the existing C++/Tree and C++/Parser mappings. Let me know if you would be interested in such a new mapping and I will send you a high-level overview of the design. hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061116/9cc6cbc4/attachment.pgp From boris at codesynthesis.com Wed Nov 15 23:50:12 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] automating xsd build from source In-Reply-To: <20061114222331.91152.qmail@web33103.mail.mud.yahoo.com> References: <20061114222331.91152.qmail@web33103.mail.mud.yahoo.com> Message-ID: <20061116045012.GB13570@karelia> Hi Harish, Harish Prasad writes: > I downloaded XSD and it's prerequisites packages on my Linux machine > and followed the build document for Unix provided on codesynthesis website. I assume you know that there are pre-built binaries that you can use. > Does anybody have automated way of doing entire xsd build including > installation of prerequisites packages ? We've though about it and even tried to do it with some parts of the configuration process. The hard part is to figure out how to conveniently supply such non-interactive configuration information to the build process. One way that we played with is to use make variables on the command line, e.g., $ make cxx_options=-Wall cxx_pp_options=-DNDEBUG There are several problems with this approach: 1. Things quickly become messy as the number of variables on the command line increase. This can be overcome with a config file that is included into the build process, e.g,: $ cat >my-config cxx_options=-Wall cxx_pp_options=-DNDEBUG $ make config=my-config 2. It will be hard to avoid name conflicts in such configuration variables for individual libraries. This is a much harder problem to solve. One idea is to provide config files for each individual library: $ make libcult_config=my-libcult-config hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061116/bd1bdd3c/attachment.pgp From boris at codesynthesis.com Thu Nov 16 00:00:38 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Storing individual tree nodes in DB XML documents Message-ID: <20061116050038.GC13570@karelia> Hi Remsy, Schmilinsky, Remsy writes: > Hi. From the library example: > > for (catalog::book::const_iterator bi (c->book ().begin ()); > bi != c->book ().end (); > ++bi) > > I want to save each book in dbxml as a separate document instead of the > whole catalog. can I convert iterator bi to catalog::book object and > then use it to save a document in dbxml? Sure, catalog::book::const_iterator is a standard, STL-like iterator so you can get to the book by simply dereferencing it: catalog::book const& b (*bi); > I am following the dbxml example, it shows how to save the catalog as a > document instead of a document for each book. I think this code should do what you want: // Create a new XML document. // XmlDocument doc (manager.createDocument ()); doc.setName ("new.xml"); // Obtain its DOM representation and add the root element. // xercesc::DOMDocument& dom_doc (*doc.getContentAsDOM ()); xercesc::DOMElement* e ( dom_doc.createElementNS ( xml::string ("http://www.codesynthesis.com/library").c_str (), xml::string ("lib:book").c_str ())); dom_doc.appendChild (e); // Serialize the object representation to the XML document. // *e << b; // Place the document into the container. // container.putDocument (doc, update_context); hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061116/daee162e/attachment.pgp From shasan at mitre.org Thu Nov 16 18:41:20 2006 From: shasan at mitre.org (Hasan, Eric) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Error with X3D schema Message-ID: I'm getting the following error when generating c++ code for the X3D schema. $ xsd cxx-tree x3d-3.0.xsd x3d-3.0.xsd:5804:41: warning: element 'GeoCoordinate' is implicitly of anyType x3d-3.0.xsd:5804:41: info: did you forget to specify 'type' attribute? x3d-3.0.xsd:5805:44: warning: element 'GeoElevationGrid' is implicitly of anyType x3d-3.0.xsd:5805:44: info: did you forget to specify 'type' attribute? x3d-3.0.xsd:5806:39: warning: element 'GeoLocation' is implicitly of anyType x3d-3.0.xsd:5806:39: info: did you forget to specify 'type' attribute? x3d-3.0.xsd:5807:37: warning: element 'GeoOrigin' is implicitly of anyType x3d-3.0.xsd:5807:37: info: did you forget to specify 'type' attribute? x3d-3.0.xsd:5808:34: warning: element 'GeoLOD' is implicitly of anyType x3d-3.0.xsd:5808:34: info: did you forget to specify 'type' attribute? x3d-3.0.xsd:5810:51: warning: element 'GeoPositionInterpolator' is implicitly of anyType x3d-3.0.xsd:5810:51: info: did you forget to specify 'type' attribute? x3d-3.0.xsd:5811:42: warning: element 'GeoTouchSensor' is implicitly of anyType x3d-3.0.xsd:5811:42: info: did you forget to specify 'type' attribute? x3d-3.0.xsd:5812:40: warning: element 'GeoViewpoint' is implicitly of anyType x3d-3.0.xsd:5812:40: info: did you forget to specify 'type' attribute? x3d-3.0.xsd:5813:41: warning: element 'ProtoInstance' is implicitly of anyType x3d-3.0.xsd:5813:41: info: did you forget to specify 'type' attribute? xsd: /home/boris/work/xsd/libxsd-frontend/xsd-frontend/semantic-graph/elemen ts.hxx:394: XSDFrontend::SemanticGraph::Names& XSDFrontend::SemanticGraph::Nameable::named_(): Assertion `named ()' failed. Aborted I downloaded the individual X3D schema files from web3d.org (not the zip file which, is old) and removed the includes that were causing a problem for this guy: http://www.codesynthesis.com/pipermail/xsd-users/2006-September/000537. html platform: Linux x86 distro: fedora core 4 compiler: gcc 3.2.3 20030502 codesynthesis version: v2.3.1 BETA xerces-c version: 2.7.0-3 Any help would be appreciated. From boris at codesynthesis.com Fri Nov 17 01:32:25 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Error with X3D schema In-Reply-To: References: Message-ID: <20061117063225.GA16972@karelia> Hi Eric, Hasan, Eric writes: > I'm getting the following error when generating c++ code for the X3D > schema. > > $ xsd cxx-tree x3d-3.0.xsd > > [...] > > xsd: > /home/boris/work/xsd/libxsd-frontend/xsd-frontend/semantic-graph/elemen > ts.hxx:394: XSDFrontend::SemanticGraph::Names& > XSDFrontend::SemanticGraph::Nameable::named_(): Assertion `named ()' > failed. > Aborted This is a bug in XSD. We will try to fix it before 2.3.1 is out. The workaround is to use the --morph-anonymous option: $ xsd cxx-tree --morph-anonymous x3d-3.0.xsd You will probably need to use it (along with the --root-element X3D option) anyway since without it the generated code will be too bloated. Thanks for reporting this! -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061117/73e1b0d5/attachment.pgp From davis at kapsoft.com Tue Nov 21 13:47:17 2006 From: davis at kapsoft.com (John Davis) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Parser Compile errors Message-ID: <002701c70d9d$790d9bb0$0902a8c0@OrbitFR.com> I am new to using the parser and I am getting two compiler errors. They are both referencing my "codec" parser. Obviously I am not setting it up right in my code. Please point me in the right direction. Thank you John Davis Compile errors: c:\SMS\Code\Test0\Test0.cpp(95) : error C2143: syntax error : missing ',' before '&' c:\SMS\Code\Test0\Test0.cpp(127) : error C2664: '_xsd_SAL_type::SAL_type<_xsd_Description_,_xsd_codec_>::codec_parser' : cannot convert parameter 1 from 'codec_parser' to 'xsd::cxx::parser::parser &' with [ _xsd_Description_=std::string, _xsd_codec_=codec_parser ] and [ X=codec_parser, C=char ] A reference that is not to 'const' cannot be bound to a non-lvalue ********************************************** ********************************************** Header of Test0.cpp code snippet: struct codec_parser: codec_type { virtual void nameX(const std::string& name) { name_ = name; std::cout << "codec.name :" << name << std::endl; } ~codec_parser() { }; private: std::string name_; }; struct SAL_parser: SAL_type { virtual void pre () { std::cout << "SAL.pre" << std::endl; }; virtual void Description (const std::string& Description) { Description_ = Description; std::cout << "SAL.Description: " << Description << std::endl; }; virtual void codec (const codec_parser& xxx) // THIS IS LINE 95 (see the compiler errors listed above) { std::cout << "SAL.codec" << std::endl; }; ~SAL_parser() { }; private: std::string Description_; }; ********************************************** ********************************************** xml_schema::string string_p; codec_parser codec_p; codec_p.nameX_parser (string_p); SAL_parser SAL_p; SAL_p.Description_parser (string_p); SAL_p.codec_parser (codec_p); // THIS IS LINE 127 (see compile errors above ********************************************** ********************************************** Generated Test0.hxx code snippet: namespace _xsd_codec_type { template < typename x > struct _xsd_cSpec { virtual ~_xsd_cSpec (); virtual void cSpec (const x&); void _xsd_call_glue_cSpec (::xsd::cxx::parser::parser< x, char >*); }; template < typename x > struct _xsd_cccInterface { virtual ~_xsd_cccInterface (); virtual void cccInterface (const x&); void _xsd_call_glue_cccInterface (::xsd::cxx::parser::parser< x, char >*); }; template < typename x > struct _xsd_initialization { virtual ~_xsd_initialization (); virtual void initialization (const x&); void _xsd_call_glue_initialization (::xsd::cxx::parser::parser< x, char >*); }; template < typename x > struct _xsd_DigitalData { virtual ~_xsd_DigitalData (); virtual void DigitalData (const x&); void _xsd_call_glue_DigitalData (::xsd::cxx::parser::parser< x, char >*); }; template < typename x > struct _xsd_nameX { virtual ~_xsd_nameX (); virtual void nameX (const x&); void _xsd_call_glue_nameX (::xsd::cxx::parser::parser< x, char >*); }; template < typename _xsd_cSpec_, typename _xsd_cccInterface_, typename _xsd_initialization_, typename _xsd_DigitalData_, typename _xsd_nameX_ > struct codec_type: virtual ::xsd::cxx::parser::non_validating::complex_content< char >, _xsd_cSpec< _xsd_cSpec_ >, _xsd_cccInterface< _xsd_cccInterface_ >, _xsd_initialization< _xsd_initialization_ >, _xsd_DigitalData< _xsd_DigitalData_ >, _xsd_nameX< _xsd_nameX_ > { // Parser construction API. // void cSpec_parser (::xsd::cxx::parser::parser< _xsd_cSpec_, char >&); void cccInterface_parser (::xsd::cxx::parser::parser< _xsd_cccInterface_, char >&); void initialization_parser (::xsd::cxx::parser::parser< _xsd_initialization_, char >&); void DigitalData_parser (::xsd::cxx::parser::parser< _xsd_DigitalData_, char >&); void nameX_parser (::xsd::cxx::parser::parser< _xsd_nameX_, char >&); void parsers (::xsd::cxx::parser::parser< _xsd_cSpec_, char >&, ::xsd::cxx::parser::parser< _xsd_cccInterface_, char >&, ::xsd::cxx::parser::parser< _xsd_initialization_, char >&, ::xsd::cxx::parser::parser< _xsd_DigitalData_, char >&, ::xsd::cxx::parser::parser< _xsd_nameX_, char >&); codec_type (); // Implementation. // protected: virtual bool _start_element_impl (const ::xsd::cxx::parser::ro_string< char >&, const ::xsd::cxx::parser::ro_string< char >&); virtual bool _end_element_impl (const ::xsd::cxx::parser::ro_string< char >&, const ::xsd::cxx::parser::ro_string< char >&); virtual bool _attribute_impl (const ::xsd::cxx::parser::ro_string< char >&, const ::xsd::cxx::parser::ro_string< char >&, const ::xsd::cxx::parser::ro_string< char >&); protected: ::xsd::cxx::parser::parser< _xsd_cSpec_, char >* _xsd_cSpec__; ::xsd::cxx::parser::parser< _xsd_cccInterface_, char >* _xsd_cccInterface__; ::xsd::cxx::parser::parser< _xsd_initialization_, char >* _xsd_initialization__; ::xsd::cxx::parser::parser< _xsd_DigitalData_, char >* _xsd_DigitalData__; ::xsd::cxx::parser::parser< _xsd_nameX_, char >* _xsd_nameX__; }; } template < typename _xsd_codec_type_, typename _xsd_cSpec_, typename _xsd_cccInterface_, typename _xsd_initialization_, typename _xsd_DigitalData_, typename _xsd_nameX_ > struct codec_type: virtual ::xsd::cxx::parser::parser< _xsd_codec_type_, char >, virtual _xsd_codec_type::codec_type< _xsd_cSpec_, _xsd_cccInterface_, _xsd_initialization_, _xsd_DigitalData_, _xsd_nameX_ > { /* Parser hooks. Override them in your implementation. virtual void pre (); virtual void cSpec (const _xsd_cSpec_&); virtual void cccInterface (const _xsd_cccInterface_&); virtual void initialization (const _xsd_initialization_&); virtual void DigitalData (const _xsd_DigitalData_&); virtual void nameX (const _xsd_nameX_&); virtual _xsd_codec_type_ post (); */ }; namespace _xsd_SAL_type { template < typename x > struct _xsd_Description { virtual ~_xsd_Description (); virtual void Description (const x&); void _xsd_call_glue_Description (::xsd::cxx::parser::parser< x, char >*); }; template < typename x > struct _xsd_codec { virtual ~_xsd_codec (); virtual void codec (const x&); void _xsd_call_glue_codec (::xsd::cxx::parser::parser< x, char >*); }; template < typename _xsd_Description_, typename _xsd_codec_ > struct SAL_type: virtual ::xsd::cxx::parser::non_validating::complex_content< char >, _xsd_Description< _xsd_Description_ >, _xsd_codec< _xsd_codec_ > { // Parser construction API. // void Description_parser (::xsd::cxx::parser::parser< _xsd_Description_, char >&); void codec_parser (::xsd::cxx::parser::parser< _xsd_codec_, char >&); void parsers (::xsd::cxx::parser::parser< _xsd_Description_, char >&, ::xsd::cxx::parser::parser< _xsd_codec_, char >&); SAL_type (); // Implementation. // protected: virtual bool _start_element_impl (const ::xsd::cxx::parser::ro_string< char >&, const ::xsd::cxx::parser::ro_string< char >&); virtual bool _end_element_impl (const ::xsd::cxx::parser::ro_string< char >&, const ::xsd::cxx::parser::ro_string< char >&); protected: ::xsd::cxx::parser::parser< _xsd_Description_, char >* _xsd_Description__; ::xsd::cxx::parser::parser< _xsd_codec_, char >* _xsd_codec__; }; } template < typename _xsd_SAL_type_, typename _xsd_Description_, typename _xsd_codec_ > struct SAL_type: virtual ::xsd::cxx::parser::parser< _xsd_SAL_type_, char >, virtual _xsd_SAL_type::SAL_type< _xsd_Description_, _xsd_codec_ > { /* Parser hooks. Override them in your implementation. virtual void pre (); virtual void Description (const _xsd_Description_&); virtual void codec (const _xsd_codec_&); virtual _xsd_SAL_type_ post (); */ }; ******************************************************************* From boris at codesynthesis.com Tue Nov 21 14:54:08 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Parser Compile errors In-Reply-To: <002701c70d9d$790d9bb0$0902a8c0@OrbitFR.com> References: <002701c70d9d$790d9bb0$0902a8c0@OrbitFR.com> Message-ID: <20061121195408.GB13842@karelia> Hi John, John Davis writes: > Header of Test0.cpp code snippet: > > > > struct codec_parser: codec_type initialization_parser, DigitalData_parser, std::string> > > { > > [...] > > }; > > > > struct SAL_parser: SAL_type I am not sure you want to make the last template argument 'codec_parser'. Generally the type that you put there should be the same as the result type (the first template argument) of one of the parsers. Here you are going to use codec_parser to handle 'codec' so the type you use here should be the same as the result type of codec_parser, which is void. So this line should probably be: struct SAL_parser: SAL_type > virtual void codec (const codec_parser& xxx) This will then become: virtual void codec () > // THIS IS LINE 95 (see the compiler errors listed above) Hm, I am not sure why the compiler is complaining. Hopefully it will go away after the changes above. hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061121/a2c9e6ba/attachment.pgp From davis at kapsoft.com Tue Nov 21 15:24:20 2006 From: davis at kapsoft.com (John Davis) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Parser Compile errors In-Reply-To: <20061121195408.GB13842@karelia> Message-ID: <000e01c70dab$077efd00$0902a8c0@OrbitFR.com> Yes, that fixed it. Thanks John Davis -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Tuesday, November 21, 2006 2:54 PM To: John Davis Cc: xsd-users@codesynthesis.com Subject: Re: [xsd-users] Parser Compile errors Hi John, John Davis writes: > Header of Test0.cpp code snippet: > > > > struct codec_parser: codec_type initialization_parser, DigitalData_parser, std::string> > > { > > [...] > > }; > > > > struct SAL_parser: SAL_type I am not sure you want to make the last template argument 'codec_parser'. Generally the type that you put there should be the same as the result type (the first template argument) of one of the parsers. Here you are going to use codec_parser to handle 'codec' so the type you use here should be the same as the result type of codec_parser, which is void. So this line should probably be: struct SAL_parser: SAL_type > virtual void codec (const codec_parser& xxx) This will then become: virtual void codec () > // THIS IS LINE 95 (see the compiler errors listed above) Hm, I am not sure why the compiler is complaining. Hopefully it will go away after the changes above. hth, -boris From greg at permedia.ca Wed Nov 22 18:33:14 2006 From: greg at permedia.ca (Greg Carter) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] reading and writing non root elements Message-ID: <4564DE3A.10502@permedia.ca> Hello, I wondering what the best approach would be for the following problem. I've defined a schema with one root element which is a complex type made up of many other complex types. All the complex types are defined globally (no inner anonymous types). Once the instance document is read in to a XSD generated class I wish to then operate on these sub types, changing the data, sending it off to other shared libs to do so. These shared libraries can be written in another language. So I thought the easiest thing to do would be to write the data out to an XML string to pass it to the other libraries. Similarly, have the results passed back as an XML string that I can then read back into the XSD generated class. It's assumed the developers of the other libraries will have access to schema binding tools similar to XSD. XSD cxx-tree will generate serialization functions for the schema root elements. Is there an easy way to do this for non root elements? I see that the class constructors can take a Xercesc DOMElement but I'm not sure how to get the string into this. Would I be better off defining separate schemas for any type that I need to use in this way (declaring a root element of that type)? I can accomplish writing the data out to a string by using the --generate-ostream option. If I were to read in the data generated by these stream functions to an XSD generated class, would I need to preface it with namespace (xmls=...) information so that the classes will parse it correctly? Below is a simple schema that illustrates the problem. After parsing the instance document that contains a MyType, I'll use the class instance of elOne, do something with it, then pass it off to a shared library, first converting it to XML. There's no need to convert the whole document to XML, just the elOne. Then I need to be able to parse the returned XML string back into an instance of ElOneType. Thanks. ... From boris at codesynthesis.com Thu Nov 23 10:15:12 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] reading and writing non root elements In-Reply-To: <4564DE3A.10502@permedia.ca> References: <4564DE3A.10502@permedia.ca> Message-ID: <20061123151512.GA19837@karelia> Hi Greg, Greg Carter writes: > I wondering what the best approach would be for the following problem. > I've defined a schema with one root element which is a complex type made > up of many other complex types. All the complex types are defined > globally (no inner anonymous types). Once the instance document is read > in to a XSD generated class I wish to then operate on these sub types, > changing the data, sending it off to other shared libs to do so. These > shared libraries can be written in another language. So I thought the > easiest thing to do would be to write the data out to an XML string to > pass it to the other libraries. Similarly, have the results passed back > as an XML string that I can then read back into the XSD generated > class. It's assumed the developers of the other libraries will have > access to schema binding tools similar to XSD. > > XSD cxx-tree will generate serialization functions for the schema root > elements. Is there an easy way to do this for non root elements? > > I see that the class constructors can take a Xercesc DOMElement but I'm > not sure how to get the string into this. > > Would I be better off defining separate schemas for any type that I need > to use in this way (declaring a root element of that type)? That would be one way to accomplish this. You could define a separate schema which will include the original schema and define a root element for each complex type. You can then compile this schema to obtain necessary parsing and serialization functions. The only problem with this approach is that you won't get exactly the same XML in the following situation: 1. Your schema defines target namespace 2. Local elements in your schema are unqualified In this case your fragment XML will have its root element qualified while the complete XML document has it unqualified, e.g., ... ... ... And the fragment will look like this: ... This is because global elements in XML Schema are always qualified. The other approach uses generated type's constructors and serialization operators to parse/serialize the type instance into XML. It also requires some dealing with Xerces-C++. First, let's consider the parsing case. We are going to use the helper function that is shown in the Q 2.1 of the Wiki FAQ[1]. The first step is to parse your XML string to DOM: #include using namespace xercesc; namespace xml = xsd::cxx::xml; XMLPlatformUtils::Initialize (); { std::istringstream is (""); xml::dom::auto_ptr doc (parse (is)); Then we need to get to the root DOMElement which we can pass to the ElOneType's constructor: DOMElement& e (*doc->getDocumentElement ()); ElOneType el_one (e); } XMLPlatformUtils::Terminate (); The opposite direction is similar: first we create an empty DOM document, then we use the generated serialization operator to write the contents of ElOneType to the document's root element, and, finally, we serialize the DOM document to XML string. Here we are using helper functions defined in Q 3.1 and 3.2 of the same FAQ: #include using namespace xercesc; namespace xml = xsd::cxx::xml; XMLPlatformUtils::Initialize (); { xml::dom::auto_ptr doc (create ("elOne")); DOMElement& e (*doc->getDocumentElement ()); ElOneType el_one = ... e << el_one; std::ostringstream os (""); serialize (os, *doc); // XML string is in os.str () } XMLPlatformUtils::Terminate (); This approach does not have the qualification problem described above. > I can accomplish writing the data out to a string by using the > --generate-ostream option. The --generate-ostream options triggers generation of the std::ostream insertion operators that print the data in the human-readable form, not in XML. They are usually used for debugging, etc. [1] http://wiki.codesynthesis.com/Tree/FAQ hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061123/a1693fc5/attachment.pgp From thierry.letellier at capgemini.fr Mon Nov 27 10:05:27 2006 From: thierry.letellier at capgemini.fr (LETELLIER Thierry) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] how to create en xml file Message-ID: <456AFEB7.3090301@capgemini.fr> Hi I m a new xml/xsd user Someone have generate C++ sources from an xsd schema He use it to read an xml file and i have to use the sources and the schema to create this file But i don't understand How it work at all First : how can i open the stream Second : I have the write a vector of objets how can i do that I need some help or good exemples .... Thierry Toulouse FRANCE This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. From boris at codesynthesis.com Mon Nov 27 10:23:14 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] how to create en xml file In-Reply-To: <456AFEB7.3090301@capgemini.fr> References: <456AFEB7.3090301@capgemini.fr> Message-ID: <20061127152314.GA4818@karelia> Hi Thierry, LETELLIER Thierry writes: > I m a new xml/xsd user > Someone have generate C++ sources from an xsd schema > He use it to read an xml file > and i have to use the sources and the schema to create this file > But i don't understand How it work at all > > First : how can i open the stream > Second : I have the write a vector of objets how can i do that There is the library example in examples/cxx/tree/library that shows how to do what you want. Normally you would create an empty top-level instance that represents your document. In case of the library example it would be catalog (which is a sequence of books): catalog c; Then you populate this instance with data, e.g., by creating and adding one or two books: book b (679776443, // ISBN title ("Dead Souls"), // Title genre::philosophy, // Genre "DS"); // ID b.author ().push_back (author ("Nikolai Gogol", "1809-03-31")); c.book ().push_back (b); Then you open a stream (this could be pretty much any stream, a file stream, a string stream, etc.): std::ofstream ofs ("result.xml"); Finally, you serialize the in-memory representation to the stream: xml_schema::namespace_infomap map; map["lib"].name = "http://www.codesynthesis.com/library"; map["lib"].schema = "library.xsd"; catalog_ (ofs, c, map); hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061127/41c1ed23/attachment.pgp From greg at permedia.ca Mon Nov 27 18:31:24 2006 From: greg at permedia.ca (Greg Carter) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] reading and writing non root elements In-Reply-To: <20061123151512.GA19837@karelia> References: <4564DE3A.10502@permedia.ca> <20061123151512.GA19837@karelia> Message-ID: <456B754C.5000600@permedia.ca> Hi Boris, Thanks for the reply. I am trying to use the code given to read in an XML doc but I am getting errors at the point where the string is read into a DOMDocument object ( the parser->parse(wrap) line in the parse function). I get a bunch of "error: Unknown Element 'MyEleType" and "error: Attribute 'someAtt' is not declared for element 'MyEleType'" Do I need to tell Xerces about the schema that defines MyEleType? Thanks Greg. Boris Kolpackov wrote: > Hi Greg, > > Greg Carter writes: > > The other approach uses generated type's constructors and serialization > operators to parse/serialize the type instance into XML. It also requires > some dealing with Xerces-C++. > > First, let's consider the parsing case. We are going to use the helper > function that is shown in the Q 2.1 of the Wiki FAQ[1]. The first > step is to parse your XML string to DOM: > > #include > > using namespace xercesc; > namespace xml = xsd::cxx::xml; > > XMLPlatformUtils::Initialize (); > > { > std::istringstream is (""); > xml::dom::auto_ptr doc (parse (is)); > > Then we need to get to the root DOMElement which we can pass to the > ElOneType's constructor: > > DOMElement& e (*doc->getDocumentElement ()); > > ElOneType el_one (e); > > } > > XMLPlatformUtils::Terminate (); > From greg at permedia.ca Tue Nov 28 12:15:01 2006 From: greg at permedia.ca (Greg Carter) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] reading and writing non root elements In-Reply-To: <456B754C.5000600@permedia.ca> References: <4564DE3A.10502@permedia.ca> <20061123151512.GA19837@karelia> <456B754C.5000600@permedia.ca> Message-ID: <456C6E95.1000506@permedia.ca> OK I got it to work by setting the validate variable to false in the parse function. To get validation back working I've added a call to DOMBuilder::setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, location), but I can't seem to make Xerces happy with my schema location... oh well I should get it eventually. Thanks. Greg. Greg Carter wrote: > Hi Boris, > > Thanks for the reply. I am trying to use the code given to read in an > XML doc but I am getting errors at the point where the string is read > into a DOMDocument object ( the parser->parse(wrap) line in the parse > function). I get a bunch of "error: Unknown Element 'MyEleType" and > "error: Attribute 'someAtt' is not declared for element 'MyEleType'" > > Do I need to tell Xerces about the schema that defines MyEleType? > > Thanks > Greg. From boris at codesynthesis.com Tue Nov 28 12:12:14 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] reading and writing non root elements In-Reply-To: <456C6E95.1000506@permedia.ca> References: <4564DE3A.10502@permedia.ca> <20061123151512.GA19837@karelia> <456B754C.5000600@permedia.ca> <456C6E95.1000506@permedia.ca> Message-ID: <20061128171214.GA12065@karelia> Hi Greg, Greg Carter writes: > OK I got it to work by setting the validate variable to false in the > parse function. To get validation back working I've added a call to > DOMBuilder::setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, > location), but I can't seem to make Xerces happy with my schema location... > oh well I should get it eventually. I am glad you've figured it out. I think your problem with setProperty comes from the fact that Xerces-C++ treats the location as a relative path unless it is in the form "file:///absolute/path/to/your/schema.xsd". You can read more about this in Q 2.4 of the "official" C++/Tree Mapping FAQ: http://codesynthesis.com/projects/xsd/documentation/cxx/tree/faq/#2.4 Also note that in order for your XML fragment to be successfully validated against the schema you will need to declare the fragment's root element as global in the schema. Only global elements are allowed to be document roots in XML Schema. hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061128/ee816b6e/attachment.pgp From barbapapaz at gmail.com Wed Nov 29 10:28:01 2006 From: barbapapaz at gmail.com (barbapapaz) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] generate binding on 3DXML file Message-ID: <52a41b370611290728n1651608byb0686ceb9a6ced22@mail.gmail.com> Hi, 3Dxml file is concurent of colada of Sony I try to generate c++ class with xsd.exe (cxx-tree), but i have an error: 3DXML.xsd:276:85: error: Value '0.0E0' with length '1' is not equal to length facet of '3' . I don't find this informations in 3dxml.xsd. You have an idea? http://dl-3.free.fr/52616e646f6d4956eefa3625187cdc157018ff0fbbc4929081b68c8b226d969e/3DXML.xsd this file is valid for 24 hours, you can download it on dassault 3dxml website if it's to late. From boris at codesynthesis.com Wed Nov 29 12:40:22 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] generate binding on 3DXML file In-Reply-To: <52a41b370611290728n1651608byb0686ceb9a6ced22@mail.gmail.com> References: <52a41b370611290728n1651608byb0686ceb9a6ced22@mail.gmail.com> Message-ID: <20061129174022.GC17541@karelia> Hi, barbapapaz writes: > 3Dxml file is concurent of colada of Sony > > I try to generate c++ class with xsd.exe (cxx-tree), but i have an error: > > 3DXML.xsd:276:85: error: Value '0.0E0' with length '1' is not equal to > length facet of '3' . I don't find this informations in 3dxml.xsd. This is a bug in Xerces-C++ 2.7.0 (jira issue #1546) that is fixed in the latest beta (2.3.1.b1) which you can get here: http://codesynthesis.com/products/xsd/download.xhtml I was able to compile your schema with this command line: xsd cxx-tree --namespace-map http://www.3ds.com/xsd/3DXML=ThreeDXML 3DXML.xsd Note also that you will need to do one of the following: 1. Disable validation on the Xerces-C++ level by passing the xml_schema::flags::dont_validate flag to the parsing function. 2. If you want validation then your will need to patch Xerces-C++ that you link to your application with the fix for this bug. The patch can be downloaded from here: http://codesynthesis.com/~boris/tmp/xerces-c-2.7.0-1546.patch hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061129/2d9426b6/attachment.pgp From greg at permedia.ca Wed Nov 29 19:16:25 2006 From: greg at permedia.ca (Greg Carter) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] reading and writing non root elements In-Reply-To: <20061128171214.GA12065@karelia> References: <4564DE3A.10502@permedia.ca> <20061123151512.GA19837@karelia> <456B754C.5000600@permedia.ca> <456C6E95.1000506@permedia.ca> <20061128171214.GA12065@karelia> Message-ID: <456E22D9.9000601@permedia.ca> Hello Boris, One last problem. I changed my schema so that the element was global and added a ref to it. I used the code that you gave in the last post plus the helper functions in the FAQ. I also added a call to setAttributeNS and added an entry for the prefix for my namespace (tns in the example). In the generated XML I am not getting my root element tagged with the prefix, if I manually add the prefix to the root element it validates. This is what is generated: If I change it to (add the tns: prefix to elOne) it works. This is also how the XML looks (tns namespace prefix) when generated by the XSD generated code for the global element I chose as the root element. I did step through the XSD generated code to see where the prefix was added but it wasn't immediately clear. I do have a comment on multiple global elements, but I'll put it in a new message to the list. Thanks. Greg. Boris Kolpackov wrote: > Hi Greg, > > > I am glad you've figured it out. I think your problem with setProperty > comes from the fact that Xerces-C++ treats the location as a relative > path unless it is in the form "file:///absolute/path/to/your/schema.xsd". > You can read more about this in Q 2.4 of the "official" C++/Tree Mapping > FAQ: > > http://codesynthesis.com/projects/xsd/documentation/cxx/tree/faq/#2.4 > > > Also note that in order for your XML fragment to be successfully > validated against the schema you will need to declare the fragment's > root element as global in the schema. Only global elements are allowed > to be document roots in XML Schema. > > > hth, > -boris > From greg at permedia.ca Wed Nov 29 19:58:14 2006 From: greg at permedia.ca (Greg Carter) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Global elements Re: reading and writing non root elements In-Reply-To: <456E22D9.9000601@permedia.ca> References: <4564DE3A.10502@permedia.ca> <20061123151512.GA19837@karelia> <456B754C.5000600@permedia.ca> <456C6E95.1000506@permedia.ca> <20061128171214.GA12065@karelia> <456E22D9.9000601@permedia.ca> Message-ID: <456E2CA6.5020607@permedia.ca> Arg! You can ignore my last post if you want. When I ran my schema through XSD with the newly defined multiple global elements I missed the fact that you could tell XSD to generate code for document roots for ALL global elements (--root-element-all). Given that all elements must be global to be valid instances documents, and XSD can generate the required code, there is no need for me to write any Xerces code at all. That was going to be my comment, why wouldn't XSD generate root element code for all global elements. But now I see that it does. Of course I am a little confused why you didn't just mention that to begin with ;) Thanks. Greg. Greg Carter wrote: > Hello Boris, > > One last problem. From beddoes at intient.com Thu Nov 30 08:59:15 2006 From: beddoes at intient.com (Bradley Beddoes) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Licence Query for OSS projects Message-ID: <456EE3B3.9060306@intient.com> Hello, I have been reading in detail tonight your license information for XSD and had a query which I hope to have cleared up, this was the only suitable forum I could find, if licensing queries are best directed elsewhere please let me know. I am currently working on a library which will be open sourced under the Apache 2.0 license when it is completed. In addition to loading and manipulating XML documents using the generated code from XSD it will perform signature validation using Apache XML security, public key resolution/management and verification of supplied data to prevent for example replay attacks amongst others. In my understanding of the FLOSSE file distributed this would clarify it as a member of the 1a scenario, and Apache 2.0 is a supported free software license, is this correct? Therefore all we need to do is label the generated code from XSD with the Apache 2.0 license header and distribution is legal? Do we need to supply the FLOSSE or any other relevant documentation with the release? In addition to the above I hope to be able to feed back to you a list of quite complex schema developed by OASIS that XSD supports once everything is working well for inclusion on the supported schema pages. Of course we look forward to working with the XSD community in the future. regards, Bradley -- Bradley Beddoes Lead Technical Architect Intient http://intient.com Open Source, Open Standards. From boris at codesynthesis.com Thu Nov 30 09:14:46 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Re: Global elements Re: reading and writing non root elements In-Reply-To: <456E2CA6.5020607@permedia.ca> References: <4564DE3A.10502@permedia.ca> <20061123151512.GA19837@karelia> <456B754C.5000600@permedia.ca> <456C6E95.1000506@permedia.ca> <20061128171214.GA12065@karelia> <456E22D9.9000601@permedia.ca> <456E2CA6.5020607@permedia.ca> Message-ID: <20061130141446.GB20095@karelia> Hi Greg, Greg Carter writes: > That was going to be my comment, why wouldn't XSD generate root element > code for all global elements. But now I see that it does. Of course I > am a little confused why you didn't just mention that to begin with ;) I thought I did in my first reply to this thread (where I talked about two strategies to handle XML fragments, the first being to define global elements and the second being to do XML-to-DOM parsing yourself and then use the constructors). But I think I know where the confusion came from. In that reply I suggest that you define a separate schema with those additional global elements. I think you understood this as defining a separate schema for each element (presumably because XSD cannot generate parsing/serialization functions for more than one element) while I meant to define one schema with all the extra elements just for architectural cleanness (e.g., external consumers of your XML may not need to see these elements). There is nothing that prevents you from putting the extra elements in the original schema. Sorry about the confusion :-) -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061130/4e904462/attachment.pgp From boris at codesynthesis.com Thu Nov 30 09:22:49 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] reading and writing non root elements In-Reply-To: <456E22D9.9000601@permedia.ca> References: <4564DE3A.10502@permedia.ca> <20061123151512.GA19837@karelia> <456B754C.5000600@permedia.ca> <456C6E95.1000506@permedia.ca> <20061128171214.GA12065@karelia> <456E22D9.9000601@permedia.ca> Message-ID: <20061130142249.GC20095@karelia> Hi Greg, Replying in case somebody else will need this. Greg Carter writes: > One last problem. I changed my schema so that the element was global > and added a ref to it. I used the code that you gave in the last post > plus the helper functions in the FAQ. I also added a call to > setAttributeNS and added an entry for the prefix for my namespace (tns > in the example). In the generated XML I am not getting my root element > tagged with the prefix, if I manually add the prefix to the root element > it validates. I think you forgot to add the namespace and prefix for the root element in your call to create(). I.e., you have: create ("elOne"); while you need: create ("elOne", "http://www.blah.com/MySchema", "tns"); Also note that you don't need to manually associate the "tns" prefix with "http://www.blah.com/MySchema" using setAttributeNS since this namespace will be handled automatically. > I did step through the XSD generated code to see where the prefix was > added but it wasn't immediately clear. It is added automatically by the Xerces-C++ createDocument function. hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061130/9682b17c/attachment.pgp From boris at codesynthesis.com Thu Nov 30 10:30:30 2006 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Oct 11 15:33:50 2009 Subject: [xsd-users] Licence Query for OSS projects In-Reply-To: <456EE3B3.9060306@intient.com> References: <456EE3B3.9060306@intient.com> Message-ID: <20061130153030.GD20095@karelia> Hi Bradley, Bradley Beddoes writes: > I am currently working on a library which will be open sourced under the > Apache 2.0 license when it is completed. In addition to loading and > manipulating XML documents using the generated code from XSD it will > perform signature validation using Apache XML security, public key > resolution/management and verification of supplied data to prevent for > example replay attacks amongst others. > > In my understanding of the FLOSSE file distributed this would clarify it > as a member of the 1a scenario, and Apache 2.0 is a supported free > software license, is this correct? Apache 2.0 is a supported free software license. However to say whether your case falls under the FLOSS exception or not, we will need a little bit more details on what useful functionality you will provide on top of the generated code (i.e., what does "manipulating XML documents using the generated code" really means in your case). I believe that the Apache XML security library does its job on raw XML. If that's the case then the fact that you use it is not relevant since it does not depend on the generated code in any way (I can be mistaken here, of course). It would also be helpful to know how do you expect the clients of your library to use it. Please feel free to email me privately if you would rather not go into details on the public mailing list. > In addition to the above I hope to be able to feed back to you a list of > quite complex schema developed by OASIS that XSD supports once > everything is working well for inclusion on the supported schema pages. This would be great, thanks. hth, -boris -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: Digital signature Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20061130/bc362350/attachment.pgp