From givemenews at tom.com Wed Apr 2 00:24:47 2008
From: givemenews at tom.com (Lixuesong)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] about cxx-tree generated include file
Message-ID: <000601c89479$7e68cc10$6601a8c0@michael>
I have a xsd file my.xsd with following segment:
and compiling the xsd file using the following command:
xsd cxx-tree --generate-serialization --hxx-suffix .h --cxx-suffix .cpp my.xsd
and I found in generated my.h file, there is a line:
#include "../general/lizgen.h"
in fact, I finally put my.h and lizgen.h in the same directory, so such a including will raise a failure when compiling using g++.
so, would you let me have a choice to produce my.h with:
#include "lizgen.h"
instead of
#include "../general/lizgen.h" ?
From boris at codesynthesis.com Wed Apr 2 04:05:30 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] about cxx-tree generated include file
In-Reply-To: <000601c89479$7e68cc10$6601a8c0@michael>
References: <000601c89479$7e68cc10$6601a8c0@michael>
Message-ID: <20080402080530.GB10411@karelia>
Hi,
Lixuesong writes:
> I have a xsd file my.xsd with following segment:
>
>
>
> [...]
>
> and I found in generated my.h file, there is a line:
>
> #include "../general/lizgen.h"
>
>
> so, would you let me have a choice to produce my.h with:
> #include "lizgen.h"
>
> instead of
> #include "../general/lizgen.h" ?
You can use the --include-regex option (see the XSD Compiler Command
Line Manual for details). Your particular case can be handled with
the following regex:
--include-regex "%../general/lizgen.h%lizgen.h%"
Boris
From smadhavi at prokarma.com Wed Apr 2 05:19:34 2008
From: smadhavi at prokarma.com (Sirigiri Madhavi)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Issue on parsing of one element which is of different
types
Message-ID: <8F1D4C7A00A8DB418C6DF27C26F086DD0CFE629B@VS5.EXCHPROD.USA.NET>
Hi All,
I have some issue on parsing of one element(EventMessage) which is of different types( AlertOpen, AlertClosure )
Detailed explanation:
1. Event.xml :
AE
2008-02-13T09:38:00.000-05:00
0701
2008-02-14T00:18:21.000-05:00
TTCI
2008-02-14T00:06:43.000-05:00
OPEN
CE
M
2008-02-13T01:00:00.000-05:00
0701
2008-02-14T00:35:00.000-05:00
WSR
2008-02-13T01:00:00.000-05:00
CLOSE
2.notifications_v200701.xsd :
These match the flat file format
These match the flat file format
When I generate driver (notifications_v200701-driver.cxx) file automatically I didn't get any parser calls in that except the below one :
EventMessages_p.parsers (EventMessage_p);
As we have no parsers in the EventMessage-Skeleton class. so it is not generating any more parser calls in that driver file.
If I give manually EventMessages_p.parsers (AlertClosure_p); it is printing the values.
But I want to connect both types (AlertOpen and AlertClosure) of EventMessage parser automatically with the EventMessages parser.
Can anybody help.
Thanks in advance.
Madhu
From boris at codesynthesis.com Wed Apr 2 05:52:22 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Issue on parsing of one element which is of different
types
In-Reply-To: <8F1D4C7A00A8DB418C6DF27C26F086DD0CFE629B@VS5.EXCHPROD.USA.NET>
References: <8F1D4C7A00A8DB418C6DF27C26F086DD0CFE629B@VS5.EXCHPROD.USA.NET>
Message-ID: <20080402095222.GC11293@karelia>
Hi Sirigiri,
Sirigiri Madhavi writes:
> When I generate driver (notifications_v200701-driver.cxx) file
> automatically I didn't get any parser calls in that except the
> below one :
>
> EventMessages_p.parsers (EventMessage_p);
The generated sample test driver does not instantiate and connect
parsers for polymorphic cases. It is generally not possible to do
since there is no way to know which types can and cannot be used
in xsi:type. You will need to add extra parser() calls with derived
types yourself.
> If I give manually EventMessages_p.parsers (AlertClosure_p); it is
> printing the values.
>
> But I want to connect both types (AlertOpen and AlertClosure) of
> EventMessage parser automatically with the EventMessages parser.
Then you need to add:
EventMessages_p.parser (AlertOpen_p);
EventMessages_p.parser (AlertClosure_p);
To the call for EventMessage_p that is generated automatically. This
is all covered in Section 5.4, "Support for Polymorphism" in the
C++/Parser Getting Started Guide:
http://codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.4
As we all in the 'polymorphism' example.
Boris
From roee88 at gmail.com Wed Apr 2 13:15:17 2008
From: roee88 at gmail.com (roee shlomo)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Managed code in generated header file
Message-ID: <9963f10e0804021015x1a8b9edes24a6560299366ca3@mail.gmail.com>
Hi all,
I'm working on a project written in pure c++.
I'm using CodeSynthesis XSD and it used to work fine. It generated a small
header file and all worked fine:
> ...
> // Begin prologue.
> //
> //
> // End prologue.
>
> #include
>
> #if (XSD_INT_VERSION != 3000000L)
> #error XSD runtime version mismatch
> #endif
>
> #include
> ...
>
I then upgraded from Microsoft Visual Studio 2005 Express to Microsoft
Visual Studio 2005 Professional and it doesn't work anymore.
Each time I build the project I can see:
> 1>Creating DataSet class using XSD ...
>
> 1>Writing file 'd:'.
>
And the header file generated by CodeSynthesis XSD changes into a large file
that uses .NET code:
> #pragma once
>
> #using
> #using
> #using
> #using
>
> using namespace System::Security::Permissions;
> [assembly:SecurityPermissionAttribute(SecurityAction::RequestMinimum,
> SkipVerification=false)];
> //
> // This source code was auto-generated by xsd, Version=2.0.50727.42.
> //
>
> ...
>
As a result I get this error in the generated file:
> fatal error C1190: managed targeted code requires a '/clr' option
Note that I have set the appropriate values in `projects and solutions` ->
`vc++ directories`.
Thanks in advance,
Roee.
From boris at codesynthesis.com Wed Apr 2 14:10:15 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Managed code in generated header file
In-Reply-To: <9963f10e0804021015x1a8b9edes24a6560299366ca3@mail.gmail.com>
References: <9963f10e0804021015x1a8b9edes24a6560299366ca3@mail.gmail.com>
Message-ID: <20080402181015.GA13345@karelia>
Hi,
roee shlomo writes:
> I then upgraded from Microsoft Visual Studio 2005 Express to Microsoft
> Visual Studio 2005 Professional and it doesn't work anymore.
>
> [...]
>
> Note that I have set the appropriate values in `projects and solutions` ->
> `vc++ directories`.
Make sure you set up the "Executable Files" path to point to the bin
directory inside the XSD distribution and it is at the top of the list.
If I try to remove this path I get the same problem as you do. For more
information refer to the README file that comes with the XSD distribution
for Windows.
Boris
From lvkun2006 at gmail.com Tue Apr 8 00:17:24 2008
From: lvkun2006 at gmail.com (kun lv)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Questions about Default Value and Debug
Message-ID: <32b74eaf0804072117m15e46a95xf01410cc03898617@mail.gmail.com>
Hi,
I have a large XSD file and generate code from
it(with --generate-default-ctor ). I don't set all value for every element
,but when I run the program, It throw exception. I want to know if I can
find a method allow me not set all value for every element.
And I also want to know if the code generated by xsd could output the some
log for debugging. The exception infomation is so brief that I can't find
where cause the error.
In the end, how can i output the structure to wstring. It seems like it can
only use the stringstream not wstringstream.
Thank you very much.
From boris at codesynthesis.com Tue Apr 8 03:46:17 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Questions about Default Value and Debug
In-Reply-To: <32b74eaf0804072117m15e46a95xf01410cc03898617@mail.gmail.com>
References: <32b74eaf0804072117m15e46a95xf01410cc03898617@mail.gmail.com>
Message-ID: <20080408074617.GA5385@karelia>
Hi,
kun lv writes:
> I have a large XSD file and generate code from
> it(with --generate-default-ctor ). I don't set all value for every element
> ,but when I run the program, It throw exception. I want to know if I can
> find a method allow me not set all value for every element.
No, there is no such method. The XSD-generated code has no way to
know what you think the default value should be for every type. I
suggest that you remove the --generate-default-ctor option. This
way the generated constructors will force you to specify the
required values and you won't get any exceptions.
> And I also want to know if the code generated by xsd could output the some
> log for debugging. The exception infomation is so brief that I can't find
> where cause the error.
You can use the --generate-ostream option which triggers generation
of std::ostream insertion operators for every generated type. This
way you can print the whole object model or any or its fragments
into a log.
> In the end, how can i output the structure to wstring. It seems like it can
> only use the stringstream not wstringstream.
You can instruct the compiler to use 'wchar_t' as the character type
instead of 'char' in the generate code with the '--char-type wchar_t'
option. This way the string-based types will all derive from
std::wstring instead of std::string. The stream insertion operators
will also use std::wostream instead of std::ostream.
If you don't want to change the character type in the generated code,
then you can use the following series of steps (may not work on all
platforms and/or for all character encodings):
type& r = ... / object model
std::ostringstream ostr;
ostr << r;
std::wostringstream wostr;
wostr << ostr.str ().c_str ();
std::wstring s (wostr.str ());
Boris
From lvkun2006 at gmail.com Tue Apr 8 05:29:25 2008
From: lvkun2006 at gmail.com (kun lv)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Questions about Default Value and Debug
In-Reply-To: <20080408074617.GA5385@karelia>
References: <32b74eaf0804072117m15e46a95xf01410cc03898617@mail.gmail.com>
<20080408074617.GA5385@karelia>
Message-ID: <32b74eaf0804080229v51c9df8dwe2a7feb756618666@mail.gmail.com>
Thank you for your patient explanation. But I already add the "--char-type
wchar_t'" option, the string type is converted to wstring,but the stream
insertion operators have not changed.
my compile option
xsd cxx-tree --hxx-suffix .h --cxx-suffix .cpp --char-type wchar_t
--generate-serialization --generate-default-ctor --generate-ostream
--generate-intellisense --cxx-prologue "#include ""stdafx.h""" Base.xsd
2008/4/8, Boris Kolpackov :
>
> Hi,
>
> kun lv writes:
>
> > I have a large XSD file and generate code from
> > it(with --generate-default-ctor ). I don't set all value for every
> element
> > ,but when I run the program, It throw exception. I want to know if I can
> > find a method allow me not set all value for every element.
>
> No, there is no such method. The XSD-generated code has no way to
> know what you think the default value should be for every type. I
> suggest that you remove the --generate-default-ctor option. This
> way the generated constructors will force you to specify the
> required values and you won't get any exceptions.
>
>
> > And I also want to know if the code generated by xsd could output the
> some
> > log for debugging. The exception infomation is so brief that I can't
> find
> > where cause the error.
>
> You can use the --generate-ostream option which triggers generation
> of std::ostream insertion operators for every generated type. This
> way you can print the whole object model or any or its fragments
> into a log.
>
>
> > In the end, how can i output the structure to wstring. It seems like it
> can
> > only use the stringstream not wstringstream.
>
> You can instruct the compiler to use 'wchar_t' as the character type
> instead of 'char' in the generate code with the '--char-type wchar_t'
> option. This way the string-based types will all derive from
> std::wstring instead of std::string. The stream insertion operators
> will also use std::wostream instead of std::ostream.
>
> If you don't want to change the character type in the generated code,
> then you can use the following series of steps (may not work on all
> platforms and/or for all character encodings):
>
> type& r = ... / object model
>
> std::ostringstream ostr;
> ostr << r;
>
> std::wostringstream wostr;
> wostr << ostr.str ().c_str ();
>
> std::wstring s (wostr.str ());
>
> Boris
>
From boris at codesynthesis.com Tue Apr 8 05:52:57 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Questions about Default Value and Debug
In-Reply-To: <32b74eaf0804080229v51c9df8dwe2a7feb756618666@mail.gmail.com>
References: <32b74eaf0804072117m15e46a95xf01410cc03898617@mail.gmail.com>
<20080408074617.GA5385@karelia>
<32b74eaf0804080229v51c9df8dwe2a7feb756618666@mail.gmail.com>
Message-ID: <20080408095257.GA10745@karelia>
Hi,
kun lv writes:
> But I already add the "--char-type wchar_t'" option, the string type
> is converted to wstring,but the stream insertion operators have not
> changed.
I just tried to compile hello.xsd that comes with the XSD distribution
using the following command line:
xsd cxx-tree --char-type wchar_t --generate-ostream hello.xsd
After that I opened the generated hello.hxx file and saw the following
declaration for the stream insertion operator:
::std::wostream&
operator<< (::std::wostream&, const hello_t&);
This operator should allow me to do the following:
hello_t& h = ...
std::wostringstream ostr;
ostr << h;
std::wstring s (ostr.str ());
Perhaps you are confusing the stream insertion operators that are
generated using --generate-ostream with the serialization operators
and functions generated using --generate-serialization. The stream
insertion operators dump the object model in a human readable text
format which is useful for debugging, etc. The serialization
operators save the object model in XML. Because XML can be encoded
using various encodings (e.g., ASCII, UTF-8, UTF-16, UTF-32), the
resulting output is treated by serialization functions as a sequence
of bytes. This is why serialization functions output to std::ostream
even when you specify '--char-type wchar_t'. If you make sure that
your XML is in the same encoding and endianness as what's in wchar_t
(e.g, UTF-32LE), then you can initialize a std::wstring instance with
a memory buffer that holds your XML document.
Boris
From meirab at gmail.com Tue Apr 8 14:16:21 2008
From: meirab at gmail.com (M)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] hello codesynthesis
Message-ID: <00b101c899a4$a8051210$6402a8c0@m1>
hello codesynthesis
-----------------------------
i try to run the test program in tree demo.
i have downloaded codesynthesis xsd v3.1.0 for windows and then i try compile + run the tree demo with vc++2005.
and i get this message:
driver.exe - Unable To Locate Component
This application has failed to start because xerces-c_2_8D.dll was not found. Re-installing the application may fix this problem.
where do i have to define in the tools/options/projects the place where vc++2005 can find the xerces-c-2_8D.dll ?
(this .dll is inside xerces directory).
( i have defined xsd + xerces as it written in the readme file !!!).
thank you
meir abramson
meirab@bigfoot.com
From boris at codesynthesis.com Tue Apr 8 14:55:06 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] hello codesynthesis
In-Reply-To: <00b101c899a4$a8051210$6402a8c0@m1>
References: <00b101c899a4$a8051210$6402a8c0@m1>
Message-ID: <20080408185506.GA29555@karelia>
Hi,
M writes:
> where do i have to define in the tools/options/projects the place where
> vc++2005 can find the xerces-c-2_8D.dll ?
The best way to do this is to add the directory where xerces-c-2_8D.dll
is located to your PATH environment variable. Here are the instructions
from the README:
"In the Control Panel, choose "System" and select the "Advanced" tab.
Click on the "Environment Variables" button. In the "System Variables"
list, select "Path" and add (via "Edit" button) the
";C:\projects\xerces-c-x.y.z\bin" path at the end."
After that you will need to restart VC++ for this change to take effect.
Boris
From sbalasub at qualcomm.com Thu Apr 10 17:14:24 2008
From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] regular expressions in 3.0 vs 3.1.
Message-ID:
Hi,
I have seen two changes when upgrading to XSD v3.1
1. Regular expressions,
--include-regex "Z\\..*/common/Zdistribution/Z"
This used to replace #include "../../common/File.h" to #include
"distribution/File.h"
This does not work with XSD v 3.1
Other examples are,
We need "../../types/core.h" replaced by "types/core.h"
"../../types/http.h" replaced by "types/http.h"
What should the regular expression for -include-regex be used?
2. File guards
XSD now supports -guard-prefix, which is useful.
But I have noticed that if this option is not provided, it use the $pwd
+ something for the file guard.
I am not sure why this was done when -guard-prefix option provides the
user the flexibility. I would like the default behavior for 3.0 release.
Thanks,
Shiva
From boris at codesynthesis.com Fri Apr 11 06:13:42 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] regular expressions in 3.0 vs 3.1.
In-Reply-To:
References:
Message-ID: <20080411101342.GC25596@karelia>
Hi Shiva,
Balasubramanyam, Shivakumar writes:
> --include-regex "Z\\..*/common/Zdistribution/Z"
>
> This used to replace #include "../../common/File.h" to #include
> "distribution/File.h"
There was a bug in the include regex handling code in that it allowed
matching/replacing sub-strings. This bug allowed expressions like above
to work. Here is the alternative that should work in 3.1.0 and earlier
versions:
--include-regex 'Z.*/common/(.*)Zdistribution/$1Z'
That is, you need to match the whole include path.
> We need "../../types/core.h" replaced by "types/core.h"
> "../../types/http.h" replaced by "types/http.h"
--include-regex 'Z.*/types/(.*)Ztypes/$1Z'
> XSD now supports -guard-prefix, which is useful.
>
> But I have noticed that if this option is not provided, it use the $pwd
> + something for the file guard.
>
> I am not sure why this was done when -guard-prefix option provides the
> user the flexibility. I would like the default behavior for 3.0 release.
In earlier versions the include guard was derived from the schema name
alone. This caused problems for grammars that have several schema files
with the same name but residing in different directories, for example:
foo/a.xsd
bar/a.xsd
The really bad part about this is that a user can spend a lot of time
trying to figure out what's wrong. The generated code simply stops
compiling without any useful clues to the cause.
In 3.1.0 we've extended the guard name with the directory part of the
schema being compiled. Thus if you invoke XSD like so:
$ xsd cxx-tree a.xsd
You will get A_HXX as a guard. But if you do it like this:
$ xsd cxx-tree foo/a.xsd
$ xsd cxx-tree bar/a.xsd
Then you get FOO_A_HXX and BAR_A_HXX as guards. One negative consequence
of this change, which I believe you are observing, is that if you compile
your schema with an absolute path, then you will get all the leading
directories in the guard. We, however, decided that this is a lesser
of the two evils.
To get the original behaviors (or close to it), you can specify the
--guard-prefix options which overrides the directory part of the guard.
For example, you can do:
$ xsd cxx-tree --guard-prefix "guard" /long/path/to/a.xsd
And get GUARD_A_HXX as a guard.
Boris
From lvkun2006 at gmail.com Fri Apr 11 02:41:22 2008
From: lvkun2006 at gmail.com (kun lv)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
Message-ID: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
SGksClRoZSBjb250ZW50IG9mIFBhcmFtLnhzZCBpczoKPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNv
ZGluZz0idXRmLTgiPz4KPHhzOnNjaGVtYSB4bWxuczp4cz0iaHR0cDovL3d3dy53My5vcmcvMjAw
MS9YTUxTY2hlbWEiCmVsZW1lbnRGb3JtRGVmYXVsdD0icXVhbGlmaWVkIiBhdHRyaWJ1dGVGb3Jt
RGVmYXVsdD0idW5xdWFsaWZpZWQiPgogPHhzOmVsZW1lbnQgbmFtZT0iUGFyYW0iPgogIDx4czpj
b21wbGV4VHlwZT4KICAgPHhzOnNlcXVlbmNlPgogICAgPHhzOmVsZW1lbnQgbmFtZT0iYXJnMSIg
dHlwZT0ieHM6c3RyaW5nIi8+CiAgIDwveHM6c2VxdWVuY2U+CiAgPC94czpjb21wbGV4VHlwZT4K
IDwveHM6ZWxlbWVudD4KPC94czpzY2hlbWE+CgpBbmQgSSBnZW5lcmF0ZSBjb2RlIHdpdGggdGhl
IFhTRCx0aGUgY29tbWFuZCBpcyA6CnhzZCBjeHgtdHJlZSAtLWh4eC1zdWZmaXggLmggLS1jeHgt
c3VmZml4IC5jcHAgLS1nZW5lcmF0ZS1zZXJpYWxpemF0aW9uCi0tY2hhci10eXBlIHdjaGFyX3Qg
LS1nZW5lcmF0ZS1kZWZhdWx0LWN0b3IgLS1jeHgtcHJvbG9ndWUgIiNpbmNsdWRlCiIic3RkYWZ4
LmgiIiIgVGVzdC54c2QgUGFyYW0ueHNkCgpBbmQgdGhlIHNhbXBsZSBjb2RlIGlzOgogICAgeG1s
X3NjaGVtYTo6bmFtZXNwYWNlX2luZm9tYXAgbWFwOwogICAgUGFyYW0gcGFyYW07CiAgICBwYXJh
bS5hcmcxKCBMIs7SIiApOyAgICAvLyDO0iBpcyBhIGNoaW5lc2UgY2hhcmFjdGVyIG1lYW5zIG1l
CiAgICBzdHJpbmdzdHJlYW0gb3NzcGFyYW07CiAgICBQYXJhbV8ob3NzcGFyYW0scGFyYW0sbWFw
LEVOQ09ESU5HLHhtbF9zY2hlbWE6OmZsYWdzOjpub194bWxfZGVjbGFyYXRpb24KKTsKICAgIHN0
cmluZyBzdHJQYXJhbSggb3NzcGFyYW0uc3RyKCkgKTsKIFdoZW4gaSBydW4gdGhpcyBjb2RlLCB0
aGUgY29udGVudCBvZiBzdHJQYXJhbSBpcwogICAgPFBhcmFtPgogPGFyZzE+5og/L2FyZzE+Cjwv
UGFyYW0+CgpJIHRyaWVkIHNlcnZlciBtZXRob2QgdG8gY29udmVydCB0aGUgc3RyaW5nIHRvIHdz
dHJpbmcuIEJ1dCBpdCBkb2Vzbid0IHdvcmsuCkhvdyBjYW4gaSBkZWFsIHdpdGggbWVzc3kgY29k
ZT8gSXMgdGhlcmUgYW55IGV4YW1wbGU/ClRoYW5rIHlvdSB2ZXJ5IG11Y2ghCg==
From boris at codesynthesis.com Mon Apr 14 03:45:17 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
Message-ID: <20080414074517.GA4703@karelia>
Hi,
kun lv writes:
> xml_schema::namespace_infomap map;
> Param param;
> param.arg1( L"??" ); // ?? is a chinese character means me
> stringstream ossparam;
> Param_(ossparam,param,map,ENCODING,xml_schema::flags::no_xml_declaration
> );
> string strParam( ossparam.str() );
>
> When i run this code, the content of strParam is
>
> ???/arg1>
>
What is the ENCODING argument in the call to Param_? You should
understand that the resulting XML can be encoded using different
character encodings. If it is, say, UTF-8 then you can treat the
resulting XML as string and your Chinese character will be encoded
as a multi-byte sequence. If, however, you specify, say UTF-32 as
the encoding then the resulting XML cannot be treated as a string
-- it will most likely have '\0' bytes all over it.
So before you figure out how to convert your XML fragment to
std::wstring, you need to decide which character encoding you
want your XML to be.
Boris
From lvkun2006 at gmail.com Mon Apr 14 05:30:53 2008
From: lvkun2006 at gmail.com (kun lv)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <20080414074517.GA4703@karelia>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
Message-ID: <32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
Sorry, I forgot maro define before the code.
#define ENCODING L"UTF-16"
I have solve the serializtion problem with a simple method(I think maybe not
the right method).
I wrote a function:
wstring EncodestringTowstring(string const &strSource)
{
size_t stSource_size = strSource.size();
const char* str = strSource.c_str();
const wchar_t* wstr = (const wchar_t*)str;
wstring wstrTemp(wstr);
wstring wstrResult( wstrTemp.begin(), wstrTemp.begin() + stSource_size/2 );
return wstrResult;
}
The result is right.
But when i try to parse the document, the program throw out exception:
instance document parsing failed
The parse code:
stringstream issparam(strParam);
wstring strarg1;
try
{
std::auto_ptr< param > paramptr = param_( issparam,
ENCODING,xml_schema::flags::dont_validate );
strarg1 = paramptr->arg1();
}
catch (const xml_schema::exception& e)
{
CString strError( e.what() );
AfxMessageBox( strError );
}
The content of strParam is
content
when the text is all english character, the code can work out. But when I
replace the "content" with some chinese character, it throw out exception:
instance document parsing failed
How can I deal with this problem?
Thank you very much.
2008/4/14, Boris Kolpackov :
>
> Hi,
>
> kun lv writes:
>
> > xml_schema::namespace_infomap map;
> > Param param;
> > param.arg1( L"??" ); // ?? is a chinese character means me
> > stringstream ossparam;
> >
> Param_(ossparam,param,map,ENCODING,xml_schema::flags::no_xml_declaration
> > );
> > string strParam( ossparam.str() );
> >
> > When i run this code, the content of strParam is
> >
> > ???/arg1>
> >
>
> What is the ENCODING argument in the call to Param_? You should
> understand that the resulting XML can be encoded using different
> character encodings. If it is, say, UTF-8 then you can treat the
> resulting XML as string and your Chinese character will be encoded
> as a multi-byte sequence. If, however, you specify, say UTF-32 as
> the encoding then the resulting XML cannot be treated as a string
> -- it will most likely have '\0' bytes all over it.
>
> So before you figure out how to convert your XML fragment to
> std::wstring, you need to decide which character encoding you
> want your XML to be.
>
> Boris
>
From Ryan.Prather at peterson.af.mil Mon Apr 14 15:25:43 2008
From: Ryan.Prather at peterson.af.mil (Prather, Ryan C SSgt USAF AFSPC SYAG/SED)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Error Logging
Message-ID:
Is there a function that will convert the exception object to a STL
string object? We currently have a Error class that does all of the
error handling that need to be done. It basically just sends a string
to a file with a couple of other parameters. The function just takes
two arguments an integer (error code) and string (error message). The
string can be no longer than 60 characters so I need to find a way to
reformat the exceptions that XSD provides to something that is 60
characters or less. Thanks
Ryan
From boris at codesynthesis.com Mon Apr 14 16:57:56 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Error Logging
In-Reply-To:
References:
Message-ID: <20080414205756.GA16095@karelia>
Hi Ryan,
Prather, Ryan C SSgt USAF AFSPC SYAG/SED writes:
> Is there a function that will convert the exception object to a STL
> string object?
Yes, you can use the std::ostringstream stream for that:
#include
catch (const xml_schema::parsing& e)
{
std::ostringstream ostr;
ostr << e;
std::string str = ostr.str ();
}
> The function just takes two arguments an integer (error code) and
> string (error message). The string can be no longer than 60
> characters so I need to find a way to reformat the exceptions that
> XSD provides to something that is 60 characters or less.
I don't think you can do this without potentially loosing some
information. The xml_schema::parsing exception contains a list
of parsing errors and warnings. The above code will save them
all at once into the string. Instead you can iterate over them
and log one at a time:
catch (const xml_schema::parsing& e)
{
const xml_schema::diagnostics& d = e.diagnostics ();
for (xml_schema::diagnostics::const_iterator i = d.begin ();
i != d.end (); ++i)
{
const xml_schema::error& er = *i;
const std::string& msg = er.message ();
}
}
For more information on the xml_schema::parsing, xml_schema::diagnostics
and xml_schema::error types see Section 7.3, "Error Handling" in the
C++/Parser Getting Started Guide (I assume you are still using the
C++/Parser mapping):
http://codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#7.3
Boris
From boris at codesynthesis.com Tue Apr 15 03:27:36 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
<32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
Message-ID: <20080415072736.GB17491@karelia>
Hi,
kun lv writes:
> #define ENCODING L"UTF-16"
I assume your wchar_t is 16-bit wide then (e.g., because you are
on Windows and using MS VC++).
> I have solve the serializtion problem with a simple method(I think maybe
> not the right method).
Yes, I wouldn't do it this way.
> But when i try to parse the document, the program throw out exception:
> instance document parsing failed
This is most likely because your document does not contain XML
declaration which specifies that it is in UTF-16. If encoding
is not specified then the parsers must assume it is UTF-8. I
suggest that you remove the no_xml_declaration flag.
Alternatively, you can override the encoding assumed by the
parser but for that you will need to do XML-to-DOM parsing
yourself. See XSD and Xerces-C++ documentation for more
information on this method.
Boris
From boris at codesynthesis.com Tue Apr 15 04:51:09 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <000301c89ed5$4c958870$e5c09950$@com>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
<32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
<20080415072736.GB17491@karelia>
<000301c89ed5$4c958870$e5c09950$@com>
Message-ID: <20080415085109.GA17802@karelia>
Hi,
lvkun writes:
> But When I remove the flag(xml_schema::flags::no_xml_declaration), it still
> throw out the exception:
> instance document parsing failed
Try to catch and print the exception:
try
{
// parsing function call goes here
}
catch (const xml_schema::exception& e)
{
wcerr << e << endl;
}
This will give you more information on what's going on.
Boris
From lvkun2006 at gmail.com Tue Apr 15 05:17:05 2008
From: lvkun2006 at gmail.com (lvkun)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <20080415085109.GA17802@karelia>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
<32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
<20080415072736.GB17491@karelia>
<000301c89ed5$4c958870$e5c09950$@com>
<20080415085109.GA17802@karelia>
Message-ID: <000401c89ed9$7b262b50$717281f0$@com>
Thank you!
The information of exception is :
UTF-16:1:57 warning: Encoding (UTF-16, from XMLDecl or manually set)
contradicts
the auto-sensed encoding, ignoring it
UTF-16:1:57 error: An exception occurred! Type:UTFDataFormatException,
Message:i
nvalid byte 2 () of a 2-byte sequence.
What does it mean?
From boris at codesynthesis.com Tue Apr 15 05:04:06 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <000401c89ed9$7b262b50$717281f0$@com>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
<32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
<20080415072736.GB17491@karelia>
<000301c89ed5$4c958870$e5c09950$@com>
<20080415085109.GA17802@karelia>
<000401c89ed9$7b262b50$717281f0$@com>
Message-ID: <20080415090406.GC17802@karelia>
Hi,
lvkun writes:
> UTF-16:1:57 warning: Encoding (UTF-16, from XMLDecl or manually set)
> contradicts the auto-sensed encoding, ignoring it
>
> UTF-16:1:57 error: An exception occurred! Type:UTFDataFormatException,
> Message:invalid byte 2 () of a 2-byte sequence.
>
> What does it mean?
This means that there is something wrong with your XML document
probably because of the questionable manipulations you've performed
while converting it from string to wstring.
Can you explain why you need to convert it to wstring? Can't it
be simply saved directly to a file and then read from this file?
Boris
From lvkun2006 at gmail.com Tue Apr 15 04:47:09 2008
From: lvkun2006 at gmail.com (lvkun)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <20080415072736.GB17491@karelia>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
<32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
<20080415072736.GB17491@karelia>
Message-ID: <000301c89ed5$4c958870$e5c09950$@com>
Thank you very much!
But When I remove the flag(xml_schema::flags::no_xml_declaration), it still
throw out the exception:
instance document parsing failed
From lvkun2006 at gmail.com Tue Apr 15 05:57:34 2008
From: lvkun2006 at gmail.com (lvkun)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <20080415090406.GC17802@karelia>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
<32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
<20080415072736.GB17491@karelia>
<000301c89ed5$4c958870$e5c09950$@com>
<20080415085109.GA17802@karelia>
<000401c89ed9$7b262b50$717281f0$@com>
<20080415090406.GC17802@karelia>
Message-ID: <000501c89edf$2396a530$6ac3ef90$@com>
Thank you!
In the serialization process(I have to put some Chinese character into some
string-type element) :
When I use "UTF-8"(char-type: wchar_t ), the output have messy code.
When I use "UTF-8"(char-type:char), it throw out
exception(invalid_utf8_string) .
When I use "UTF-16"(char-type:wchar_t), the string I get is
unexpected. I need to convert the string to CString(MFC). So I tried to
convert it to wstring first.
From boris at codesynthesis.com Wed Apr 16 04:00:29 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] A Question about Unicode Character
In-Reply-To: <000501c89edf$2396a530$6ac3ef90$@com>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
<32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
<20080415072736.GB17491@karelia>
<000301c89ed5$4c958870$e5c09950$@com>
<20080415085109.GA17802@karelia>
<000401c89ed9$7b262b50$717281f0$@com>
<20080415090406.GC17802@karelia>
<000501c89edf$2396a530$6ac3ef90$@com>
Message-ID: <20080416080029.GB20654@karelia>
Hi,
lvkun writes:
> I need to convert the string to CString(MFC). So I tried to convert
> it to wstring first.
Ok, here is what you can do (this method is Windows-specific). You
will need to first serialize the object model to DOMDocument. Note
also that you will need to initialize and terminate the Xerces-C++
runtime. Using the example from your previous email this can look
like this:
#include
#include
int main ()
{
xercesc::XMLPlatformUtils::Initialize ();
{
xml_schema::dom::auto_ptr doc = Param_(
param, map);
}
xercesc::XMLPlatformUtils::Terminate ();
}
Once you get the DOM document, you can use the Xerces-C++ DOMWriter's
writeToString function to serialize this document to XMLCh string
which, on Windows, is the same as wchar_t. There is a piece of code
in Q 3.2 in the C++/Tree Mapping FAQ that shows how to do it except
that it serializes to std::ostream instead of XMLCh string:
http://wiki.codesynthesis.com/Tree/FAQ
To make it write to wstring instead of ostream you can replace this
part:
// Adapt ostream to format target and serialize.
//
xml::dom::ostream_format_target oft (os);
writer->writeNode (&oft, doc);
eh.throw_if_failed > ();
With the following code:
XMLCh* str = writer->writeToString (doc);
eh.throw_if_failed > ();
std::wstring wstr (str);
XMLString::release (&str);
Boris
From wanghai_cwq at 163.com Wed Apr 16 06:03:43 2008
From: wanghai_cwq at 163.com (wanghai_cwq)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] GML parser
Message-ID: <20517436.1205471208340223854.JavaMail.coremail@bj163app88.163.com>
Dear MR.
I hope you will not confuse that my poor English,so I just say the sample and brief words to my application.
I want to get a latest GML parser version with C++ to my graduation design which is generic better,so I wish get the codes and the code's notes details.
Thanks for you help.
yours.
Wanghai C
04/16
From boris at codesynthesis.com Thu Apr 17 07:50:06 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] GML parser
In-Reply-To: <20517436.1205471208340223854.JavaMail.coremail@bj163app88.163.com>
References: <20517436.1205471208340223854.JavaMail.coremail@bj163app88.163.com>
Message-ID: <20080417115006.GA23898@karelia>
Hi Wanghai,
wanghai_cwq writes:
> I want to get a latest GML parser version with C++ to my graduation
> design which is generic better,so I wish get the codes and the code's
> notes details.
I understand you need a C++ parser for GML. The C++/Tree Mapping can
be used for that:
http://codesynthesis.com/products/xsd/c++/tree/
For some additional information on using this particular schema, see
the GML Wiki page:
http://wiki.codesynthesis.com/Schemas/GML
Boris
From sbalasub at qualcomm.com Fri Apr 18 17:27:07 2008
From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Multiple Serialization Library
Message-ID:
Boris,
We would like to see if we can have two serialization libraries for a
single interface.
For example, I want to have XML and Boost Serialization. Is this
possible?
XML will be used for logging purposes and Boost serializer or a custom
binary serializer would be used for over the wire.
If this is not already supported, how feasible is it to add this
feature.
Thanks,
Shiva
From boris at codesynthesis.com Mon Apr 21 06:08:19 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Multiple Serialization Library
In-Reply-To:
References:
Message-ID: <20080421100819.GC29651@karelia>
Hi Shiva,
Balasubramanyam, Shivakumar writes:
> For example, I want to have XML and Boost Serialization. Is this
> possible?
Yes it is possible, though the code supporting XML and Boost
serialization will be in the same source files (in other words
you won't be able to have the object model in one library, XML
serialization in another, and Boost serialization in yet another).
You can also have several binary formats (e.g., Boost and XDR)
available at the same time. For that simply repeat the
--generate-{insertion,extraction} options for each stream type.
Boris
From sbalasub at qualcomm.com Mon Apr 21 11:39:23 2008
From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Multiple Serialization Library
In-Reply-To: <20080421100819.GC29651@karelia>
References:
<20080421100819.GC29651@karelia>
Message-ID:
Boris,
For now, that should be great.
I have a number of users requesting for the separation of these modules.
I know we have discussed this before and hope we can get it sometime in
the near future :-)
On a separate note, is there a link to indicate what features you have
in store for future releases?
Are you planning to use C++ 0x features on the generated code?
Thanks,
Shiva
-----Original Message-----
From: Boris Kolpackov [mailto:boris@codesynthesis.com]
Sent: Monday, April 21, 2008 3:08 AM
To: Balasubramanyam, Shivakumar
Cc: xsd-users@codesynthesis.com
Subject: Re: [xsd-users] Multiple Serialization Library
Hi Shiva,
Balasubramanyam, Shivakumar writes:
> For example, I want to have XML and Boost Serialization. Is this
> possible?
Yes it is possible, though the code supporting XML and Boost
serialization will be in the same source files (in other words
you won't be able to have the object model in one library, XML
serialization in another, and Boost serialization in yet another).
You can also have several binary formats (e.g., Boost and XDR)
available at the same time. For that simply repeat the
--generate-{insertion,extraction} options for each stream type.
Boris
From boris at codesynthesis.com Mon Apr 21 13:44:55 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Multiple Serialization Library
In-Reply-To:
References:
<20080421100819.GC29651@karelia>
Message-ID: <20080421174455.GA3934@karelia>
Hi Shiva,
Balasubramanyam, Shivakumar writes:
> I have a number of users requesting for the separation of these modules.
> I know we have discussed this before and hope we can get it sometime in
> the near future :-)
What is the goal of this separation (e.g., do they want to avoid
runtime dependency (e.g., if Boost serialization is not used then
the application is not linked to boost) or do they want to also
avoid compile-time dependencies (e.g., if Boost serialization
is not used then Boost headers are not required to build the
application)? It is easier to support the former than the latter
(e.g., we could generate the implementation code for XML
serialization, Boost serialization, etc., into separate source
files but the generated header will still include declarations
for these things).
> On a separate note, is there a link to indicate what features you have
> in store for future releases?
There is such a page, though it only includes high-impact features
(like new mappings):
http://www.codesynthesis.com/projects/xsd/documentation/future.xhtml
There is also a number of smaller features in store that enhance
certain areas or improve the overall quality. We also work on the
"underlying technologies", e.g., Xerces-C++ 3.0.0 which will have
a number of XML Schema-related bugs fixed, as well as XQilla which
provides XPath 2.0 support (in the next release there will be an
example on how to use XPath together with the C++/Tree mapping).
> Are you planning to use C++ 0x features on the generated code?
Hm, we don't have any immediate plans to use 0x features, especially
since, I assume, compiler support for them is not very wide-spread.
However, if there is a feature that the community feels makes their
lives much easier then we are always open to add a compiler option.
Boris
From lvkun2006 at gmail.com Tue Apr 22 00:08:42 2008
From: lvkun2006 at gmail.com (kun lv)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] custom type
Message-ID: <32b74eaf0804212108r1a92e31cr59bf17fd0cde662a@mail.gmail.com>
Hi,
I have a question with --custom-type option.
For example, I have a xsd file like this:
I just want to use string instead of xs:anyType, with the option
"--custom-type anyType=string", but It does't work out. Could you tell me
how to deal with this problem?
Thank you very much!
From boris at codesynthesis.com Tue Apr 22 02:42:56 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] custom type
In-Reply-To: <32b74eaf0804212108r1a92e31cr59bf17fd0cde662a@mail.gmail.com>
References: <32b74eaf0804212108r1a92e31cr59bf17fd0cde662a@mail.gmail.com>
Message-ID: <20080422064256.GA5409@karelia>
Hi,
kun lv writes:
>
> [...]
>
> I just want to use string instead of xs:anyType, with the option
> "--custom-type anyType=string", but It does't work out.
anyType is a somewhat special type and you cannot re-map it to string.
Here is the excerpt from C++/Tree Customization Guide[1]:
"The xsd:anyType type, which is mapped to xml_schema::type, is a base
type for every generated and built-in type in the C++/Tree mapping.
Because of this property it is often useful to customize this type
in order to provide a common functionality to all types in an object
model. One special requirement when customizing anyType is that you
should always inherit your version from the default implementation.
For an example on how to customize anyType refer to the comments
example which can be found in the examples/cxx/tree/custom/
directory of the XSD distribution."
I suggest that you also read the whole guide if you are planning
to customize types.
The way to handle this particular situation is to customize the
outer type that contains the arg0 element. You can then override
its parsing c-tor (and serialization operator, if required) and
extract the data for arg0 element as string. You can also add
accessors and modifiers that use string as a type. For more
information on how to implement parsing c-tor, etc., see the
custom/wildcard example.
[1] http://wiki.codesynthesis.com/Tree/Customization_guide
Boris
From lvkun2006 at gmail.com Tue Apr 15 06:27:20 2008
From: lvkun2006 at gmail.com (lvkun)
Date: Sun Oct 11 15:34:02 2009
Subject: =?gb2312?B?tPC4tDogW3hzZC11c2Vyc10gQSBRdWVzdGlvbiBhYm91dCBVbmljb2RlIEM=?=
=?gb2312?B?aGFyYWN0ZXI=?=
In-Reply-To: <20080415090406.GC17802@karelia>
References: <32b74eaf0804102341i43897f31l18c0a53eaa25197@mail.gmail.com>
<20080414074517.GA4703@karelia>
<32b74eaf0804140230u67504c7bsa48e93ffa98d35cf@mail.gmail.com>
<20080415072736.GB17491@karelia>
<000301c89ed5$4c958870$e5c09950$@com>
<20080415085109.GA17802@karelia>
<000401c89ed9$7b262b50$717281f0$@com>
<20080415090406.GC17802@karelia>
Message-ID: <000601c89ee3$4bd90de0$e38b29a0$@com>
I have finally solve this problem with some MFC macro. Thank you for your
patient explanation. I really appreciate for what you have done.
From thomas.walter at de.gm.com Wed Apr 30 03:44:24 2008
From: thomas.walter at de.gm.com (Thomas Walter)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Multiple XML files with identical element names
Message-ID:
Hello,
I want to parse multiple independent XML files using XSD. When I generate
the object model of either XSD file I will later on get linker errors of
duplicated objects. The issue is that the schemas use some same names for
certain elements, e.g. each schema file includes a definition for revision
log. This results in duplicated functions/objects. Is there a way to let
the xsd compiler know to use a certain prefix for the generated code for
one schema, a certain option?
Here is an extract that is identical in either schema file:
Thanks a lot in advance,
Thomas
From boris at codesynthesis.com Wed Apr 30 03:37:09 2008
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Multiple XML files with identical element names
In-Reply-To:
References:
Message-ID: <20080430073709.GA13806@karelia>
Hi Thomas,
Thomas Walter writes:
> I want to parse multiple independent XML files using XSD. When I generate
> the object model of either XSD file I will later on get linker errors of
> duplicated objects. The issue is that the schemas use some same names for
> certain elements, e.g. each schema file includes a definition for revision
> log. This results in duplicated functions/objects. Is there a way to let
> the xsd compiler know to use a certain prefix for the generated code for
> one schema, a certain option?
The way to resolve this is to place the generated code into different C++
namespaces. For example, if you have a.xsd and b.xsd with identically-
named types then you can compile them like so:
xsd cxx-tree --namespace-map =foo a.xsd
xsd cxx-tree --namespace-map =bar b.xsd
This will result in the generated C++ code for a.xsd being placed into the
foo C++ namespace and for b.xsd -- into bar. If your schemas specify target
namespaces, then you will need to add that to the --namespace-map option,
for example:
xsd cxx-tree --namespace-map http://www.example.com/a=foo a.xsd
For more information on the --namespace-map option see the XSD Compiler
Command Line Manual:
http://codesynthesis.com/projects/xsd/documentation/xsd.xhtml
Boris
From atteeela at gmail.com Wed Apr 30 09:56:36 2008
From: atteeela at gmail.com (Attila)
Date: Sun Oct 11 15:34:02 2009
Subject: [xsd-users] Creating elements in code
Message-ID: <4aeb04aa0804300656v104b96d3p34788241391a2692@mail.gmail.com>
Hi,
I am interested in creating objects on a type basis only without specifying
a complete XML document.
So for example, assume that I have an XSD like so:
Can I provide an XML snippet instead of an entire XML document like this:
jon
rick
hello world
no text
And feed it into the Code Synthesis like this:
auto_ptr c = note("noteSnippet.xml");
Furthermore, could I then take these snippets and use it to construct a
complete XML document?
Thanks!
--
Attila
Software Developer
atteeela@gmail.com