Hi,
I checked your code and the xml. And it worked. Check the attachments.

I think your problem is the firstNode is not the one you think (<Command>).
If you have spaces in the xml, the axiom think they are text_node, And
currently the code gen is not handling that situation, I have to check
whether it s a bug or not.

If it is the case, just add following lines to get rid of the text_nodes,

while(axiom_node_get_node_type(first_node, env) != AXIOM_ELEMENT)
{
    first_node = axiom_node_get_next_sibling(first_node, env);
}

And if you found the generated code is not working, please let the axis2-c
list know that issue, And hope you are updated with the tool from
http://people.apache.org/dist/axis2/nightly/

Thanks
Dimuthu

On Nov 27, 2007 11:33 AM, Sunil Pandit <[EMAIL PROTECTED]> wrote:

> Can someone guide me on how to read the attribute value on an element ?
>
> I have a web service that takes a complex element with an attribute.  The
> deserialization code generated by WSDL2C is not able to read this
> attribute.
> So I modified the code and none of the method including
> axiom_element_get_all_attributes returns the attributes.
> The axiom_element_get_all_attributes returns NULL.
>
> When I log the string form of the node passed to deserialize method , I
> can
> see all the sub elements and the attribute . Here is the code
>
> Any help is sincerely appreciated.
>
>      parent_element = axiom_node_get_data_element(first_node, env);
>      qname = axutil_qname_create_from_string(env,"Sequence");
>      if(qname != NULL)
>      {
>            parent_attri = axiom_element_get_attribute(parent_element, env,
> qname);
>      }
>
>      if(parent_attri == NULL)
>      {
>            attributes =
> axiom_element_get_all_attributes(parent_element,env);
>      }
>
> Here is the string form of node passed to the deserialize method
>
> Mon Nov 26 23:32:54 2007] [info]  CommandType : String form of Element is
>  <Command Sequence="1">
>      <Type>loadsession</Type>
>      <Parameter>C:\VPMS\workspace\Federated
>
> Perf\Federated\Models\DADVDOCS_Master\DADVDOCS\DULDOCS_test_cases.VPM</Parameter>
>  </Command>
>
>
>
>
> Regards
> Sunil Pandit
> R&D , CSC FSG Austin
> (512)2755792
>
> Computer Sciences Corporation
> Registered Office: 2100 East Grand Avenue, El Segundo California 90245,
> USA
> Registered in USA No: C-489-59
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> This is a PRIVATE message. If you are not the intended recipient, please
> delete without copying and kindly advise us by e-mail of the mistake in
> delivery.
> NOTE: Regardless of content, this e-mail shall not operate to bind CSC to
> any order or other contract unless pursuant to explicit written agreement
> or government initiative expressly permitting the use of e-mail for such
> purpose.
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Attachment: Makefile
Description: Binary data

#include <axiom.h>
#include <axis2_util.h>

int main()
{
    axiom_xml_reader_t *xml_reader = NULL;
    axutil_env_t *env;
    axiom_stax_builder_t *om_builder = NULL;
    axiom_document_t *document = NULL;

    axiom_node_t *first_node = NULL;
    axiom_attribute_t *parent_attri = NULL;
    axiom_element_t *parent_element = NULL;
    axutil_qname_t *qname = NULL;
    axutil_hash_t *attributes = NULL;

    env = axutil_env_create_all("alltest.log", AXIS2_LOG_LEVEL_TRACE);
    xml_reader = axiom_xml_reader_create_for_file(env, "test.xml", NULL);
    om_builder = axiom_stax_builder_create(env, xml_reader);
    document = axiom_stax_builder_get_document(om_builder, env);
                                 
    first_node = axiom_document_get_root_element(document, env);
    parent_element = axiom_node_get_data_element(first_node, env);
    qname = axutil_qname_create_from_string(env,"Sequence");

    if(qname != NULL)
    {
        parent_attri = axiom_element_get_attribute(parent_element, env, qname);
        printf("%s\n", axiom_attribute_get_value(parent_attri, env));
    }

    if(parent_attri == NULL)
    {
        attributes = axiom_element_get_all_attributes(parent_element,env);
        if(attributes == NULL) 
        {
            printf("attributes NULL\n");
        }
        else
        {
            printf("attributes not NULL\n");
        }
    }
    return 0;
}
<Command Sequence="1">
     <Type>loadsession</Type>
     <Parameter>C:\VPMS\workspace\Federated
Perf\Federated\Models\DADVDOCS_Master\DADVDOCS\DULDOCS_test_cases.VPM</Parameter>
</Command>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to