issue while putting Namespace in arrays

5 views
Skip to first unread message

Piyush Plaban Praharaj

unread,
Mar 3, 2011, 1:55:28 AM3/3/11
to FxWorks
and i have an arrayCollection inside a class named friendList
containing list of friends which is inside a class
after serialization the xml should look like this(this is strictly
needed by client)

<FriendList xmlns:a="http://MyAPPs.Listing/Friend">
<a:Friend>
<a:ID>1</a:ID>
<a:Name>Meera</a:Name>
</a:Friend>
<a:Friend>
<a:ID>2</a:ID>
<a:Name>Jenny</a:Name>
</a:Friend>
</FriendList >

so my array liooks like below
[XmlArray(alias="MyList ", order="7", memberName="Friend",
type="com.piyush.apps.lister.Friend")]
public var friendList:ArrayCollection;

and after serialazation the output is like this :(
<FriendList>
<Friend xmlns:a="http://MyAPPs.Listing/Friend">
<a:ID>1</a:ID>
<a:Name>Meera</a:Name>
</Friend>
<Friend xmlns:a="http://MyAPPs.Listing/Friend">
<a:ID>2</a:ID>
<a:Name>Jenny</a:Name>
</Friend>
</FriendList >

the code for Friend class is like this

[XmlClass(alias="Friend", ordered="true", prefix="a", uri="http://
MyAPPs.Listing/Friend")]
public class Friend extends DomainObject implements IIdentifiable
{

// properties
[XmlElement(alias="ID", order="1")]
public var friendID:String = "0";

[XmlElement(alias="Name", order="2")]
public var friendName:String = "Piyush";
}



the question is : is there any way i can add a namespace to an array?

Thanks,
Piyush

Alexutz

unread,
Mar 3, 2011, 3:21:43 AM3/3/11
to FxWorks
Hi,

Did you try putting a namespace on the array?
You can do this by defining the namespace in the owner class using the
Namespace annotation:

[Namespace(prefix="a", uri="http://
MyAPPs.Listing/Friend")]
public class FriendList{
...
}

and then reference it in the Array annotation:

[XmlArray(alias="MyList ", order="7", memberName="Friend",
type="com.piyush.apps.lister.Friend", namespace="a")]
public var friendList:ArrayCollection;


Let me know how it goes.

Regards,
Alex

Piyush Plaban Praharaj

unread,
Mar 3, 2011, 3:40:14 AM3/3/11
to FxWorks
Hi, Alex

Yes i have tried your above technique by adding a namespace tag to
container class of friendList array
[Namespace(prefix="a", uri="http://MyAPPs.Listing/Friend")]
before class declaration

and referred it with friendList
[XmlArray(alias="MyList ", order="7",
memberName="Friend",namespace="a",type="com.piyush.apps.lister.Friend")]

but the output came like this, no namespace, only prefix :(

<a:FriendList>
<Friend >
<ID>1</ID>
<Name>Meera</Name>
</Friend>
<Friend>
<ID>2</ID>
<Name>Jenny</Name>
</Friend>
</a:FriendList>

Alexutz

unread,
Mar 3, 2011, 3:44:06 AM3/3/11
to FxWorks
Hmmm... looks like a bug. I'll take a look at it. In the meantime
could you please enter this as an issue on the project issues page?

Thanks,
Alex
> > > Piyush- Ascundeţi textul citat -
>
> - Afişare text în citat -

Piyush Plaban Praharaj

unread,
Mar 3, 2011, 5:44:44 AM3/3/11
to FxWorks
Hi Alex,
I Have added this as an issue in issues page.
ISSueID = 40
http://code.google.com/p/flexxb/issues/detail?id=40
Thanks,
Piyush
> > > > Piyush- Ascundeþi textul citat -
>
> > - Afiºare text în citat -
>
>

Alexutz

unread,
Mar 9, 2011, 3:05:28 PM3/9/11
to FxWorks
Ha, I found the issue. When you set the member name in the array
annotation for each member of the collection it's xml name will be
computed instead of using the regular one from the XMLClass
annotation. To get things working properly you should remove the
memberName="Friend" cos the Friend class already specifies the correct
alias and namespaces.

Alex

On 3 mar., 12:44, Piyush Plaban Praharaj <piyush...@gmail.com> wrote:
> Hi Alex,
> I Have added this as an issue in issues page.
> ISSueID = 40http://code.google.com/p/flexxb/issues/detail?id=40
> > > - Afiºare text în citat -- Ascundeţi textul citat -

Piyush Plaban Praharaj

unread,
Mar 15, 2011, 8:38:12 AM3/15/11
to FxWorks
Hi Alexutz
Yes its working now!!
thanks a lot

Piyush
Reply all
Reply to author
Forward
0 new messages