Hi Paul,
Have you tried the CVS version? I believe it fixes your problem as it
prepends the name of the parent structure to the attribute name when
creating the type-safe enumeration.
Thanks,
--Keith
Paul van Hagen wrote:
>
> Hello,
>
> I ran into an interesting feature and I don't know quite how to deal with
> it.
>
> I have developed a schema "quantities.xsd" with quantities specific to
> our domain. The quantities have been defined as complexTypes as they
> needed to be extended with unit attributes as in the following example:
>
> <xsd:complexType name="Density">
> <xsd:simpleContent>
> <xsd:extension base="PositiveDouble">
> <xsd:attribute name="uom" default="kg/cub.m">
> <xsd:simpleType>
> <xsd:restriction base="xsd:string">
> <!-- SI uom -->
> <xsd:enumeration value="kg/cub.m"/>
> <!-- US uom -->
> <xsd:enumeration value="g/cc"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:attribute>
> </xsd:extension>
> </xsd:simpleContent>
> </xsd:complexType>
>
> <xsd:complexType name= "Thickness">
> <xsd:simpleContent>
> <xsd:extension base="NonNegativeDouble">
> <xsd:attribute name="uom" default="m">
> <xsd:simpleType>
> <xsd:restriction base="xsd:string">
> <!-- SI uom -->
> <xsd:enumeration value="m"/>
> <!-- US uom -->
> <xsd:enumeration value="ft"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:attribute>
> </xsd:extension>
> </xsd:simpleContent>
> </xsd:complexType>
>
> I have put the quantities in a separate namespace and updated the
> castorbuilder.properties file to map the namespace to a package. Now the
> source generator nicely creates all the classes for all the quantities,
> however, it creates a "types" directory in the package dir that defines
> the "UomType" but with the enumeration restriction of the last quantity
> in the schema. That's because the source generator overwrites the file
> according the information in the last attribute definition.
>
> When validating an XML instance document, it will validate against the
> attribute values in the class Uomtype which has a hashtable with only the
> values "m" and "ft". This causes an exception if the XML element has
> attribute "uom=kg/cub.m".
>
> To solve this I could either put all units in a single attribute ref, but
> I don't like that very much, because as it is the units are tightly
> associated to the quantity. I could also prefix the attribute name to be
> "d_uom" for the "Density" quantity and "t_uom" for the "Thickness"
> quantity type, but I don't like that very much either.
>
> Is there any other way I could solve this? Ideally, the "UomType" class
> would be nested inside the quantity class to make it a distinct type
> belonging that quantity to which you can refer to as "Density.UomType" or
> "Thickness.UomType".
>
> TIA
> Paul
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev