[xsd-users] Problem with extension of complexType with simpleContent with required attribute

Ray Lischner rlischner at proteus-technologies.com
Mon Jun 16 10:09:53 EDT 2008


The fix works too well. Suppose type A extends B, which extends xsd:string. We have customized B so that the implementation actually derives from fundamental_base<unsigned>. (Specifically, we call B CUnsigned. It lets us write C-style hex numbers in the XML document, while using unsigned integers in the code. These particular elements are bit masks and are easier to express in hexadecimal. Our existing code uses uint32_t, so using hexBinary in the schema would still require a customized type to perform the conversions.)
 
Before we applied this patch, the code for A's constructor would take a B as an argument, which was fine because B has all our customizations. With the fix, A's constructor now takes an xsd:string, which is bad because it bypasses our customizations. (On the other hand, some of our types now have attributes, which is why we needed the fix in the first place.)
 
I tried the --generate-from-base-ctor switch, but it doesn't help. I see that the base class needs to have at least one required member, which makes sense to avoid generating two constructors with identical arguments.
 
Is there some way, other than customizing A, to recover the behavior of constructing an A from a B, while retaining the proper construction of A when B has attributes?
 
Ray Lischner,
Senior Member of Technical Staff
133 National Business Pkwy, Ste 150         t. 443.539.3448
Annapolis Junction, MD 20701                c. 301.377.7390
rlischner at proteus-technologies.com          f. 443.539.3370

This electronic message and any files transmitted with it contain information which may be privileged and/or proprietary. The information is intended for use solely by the intended recipient(s). If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of this information is prohibited. If you have received this electronic message in error, please advise the sender by reply email or by telephone (443.539.3400) and delete the message. 

________________________________

From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Wed 6/11/2008 12:41 PM
To: Ray Lischner
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Problem with extension of complexType with simpleContent with required attribute



Hi Ray

Ray Lischner <rlischner at proteus-technologies.com> writes:

> It seems that Code Synthesis gives Derived's constructor all the
> inherited attributes, just as it would for a complexContent type.
> The problem is the first argument, which uses the immediate base
> class. In this case, the type of the first argument should be
> xml_schema::string.

Right, this is a bug in 2.3.1.


> If this problem has already been fixed, can you give me any hints
> as to how to patch our 2.3.1 version for the time being--until we
> can move forward to 3.1?

There is no such problem in 3.1.0 -- the constructor has string as
a base. The part of code that handles this in 3.1.0 is quite a bit
different compared to 2.3.1 so there is not way to backport anything
from 3.1.0. I've come up with a patch for 2.3.1 that should fix the
problem:

http://codesynthesis.com/~boris/tmp/xsd-2.3.1-ultimate-base.patch

I haven't tested it (don't have the 2.3.1 dependencies built) but
I am pretty sure it works. If it doesn't then let me know and I
will build everything and take a look.

Boris





More information about the xsd-users mailing list