users@jaxb.java.net

Re: problems binding two elemenst with same name

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 13 May 2014 12:35:01 +0200

https://java.net/jira/browse/JAXB/
Help is available at the triangle in "Log In | v"
-W

On 13/05/2014, Sánchez Lara, José Pablo <jpsanchez_at_indra.es> wrote:
> Hi Wolfgans, excuse me but how I raise a JIRA?
>
> -----Mensaje original-----
> De: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
> Enviado el: martes, 13 de mayo de 2014 10:23
> Para: users_at_jaxb.java.net
> Asunto: Re: problems binding two elemenst with same name
>
> Using jdk1.7.0_21/bin/xjc, I can't make it work - there seems to be a bug in
> xjc with nested inner classes of the same name, and customization doesn't
> appear to be able to break it.
>
> Please complete the XML Schema so that it is fully contained and raise a
> JIRA.
>
> That said, the XML schema is far from being a good basis for generating
> reasonable Java code. Apart from the poor choice of having an inner name
> repeat the name of its parent, the use of anonymous types nested within
> another anonymous types is inconvenient, to say the least. Also, using
> xsd:integer (which causes the use of
> BigInteger) should be reconsidered; a simple int is good for speeds even
> beyond 36000 km/h expressed in cm/s...
>
> To work around this problem, you'll have to extract the implicit types and
> give them a name so that they end up in Java classes of their own.
>
> -W
>
>
> On 13/05/2014, Sánchez Lara, José Pablo <jpsanchez_at_indra.es> wrote:
>> Wolfgang, thank you for answer, the relevant part of the XML schema is
>> a little big, but here you are. I hope that somebody can help me, You
>> can see here that there are to "element" with the same name
>> "TargetSpeed"
>>
>> ***************** START
>> <xsd:element name="TargetSpeed" minOccurs="0" maxOccurs="1">
>> <xsd:annotation>
>> <xsd:appinfo>
>> <FieldFormatPositionName>TARGET
>> SPEED</FieldFormatPositionName>
>>
>> <FieldFormatPositionNumber>12</FieldFormatPositionNumber>
>> <FieldFormatPositionConcept>THE TARGET SPEED
>> EITHER IN MILES PER HOUR/ KNOTS/ KILOMETRES PER HOUR/ METRES PER
>> SECOND, OR AS A GENERIC DEFINITION OF SLOW, MEDIUM, FAST OR
>> ZERO.</FieldFormatPositionConcept>
>> <OccurrenceCategory>Operationally
>> Determined</OccurrenceCategory>
>> <ColumnHeader></ColumnHeader>
>> </xsd:appinfo>
>> </xsd:annotation>
>> <xsd:complexType>
>> <xsd:choice>
>> <xsd:element name="TargetSpeed">
>> <xsd:annotation>
>> <xsd:appinfo>
>>
>> <Justification>Left</Justification>
>>
>> <FieldDescriptor>SPEED</FieldDescriptor>
>>
>> <AssignedFfirnFudUseDescription>ENTER &amp;quot;SPEED:&amp;quot;
>> FOLLOWED BY THE TARGET SPEED, FOR EXAMPLE:
>> &amp;quot;SPEED:80KMH&amp;quot;.</AssignedFfirnFudUseDescription>
>> </xsd:appinfo>
>> </xsd:annotation>
>> <xsd:complexType>
>> <xsd:complexContent>
>> <xsd:extension
>> base="c:SpeedType">
>>
>> <xsd:annotation>
>>
>> <xsd:appinfo>
>>
>> <FieldFormatIndexReferenceNumber>2063</FieldFormatIndexReferenceNumber
>> >
>>
>> <FieldFormatName>SPEED</FieldFormatName>
>>
>> <FieldFormatStructure></FieldFormatStructure>
>>
>> <FieldFormatDefinition>QUANTITATIVE MEASURE OF RATE OF
>> MOVEMENT.</FieldFormatDefinition>
>>
>> <FieldFormatRemark></FieldFormatRemark>
>>
>> <FieldFormatSponsor></FieldFormatSponsor>
>>
>> <FieldFormatRelatedDocuments>ATP-10(C)</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-45</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-34</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-1</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-8</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-6</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-29</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-27</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-33</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-2</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>ATP-31</FieldFormatRelatedDocuments>
>>
>> <VersionIndicator>1.0</VersionIndicator>
>>
>> </xsd:appinfo>
>> </xsd:annotation>
>> <xsd:attribute
>> name="ffirnFudn" type="xsd:string" fixed="FF2063-2" />
>> </xsd:extension>
>> </xsd:complexContent>
>> </xsd:complexType>
>> </xsd:element>
>> <xsd:element name="ApproximateSpeed">
>> <xsd:annotation>
>> <xsd:appinfo>
>>
>> <Justification>Left</Justification>
>>
>> <FieldDescriptor>APPXSPD</FieldDescriptor>
>>
>> <AssignedFfirnFudUseDescription>ENTER &amp;quot;APPXSPD:&amp;quot;
>> FOLLOWED BY THE APPROXIMATE SPEED, FOR EXAMPLE:
>> &amp;quot;APPXSPD:ZERO&amp;quot;.</AssignedFfirnFudUseDescription>
>> </xsd:appinfo>
>> </xsd:annotation>
>> <xsd:complexType>
>> <xsd:simpleContent>
>> <xsd:extension
>> base="f:ApproximateSpeedType">
>>
>> <xsd:annotation>
>>
>> <xsd:appinfo>
>>
>> <FieldFormatIndexReferenceNumber>1113</FieldFormatIndexReferenceNumber
>> >
>>
>> <FieldFormatName>GENERAL INDICATOR OF SPEED</FieldFormatName>
>>
>> <FieldFormatStructure></FieldFormatStructure>
>>
>> <FieldFormatDefinition>THE SPEED OF AN OBJECT DESCRIBED IN GENERAL
>> RELATIVE TERMS.</FieldFormatDefinition>
>>
>> <FieldFormatRemark></FieldFormatRemark>
>>
>> <FieldFormatSponsor></FieldFormatSponsor>
>>
>> <FieldFormatRelatedDocuments>AD 80-6</FieldFormatRelatedDocuments>
>>
>> <FieldFormatRelatedDocuments>APP-7</FieldFormatRelatedDocuments>
>>
>> <VersionIndicator>1.0</VersionIndicator>
>>
>> </xsd:appinfo>
>> </xsd:annotation>
>> <xsd:attribute
>> name="ffirnFudn" type="xsd:string" fixed="FF1113-5" />
>> </xsd:extension>
>> </xsd:simpleContent>
>> </xsd:complexType>
>> </xsd:element>
>> </xsd:choice>
>> <xsd:attribute name="ffSeq" type="xsd:unsignedShort"
>> fixed="12" />
>> </xsd:complexType>
>> </xsd:element>
>> ***************** END
>>
>>
>>
>> -----Mensaje original-----
>> De: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com] Enviado el: lunes,
>> 12 de mayo de 2014 15:28
>> Para: users_at_jaxb.java.net
>> Asunto: Re: problems binding two elemenst with same name
>>
>> What's the type of TargetSpeed, how is it defined? Please add the
>> relevant section of the XML schema.
>>
>> -W
>>
>>
>> On 12/05/2014, Sánchez Lara, José Pablo <jpsanchez_at_indra.es> wrote:
>>> Hi, I not sure that this is the good place to post this issue, but
>>> after look for on the web https://java.net/projects/jaxb/, I don't
>>> have found a better place.
>>>
>>> Well, I have an schema with two nested elements with the same name,
>>> one it is son from another.
>>>
>>> Jvc don't show any error, but when I try to use the java object I
>>> found problems with a parent and a son with the same name.
>>>
>>> When I try to use binding to solve the problem, jvc get a runtime error:
>>> D:\PCBCK\Java\jaxb\jaxb-ri-2.2.7\samples\aod>xjc -nv -verbose
>>> messages.xsd -b bindingset.xml 1>resultado2.txt Exception in thread
>>> "main" java.lang.IllegalArgumentException: Illegal class inheritance
>>> loop.
>>> Outer class TargetSpeedElement may not subclass from inner class:
>>> TargetSpeedElement
>>> at
>>> com.sun.codemodel.internal.JDefinedClass._extends(JDefinedClass.java:257)
>>> at
>>> com.sun.tools.internal.xjc.generator.bean.ImplStructureStrategy$1._extends(ImplStructureStrategy.java:104)
>>> at
>>> com.sun.tools.internal.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:197)
>>> at
>>> com.sun.tools.internal.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:151)
>>> at
>>> com.sun.tools.internal.xjc.model.Model.generateCode(Model.java:275)
>>> at com.sun.tools.internal.xjc.Driver.run(Driver.java:342)
>>> at com.sun.tools.internal.xjc.Driver.run(Driver.java:184)
>>> at com.sun.tools.internal.xjc.Driver._main(Driver.java:107)
>>> at com.sun.tools.internal.xjc.Driver.access$000(Driver.java:64)
>>> at com.sun.tools.internal.xjc.Driver$1.run(Driver.java:87)
>>>
>>>
>>> As a example I show you the binding file that I try to use:
>>>
>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <bindings
>>> xmlns="http://java.sun.com/xml/ns/jaxb"
>>>
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>> version="2.1" schemaLocation="sets.xsd">
>>> <bindings
>>> node="//xsd:schema/xsd:complexType[@name='TargetDesignationType']/xsd:complexContent/xsd:extension/xsd:sequence/xsd:element/xsd:complexType/xsd:choice/xsd:element[@name='TargetSpeed']">
>>> <class name="TargetSpeedElement"/>
>>> </bindings>
>>> </bindings>
>>>
>>>
>>>
>>> If I use the next bindings line in place that the previous one, I get
>>> the same runtime error:
>>>
>>> <bindings
>>> node="//xsd:schema/xsd:complexType[@name='TargetDesignationType']/xsd:
>>> complexContent/xsd:extension/xsd:sequence/xsd:element[@name='TargetSp
>>> e ed']/xsd:complexType/xsd:choice/xsd:element[@name='TargetSpeed']">
>>>
>>>
>>> Can anybody explain me how to deal with two elements with the same
>>> name to create a proper binding file?
>>>
>>>
>>>
>>> Jose Pablo Sánchez Lara
>>>
>>> MANDO Y CONTROL
>>> C/ Joaquín Rodrigo 11
>>> 28300 - Aranjuez Madrid
>>> España
>>>
>>> T +34-91-894.89.99
>>> F +34-91-892.22.17
>>> jpsanchez_at_indra.es<mailto:jpsanchez_at_indra.es>
>>> www.indra.es<http://www.indra.es>
>>>
>>> [cid:image001.jpg_at_01CF6DF1.88D8CFD0]
>>>
>>>
>>> ________________________________
>>> Este correo electrónico y, en su caso, cualquier fichero anexo al
>>> mismo, contiene información de carácter confidencial exclusivamente
>>> dirigida a su destinatario o destinatarios. Si no es vd. el
>>> destinatario indicado, queda notificado que la lectura, utilización,
>>> divulgación y/o copia sin autorización está prohibida en virtud de la
>>> legislación vigente. En el caso de haber recibido este correo
>>> electrónico por error, se ruega notificar inmediatamente esta
>>> circunstancia mediante reenvío a la dirección electrónica del remitente.
>>> Evite imprimir este mensaje si no es estrictamente necesario.
>>>
>>> This email and any file attached to it (when applicable) contain(s)
>>> confidential information that is exclusively addressed to its
>>> recipient(s).
>>> If you are not the indicated recipient, you are informed that
>>> reading, using, disseminating and/or copying it without authorisation
>>> is forbidden in accordance with the legislation in effect. If you
>>> have received this email by mistake, please immediately notify the
>>> sender of the situation by resending it to their email address.
>>> Avoid printing this message if it is not absolutely necessary.
>>>
>>
>> Este correo electrónico y, en su caso, cualquier fichero anexo al
>> mismo, contiene información de carácter confidencial exclusivamente
>> dirigida a su destinatario o destinatarios. Si no es vd. el
>> destinatario indicado, queda notificado que la lectura, utilización,
>> divulgación y/o copia sin autorización está prohibida en virtud de la
>> legislación vigente. En el caso de haber recibido este correo
>> electrónico por error, se ruega notificar inmediatamente esta
>> circunstancia mediante reenvío a la dirección electrónica del remitente.
>> Evite imprimir este mensaje si no es estrictamente necesario.
>>
>> This email and any file attached to it (when applicable) contain(s)
>> confidential information that is exclusively addressed to its
>> recipient(s).
>> If you are not the indicated recipient, you are informed that reading,
>> using, disseminating and/or copying it without authorisation is
>> forbidden in accordance with the legislation in effect. If you have
>> received this email by mistake, please immediately notify the sender
>> of the situation by resending it to their email address.
>> Avoid printing this message if it is not absolutely necessary.
>>
>
> Este correo electrónico y, en su caso, cualquier fichero anexo al mismo,
> contiene información de carácter confidencial exclusivamente dirigida a su
> destinatario o destinatarios. Si no es vd. el destinatario indicado, queda
> notificado que la lectura, utilización, divulgación y/o copia sin
> autorización está prohibida en virtud de la legislación vigente. En el caso
> de haber recibido este correo electrónico por error, se ruega notificar
> inmediatamente esta circunstancia mediante reenvío a la dirección
> electrónica del remitente.
> Evite imprimir este mensaje si no es estrictamente necesario.
>
> This email and any file attached to it (when applicable) contain(s)
> confidential information that is exclusively addressed to its recipient(s).
> If you are not the indicated recipient, you are informed that reading,
> using, disseminating and/or copying it without authorisation is forbidden in
> accordance with the legislation in effect. If you have received this email
> by mistake, please immediately notify the sender of the situation by
> resending it to their email address.
> Avoid printing this message if it is not absolutely necessary.
>