Hi Catalina,
Looks like there is a bug. It happens that if parent types only contains
attributes, the code that you mentioned is necessary,
current_node = first_node;
is_early_node_valid = AXIS2_FALSE;
is never executed.
Please raise a JIRA reporting this issue. I attached a patch (taken from the
latest svn) for give an idea what has gone wrong.
Thanks
Dimuthu
On Wed, Nov 12, 2008 at 7:09 PM, Catalina Caloian <
[EMAIL PROTECTED]> wrote:
> Hello.
>
> Scenario:
> - the first element in a sequence is nillable
> - in the actual XML, that first element is present, but is empty
> - the deserialization code of the parent mishandles this element by not
> recognizing it as being its *first* child element and by treating it as if
> it were a child with position >= 2
>
> Example:
>
> Relevant part of the wsdl:
>
> <complexType name="TransientVO">
> <sequence></sequence>
> </complexType>
>
> <complexType name="Address">
> <complexContent>
> <extension base="ns2:TransientVO">
> <sequence> </sequence>
> <!-- attributes -->
> </extension>
> </complexContent>
> </complexType>
>
> <complexType name="ResultAddress">
> <complexContent>
> <extension base="tns:Address">
> <sequence>
> <element name="wrappedAdditionalFields"
> type="tns:ArrayOfAdditionalField" minOccurs="1" maxOccurs="1"
> nillable="true"/>
> <element name="coordinates" type="ns1:Point" minOccurs="0"
> maxOccurs="1" nillable="true"/>
> </sequence>
> <!-- attributes -->
> </extension>
> </complexContent>
> </complexType>
>
>
>
> If 'wrappedAdditionalFields' would have been recognized as the first child
> element, according to the CADBBeanTemplateSource.xsl template, the
> deserialization code would have looked something like this:
> adb_ResultAddress_deserialize(...)
> {
> ...
> /*
> * building wrappedAdditionalFields element
> */
>
> current_node = first_node;
> is_early_node_valid = AXIS2_FALSE;
> ...
> }
>
> Instead, the deserialization code looks something like this:
>
> adb_ResultAddress_deserialize(...)
> {
> ...
> /*
> * building wrappedAdditionalFields element
> */
>
> /*
> * because elements are ordered this works fine
> */
> if(current_node != NULL && is_early_node_valid)
> {
> // code as if this were a child with position >= 2
> // at this point, current_node is NULL because no element has been
> recognized as being the first child (and no element will be recognized as
> such)
> }
> }
>
>
> For generating C code I have used axis2-1.4.1-src with some slight changes
> to CADBBeanTemplateSource.xsl to embed some minor bug fixes.
>
> I have attached to this e-mail the wsdl and the template I've been using.
>
> I'm not sure if this problem is a bug in Axis2C or in Axis2. However, I
> thought I would try to raise this problem here hoping that somebody might be
> able to help me.
>
> Thank you,
> Catalina Caloian
>
>
>
>
>
> This message contains information that may be privileged or confidential
> and is the property of Quintiq. It is only intended for the person to whom
> it is addressed. If you are not the intended recipient, you are not
> authorized to read, print, retain, copy, disseminate, distribute or use this
> message or any part thereof. If you have received this message in error,
> please notify the sender immediately and delete all copies of this message.
> Please note that e-mails are susceptible to change, therefore they are not
> binding.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
Thanks,
Dimuthu Gamage
http://www.dimuthu.org
http://www.wso2.org
Index: CADBBeanTemplateSource.xsl
===================================================================
--- CADBBeanTemplateSource.xsl (revision 713759)
+++ CADBBeanTemplateSource.xsl (working copy)
@@ -936,6 +936,35 @@
</xsl:choose>
</xsl:variable>
<xsl:variable name="parentPropertyInstanceName"><xsl:value-of select="$name"/>->property_<xsl:value-of select="$CName"/></xsl:variable>
+
+ <!-- the position()=1 should be outside the otherwise choose of @attribute -->
+ <xsl:choose>
+ <xsl:when test="not(@isarray)"> <!--not an array so continue normal -->
+ <xsl:if test="$ordered or not($anon or $istype) or $choice"> <!-- since non-anon and choices has just only one sub element-->
+ <xsl:if test="position()=1">
+ current_node = first_node;
+ is_early_node_valid = AXIS2_FALSE;
+ <!-- Wait until AXIOM_ELEMENT -->
+ <xsl:if test="not(@any)">
+ while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT)
+ {
+ current_node = axiom_node_get_next_sibling(current_node, env);
+ }
+ if(current_node != NULL)
+ {
+ current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env);
+ qname = axiom_element_get_qname(current_element, env, current_node);
+ }
+ </xsl:if>
+ </xsl:if>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ current_node = first_node;
+ is_early_node_valid = AXIS2_FALSE;
+ </xsl:otherwise>
+ </xsl:choose>
+
<xsl:choose>
<xsl:when test="@attribute">
<!-- here we have two options, either it can be axiom_attribute_t* which happens in anyAttribute case -->
@@ -1214,20 +1243,7 @@
<xsl:when test="$ordered or not($anon or $istype) or $choice"> <!-- since non-anon and choices has just only one sub element-->
<xsl:choose>
<xsl:when test="position()=1">
- current_node = first_node;
- is_early_node_valid = AXIS2_FALSE;
- <!-- Wait until AXIOM_ELEMENT -->
- <xsl:if test="not(@any)">
- while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT)
- {
- current_node = axiom_node_get_next_sibling(current_node, env);
- }
- if(current_node != NULL)
- {
- current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env);
- qname = axiom_element_get_qname(current_element, env, current_node);
- }
- </xsl:if>
+ <!-- This place is completely moved to up -->
</xsl:when>
<xsl:otherwise>
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]