[xsd-users] Compiler errors occurred in the generated *.hxx files from CodeSynthesis 3.2

William Canton stargate625 at gmail.com
Mon Apr 4 13:42:08 EDT 2011


After some trials and errors, I found out that the previous problem was
caused by the missing targetNamespace declarations in the other XML schema
files.  Today, I was able to generate the code using namespace mapping.  The
generated files contained the correct namespaces based on the specified
mapping key and value pairs.

However, having namespace mapping still does not solve the recurrent problem
of error C2338:  'FileSystemType'.  You have seen this before in my previous
email.  So, this build error has nothing to do with the namespace conflicts
among two or more CodeSynthesis generated files because only the header
generated from the attached schema references the FileSystemType
declaration.

But now, the xerces parser gave me yet another run time exception of memory
access violation inside the following call to parseURI:

          auto_ptr<DOMDocument> doc (
            parser->parseURI (string (uri).c_str ()));

which is contained in this template:

        template <typename C>
        auto_ptr<xercesc::DOMDocument>
        parse (const std::basic_string<C>& uri,
               xercesc::DOMErrorHandler& eh,
               const properties<C>& prop,
               unsigned long flags)

within the file named "parsing-source.txx" with the include path of
"include/xsd/cxx/xml/dom.  This might be one of the CodeSynthesis XSD
library template header.

Boris, if you like to reproduce this anomaly on your end, attached is the
standard XML schema file to use.

Also, I am not sure if the generated code has any conflict with this header
called "PlatformUtils.hpp" from Apache (see the attachment.  This file is
part of the XSD xercesc distribution.

By the way, I still use the CodeSynthesis version 3.2.  You should use the
same version to reproduce the runtime exception if you can't reproduce it in
3.3.





On Mon, Mar 28, 2011 at 3:49 PM, William Canton <stargate625 at gmail.com>wrote:

> It turned out that CodeSynthesis didn't work when there existed an
> attribute targetNamespace="http://www.example.org/any" in the xs:schema
> root element.  So, I had to remove those extra attributes from:
>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.example.org/any"
> xmlns:tns="http://www.example.org/any"
> elementFormDefault="qualified">
> ...
> </schema>
>
> into this:
>
> <schema xmlns="http://www.w3.org/2001/XMLSchema">
> ...
> </schema>
>
> After this change, CodeSynthesis could generate the code for all schemas.
>
> But this brought back to the same problem as before:
>
> error C2838: 'FileSystemType' : illegal qualified name in member
> declaration
>
> That seemed like an NP-Compete because the --namespace-Map option didn't
> seem to work properly and an application could not use more than once schema
> files.
>
>
>
> On Mon, Mar 28, 2011 at 2:10 PM, William Canton <stargate625 at gmail.com>wrote:
>
>>
>> It seemed like the only namespace generated by CodeSynthesis was this:
>>
>> namespace xml_schema
>>
>> in the codf.hxx header file.  Why couldn't it even generate the specified
>> namespace in the mapping like:
>>
>> namespace codf
>>
>>
>>
>>
>> On Mon, Mar 28, 2011 at 2:02 PM, William Canton <stargate625 at gmail.com>wrote:
>>
>>> If I had multiple namespace mappings like these:
>>>
>>> xsd.exe cxx-tree  --output-dir ..\Generated --hxx-suffix .hxx
>>> --cxx-suffix .cxx --ixx-suffix .ixx --fwd-suffix -fwd.hxx --namespace-map
>>> http://www.sample.com/config=config --namespace-map
>>> http://www.sample.com/msg=msg --namespace-map
>>> http://www.sample.com/codf=codf --generate-serialization
>>>
>>> CodeSynthesis only generated the .hxx and .cpp for the last one.  In this
>>> case, ony the codf.hxx and codf.cpp files were generated.  For the other
>>> two, it only generated the forward declarations even though I didn't use the
>>> generate forward flag.
>>>
>>> Any idea why CodeSynthesis only created the .hxx and .cpp files for the
>>> last namespace mapping in the list?
>>>
>>>
>>> On Mon, Mar 28, 2011 at 12:58 PM, William Canton <stargate625 at gmail.com>wrote:
>>>
>>>> I tried to remove the elementFormDefault="qualified" from the schema.
>>>>  But it build problem persisted.
>>>>
>>>>
>>>> On Mon, Mar 28, 2011 at 12:51 PM, William Canton <stargate625 at gmail.com
>>>> > wrote:
>>>>
>>>>> My codf schame file contains this on the top (second line):
>>>>>
>>>>> xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>>>> elementFormDefault="qualified">
>>>>>
>>>>> Should I remove the elementFormDefault="qualified"?  This could have
>>>>> caused the problem, I think.
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Mar 28, 2011 at 12:35 PM, Boris Kolpackov <
>>>>> boris at codesynthesis.com> wrote:
>>>>>
>>>>>> Hi William,
>>>>>>
>>>>>> William Canton <stargate625 at gmail.com> writes:
>>>>>>
>>>>>> > Oops! I didn't use the correct syntax last time in the
>>>>>> --namespace-Map
>>>>>> > option.  I should have used:
>>>>>> >
>>>>>> > --namespace-map xml_schema=codf
>>>>>>
>>>>>> I am not so sure. This would be correct if your schema had this in the
>>>>>> root <xs:schema> element:
>>>>>>
>>>>>> targetNamespace="xml_schema"
>>>>>>
>>>>>> Looking at your original code fragment, I don't think you have this.
>>>>>> If your schema doesn't have the targetNamespace attribute, then the
>>>>>> correct option is:
>>>>>>
>>>>>> --namespace-map =codf
>>>>>>
>>>>>> That is, it maps empty namespace (global scope) to codf.
>>>>>>
>>>>>> If you still cannot figure this out, please send me your schema (off
>>>>>> list) and I will take a look.
>>>>>>
>>>>>> Boris
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OC-CoDF-I02.xsd
Type: application/octet-stream
Size: 81185 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20110404/6cff6e6d/OC-CoDF-I02-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PlatformUtils.hpp
Type: text/x-c++hdr
Size: 33593 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20110404/6cff6e6d/PlatformUtils-0001.hpp


More information about the xsd-users mailing list