|
Replies:
7
-
Last Post:
Nov 1, 2007 1:06 AM
by: utkarsh_shah
|
|
|
|
|
|
|
Having a problem type mapping union with xjc & JAX-B 2.0
Posted:
Mar 2, 2006 4:50 PM
|
|
|
Hi
Hope someone can help. I have several large wsdl/xsd files to compile with xjc, however xsd simpleType's that use union do not seem to generate the expected output eg the cut down file below (includes a definitions.xsd but that's not the problem).
I get 23 java files generated, but LayerRateT for example contains the expected content in the comment field but the class definition misses it.
If I cut out the union construct and leave only the enumerations then xjc generates enums as I expect.
I have tried setting various globalBindings but have got nowhere. Am I missing something, any ideas?
(xjc -version = 2.0-b26-ea3)
regards Steve
<?xml version="1.0" encoding="UTF-8"?> <!-- --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="abc854.p2" targetNamespace="abc854.p2" elementFormDefault="qualified" attributeFormDefault="unqualified"> <!-- ======= All includes ======= --> <xsd:include schemaLocation="../common/definitions.xsd"/>
<!-- =LayerRateList_T Declaration ========= --> <xsd:complexType name="LayerRateList_T"> <xsd:sequence> <xsd:element name="layerRate" type="LayerRate_T" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="extAuthor" type="xsd:string" use="optional"/> <xsd:attribute name="extVersion" type="xsd:string" use="optional"/> <xsd:attribute name="abc854Version" type="abc854_Version_T" use="optional"/> </xsd:complexType> <!-- =LayerRate_T Declaration ========= --> <xsd:simpleType name="LayerRate_T"> <xsd:union> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="MINOR_([a-z]|[A-Z]|[0-9]|(_|-))*"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="PROP_([a-z]|[A-Z]|[0-9]|(_|-))*"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="LR_DS0_64K"/> <xsd:enumeration value="LR_DSL"/> <xsd:enumeration value="LR_Not_Applicable"/> <xsd:enumeration value="LR_Async_FOTS_150M"/> <xsd:enumeration value="LR_Async_FOTS_417M"/> <xsd:enumeration value="LR_Async_FOTS_560M"/> <xsd:enumeration value="LR_Async_FOTS_565M"/> <xsd:enumeration value="LR_Async_FOTS_1130M"/> <xsd:enumeration value="LR_Async_FOTS_1G7"/> <xsd:enumeration value="LR_Async_FOTS_1G8"/> </xsd:restriction> </xsd:simpleType> </xsd:union> </xsd:simpleType> </xsd:schema>
|
|
|
|
|
|
|
Re: Having a problem type mapping union with xjc & JAX-B 2.0
Posted:
Mar 2, 2006 4:54 PM
in response to: steveor
|
|
|
Union maps to String. That's by design. Sorry.
|
|
|
|
|
|
|
|
Re: Having a problem type mapping union with xjc & JAX-B 2.0
Posted:
Mar 2, 2006 5:01 PM
in response to: steveor
|
|
|
OK thanks for the quick answer, so is the way forward (workaround) to refactor the xsd?
(At least then I'll know to stop searching for a soln)
regards Steve
|
|
|
|
|
|
|
|
Re: Having a problem type mapping union with xjc & JAX-B 2.0
Posted:
Mar 10, 2006 5:14 AM
in response to: kohsuke
|
|
|
Thank you very much for your time Kohsuke - just found your response
I pushed on with my efforts and introduced a JAX-P validator as shown in the jax-b samples but I'm perplexed that it seems to validate perfectly. (I'm not complaining 
Is this fluke in that JAX-P SAX solves this in its own way and essentialy tests is it as standard string from list or PROP-string or MINOR-string
ie if the xsd union were more complex than a string it would be a problem
regards Steve
|
|
|
|
|
|
|
|
Re: Having a problem type mapping union with xjc & JAX-B 2.0
Posted:
Mar 1, 2007 6:15 PM
in response to: kohsuke
|
|
|
Hi kohsuke,
I tried your solution to map union type with xjc and jaxb 2.0, but got some problems. Would you please give me a hand? Your help is really appreciated. Thanks
[ERROR] cvc-elt.1: Cannot find the declaration of element 'xjc:javaType'. line 271 of file:/D:/Projects/workspace/TestApp/testscript.xsd
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jxb:extensionBindingPrefixes="xjc">
<!-- here is the excerpt of my schema --> <xs:simpleType name="TypeEnum"> <xs:union> <xs:simpleType> <xs:annotation> <xs:appinfo> <xjc:javaType name="com.abc.BaseTypeEnum" adapter="com.abc.MyTypeAdapter"/> </xs:appinfo> </xs:annotation> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="TypeA001"/> <xs:enumeration value="TypeA002"/> <xs:enumeration value="TypeA003"/> </xs:restriction> </xs:simpleType> <xs:simpleType> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="TypeB001"/> <xs:enumeration value="TypeB002"/> <xs:enumeration value="TypeB003"/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType> </xs:schema>
|
|
|
|
|
|
|
|
Re: Having a problem type mapping union with xjc & JAX-B 2.0
Posted:
Mar 5, 2007 1:12 PM
in response to: mjjuang
|
|
|
You must be using an old version of the RI that didn't support this extension. Try the latest, like 2.0.5 or 2.1.2.
|
|
|
|
|
|
|
|
Re: Having a problem type mapping union with xjc & JAX-B 2.0
Posted:
Nov 1, 2007 1:06 AM
in response to: kohsuke
|
|
|
Hi Kohsuke,
Earlier we were using JAXB 1.0 now want to migrate to 2.0.5.
we are facing similar issue.
XSD config is as below
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://obi.cognos.com/4" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jxb:extensionBindingPrefixes="xjc" xmlns="http://obi.cognos.com/4" elementFormDefault="qualified" > : : <xsd:simpleType name="EnableObject"> <xsd:annotation><xsd:appinfo> <xjc:javaType name="com.jaxb.EnableObject" adapter="com.jaxb.EnableObjectAdapter"/> </xsd:appinfo></xsd:annotation> <xsd:union memberTypes="AlterObject"> <xsd:simpleType> <xsd:annotation> <xsd:appinfo> <jxb:typesafeEnumClass name="EnableObjectsEnum"/> </xsd:appinfo> </xsd:annotation> <xsd:restriction base="xsd:string"> <xsd:enumeration value="EXTERNAL ACTION"/> <xsd:enumeration value="EXTERNAL LINK"/> <xsd:enumeration value="FILTER"/> </xsd:restriction> </xsd:simpleType> </xsd:union> </xsd:simpleType> : : </xsd:schema>
I am not able to locate where my EnableObjectsEnum will fall in class hierarchy
|
|
|
|
|