users@jaxb.java.net

Re: jaxb code generation issue

From: oxg1123 <oxg1123_at_yahoo.com>
Date: Sat, 4 Oct 2008 13:15:12 -0700 (PDT)

Thanks for a quick response. I've removed mixed=true and regenerated code. However during marshalling process I'm getting the following exception:

Exception from Validator:
Message is unexpected element (uri:"http://schemas.xmlsoap.org/ws/2004/03/business-process/", local:"query"). Expected elements are <{
Column is 84 at line number 38
Message is unexpected element (uri:"http://schemas.xmlsoap.org/ws/2004/03/business-process/", local:"query"). Expected elements are <{
Column is 84 at line number 44


Any ideas ?


XML
    <bpwc:assign name="Initiallize" wpc:displayName="Initiallize" wpc:id="9">
      <bpwc:copy>
        <bpwc:from variable="service">
          <bpwc:query queryLanguage="http://www.w3.org/TR/1999/REC-xpath-19991116"><![CDATA[ServiceName]]></bpwc:query> <===================== line number 38
        </bpwc:from>
        <bpwc:to variable="serviceName"/>
      </bpwc:copy>
      <bpwc:copy>
        <bpwc:from variable="service">
          <bpwc:query queryLanguage="http://www.w3.org/TR/1999/REC-xpath-19991116"><![CDATA[PreStartUpCmds]]></bpwc:query> <==================== line number 44
        </bpwc:from>





Marshalling code:
            JAXBContext jc = JAXBContext.newInstance(TProcess.class);
            Unmarshaller u = jc.createUnmarshaller();
            u.setEventHandler(new ValidationEventHandlerImpl());
            
            JAXBElement<?> bpelElement = (JAXBElement<?>)u.unmarshal(new File("/home/olegg/workspaces/bpelTranslation/jaxBpel.test/src/RepresentativeEF.bpel"));
            TProcess process = (TProcess)bpelElement.getValue();
            System.out.println(process.toString());



Generated code:

TFrom.java

 * <p>Java class for tFrom complex type.
 *
 * <p>The following schema fragment specifies the expected content contained within this class.
 *
 * <pre>
 * &lt;complexType name="tFrom">
 * &lt;complexContent>
 * &lt;extension base="http://www.zzzz.com/xmlns/xxxxx/xxxxxxxxxx/6.0.0/}tFromExtension">
 * &lt;sequence>
 * &lt;any/>
 * &lt;choice minOccurs="0">
 * &lt;element ref="{http://schemas.xmlsoap.org/ws/2004/03/business-process/}query"/>
 * &lt;element ref="{http://schemas.xmlsoap.org/ws/2004/03/business-process/}expression"/>
 * &lt;element ref="{http://schemas.xmlsoap.org/ws/2004/03/business-process/}service-ref"/>
 * &lt;/choice>
 * &lt;/sequence>
 * &lt;attribute name="variable" type="{http://www.w3.org/2001/XMLSchema}NCName" />
 * &lt;attribute name="part" type="{http://www.w3.org/2001/XMLSchema}NCName" />
 * &lt;attribute name="property" type="{http://www.w3.org/2001/XMLSchema}QName" />
 * &lt;attribute name="partnerLink" type="{http://www.w3.org/2001/XMLSchema}NCName" />
 * &lt;attribute name="endpointReference" type="{http://schemas.xmlsoap.org/ws/2004/03/business-process/}tRoles" />
 * &lt;attribute name="opaque" type="{http://schemas.xmlsoap.org/ws/2004/03/business-process/}tBoolean" />
 * &lt;/extension>
 * &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "tFrom")
public class TFrom
    extends TFromExtension
{

    @XmlAttribute
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "NCName")
    protected String variable;
    @XmlAttribute
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "NCName")
    protected String part;
    @XmlAttribute
    protected QName property;
    @XmlAttribute
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "NCName")
    protected String partnerLink;
    @XmlAttribute
    protected TRoles endpointReference;
    @XmlAttribute
    protected TBoolean opaque;

    /**
     * Gets the value of the variable property.
     *
     * @return
     * possible object is
     * {_at_link String }
     *
     */
    public String getVariable() {
        return variable;
    }

    /**
     * Sets the value of the variable property.
     *
     * @param value
     * allowed object is
     * {_at_link String }
     *
     */
    public void setVariable(String value) {
        this.variable = value;
    }





TFromExtension.java

* <pre>
 * &lt;complexType name="tFromExtension">
 * &lt;complexContent>
 * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 * &lt;sequence>
 * &lt;element ref="{http://www.zzzz.com/xmlns/xxxxx/xxxxxxxxxx/6.0.0/}literal" minOccurs="0"/>
 * &lt;/sequence>
 * &lt;/restriction>
 * &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "tFromExtension", propOrder = {
    "content"
})
@XmlSeeAlso({
    TFrom.class
})
public class TFromExtension {

    @XmlElementRef(name = "literal", namespace = "http://www.zzzz.com/xmlns/xxxxx/xxxxxxxxxx/6.0.0/", type = JAXBElement.class)
    @XmlMixed
    protected List<Serializable> content;

    /**
     *
     * BPEL Extensions extension base type for BPEL complexType tFrom.
     * Gets the value of the content property.
     *
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the content property.
     *
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     * getContent().add(newItem);
     * </pre>
     *
     *
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {_at_link String }
     * {_at_link JAXBElement }{_at_code <}{_at_link TLiteral }{_at_code >}
     *
     *
     */
    public List<Serializable> getContent() {
        if (content == null) {
            content = new ArrayList<Serializable>();
        }
        return this.content;
    }



Thanks a lot




----- Original Message ----
From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
To: users_at_jaxb.dev.java.net
Sent: Saturday, October 4, 2008 10:19:55 AM
Subject: Re: jaxb code generation issue

The base type wpc:tFromExtension has mixed="true", too.
Look for a field List<JAXBElement<?>> content in that class.
That's where your <xs:choice> elements will be after unmarshalling.

You might consider avoiding mixed="true".

-W


On Sat, Oct 4, 2008 at 6:13 PM, oxg1123 <oxg1123_at_yahoo.com> wrote:
> It looks like jaxb2 is ignoring xsd:choice within the xsd:extension. The code generation simply ignores it, not sure why.
>
> Any ideas?
>
>
> Please advice.
>
>
> XSD:
> <complexType name="tFrom" mixed="true">
> <complexContent>
> <extension base="wpc:tFromExtension">
> <sequence>
> <any namespace="##other" processContents="skip" minOccurs="0"/>
> <choice minOccurs="0">
> <element ref="bpws:query"/>
> <element ref="bpws:expression"/>
> <element ref="bpws:service-ref"/>
> </choice>
> </sequence>
> <attribute name="variable" type="NCName"/>
> <attribute name="part" type="NCName"/>
> <attribute name="property" type="QName"/>
> <attribute name="partnerLink" type="NCName"/>
> <attribute name="endpointReference" type="bpws:tRoles"/>
> <attribute name="opaque" type="bpws:tBoolean"/>
> </extension>
> </complexContent>
> </complexType>
>
>
>
> Generated code:
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "tFrom")
> @XmlRootElement(name = "from")
> public class TFrom
> extends TFromExtension
> {
> @XmlAttribute
> @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> @XmlSchemaType(name = "NCName")
> protected String variable;
> @XmlAttribute
> @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> @XmlSchemaType(name = "NCName")
> protected String part;
> @XmlAttribute
> protected QName property;
> @XmlAttribute
> @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
> @XmlSchemaType(name = "NCName")
> protected String partnerLink;
> @XmlAttribute
> protected TRoles endpointReference;
> @XmlAttribute
> protected TBoolean opaque;
>
> /**
> * Gets the value of the variable property.
> *
> * @return
>
>
> Thanks a lot
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net