How to get this XML result?

View: New views
4 Messages — Rating Filter:   Alert me  

How to get this XML result?

by patb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I have this simple (example) class:

-----------
@Root
public class TextData
{
    @Element
    private String text1;

    @Element
    private String text2;
       
    // Getters and setters...
}
-----------

and I would like to create XML data output that looks like this:

-----------
<abc:textDataRequest xmlns:r2d="http://www.foo.net/abcDataService/">
    <text1>This is text one</text1>
    <text2>This is text two</text2>
</abc:textDataRequest>
-----------

Note that the "abc" prefix is only at the root element. How must I
annotate/configure/modify my class to get the desired result?



I appreciate any help you can offer


Thanks a lot!


Best regards,
Timo Rumland


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

Re: How to get this XML result?

by niall.gallagher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 
Hi,

This does not look like valid XML. Where is the abc namespace declared in your XML. I see only an rd2 namespace? The following works with valid namespaces.

@Root(name="textDataRequest")
@Namespace(prefix="abc", reference="http://www.foo.net/abcDataService/")
public class TextData
{
    @Element
    private String text1;

    @Element
    private String text2;
       
    // Getters and setters...
}

Will produce

<abc:textDataRequest xmlns:abc="http://www.foo.net/abcDataService/">
    <text1>This is text one</text1>
    <text2>This is text two</text2>
</abc:textDataRequest>

Niall

Niall Gallagher
RBS Global Banking & Markets
Office: +44 7879498724  

-----Original Message-----
From: Timo Rumland [mailto:cr@...]
Sent: 24 September 2009 10:50
To: simple-support@...
Subject: [Simple-support] How to get this XML result?

Hello,

I have this simple (example) class:

-----------
@Root
public class TextData
{
    @Element
    private String text1;

    @Element
    private String text2;
       
    // Getters and setters...
}
-----------

and I would like to create XML data output that looks like this:

-----------
<abc:textDataRequest xmlns:r2d="http://www.foo.net/abcDataService/">
    <text1>This is text one</text1>
    <text2>This is text two</text2>
</abc:textDataRequest>
-----------

Note that the "abc" prefix is only at the root element. How must I annotate/configure/modify my class to get the desired result?



I appreciate any help you can offer


Thanks a lot!


Best regards,
Timo Rumland


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
Authorised and regulated by the Financial Services Authority.
 
This e-mail message is confidential and for use by the
addressee only. If the message is received by anyone other
than the addressee, please return the message to the sender
by replying to it and then delete the message from your
computer. Internet e-mails are not necessarily secure. The
Royal Bank of Scotland plc does not accept responsibility for
changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the
transmission of viruses, it is the responsibility of the recipient to
ensure that the onward transmission, opening or use of this
message and any attachments will not adversely affect its
systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry
out such virus and other checks as it considers appropriate.

Visit our website at www.rbs.com

***********************************************************************************


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

Re: How to get this XML result?

by patb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Niall,

> This does not look like valid XML. Where is the abc namespace
> declared in your XML. I see only an rd2 namespace? The following
> works with valid namespaces.

of course you are right, it was a missspelling... "r2d" should have
been "abc", too.


> @Root(name="textDataRequest")
> @Namespace(prefix="abc", reference="http://www.foo.net/abcDataService/")
> [...]

> Will produce

> <abc:textDataRequest xmlns:abc="http://www.foo.net/abcDataService/">
>     <text1>This is text one</text1>
>     <text2>This is text two</text2>
> </abc:textDataRequest>

I think it will produce

> <abc:textDataRequest xmlns:abc="http://www.foo.net/abcDataService/">
>     <abc:text1>This is text one</abc:text1>
>     <abc:text2>This is text two</abc:text2>
> </abc:textDataRequest>

to the "abc" namespace is on the child elements also. But I know this
it valid XML, if I want the null-namespace on child-elements, I have
to use

----------------
@Element
@Namespace( reference = "" )
private String  text1;
----------------

Thanks


Best regards,
Timo Rumland


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

Re: How to get this XML result?

by niall.gallagher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Upgrade to the latest version 2.1.4 and the namespace will not explicitly on the children. One thing to note here

<abc:textDataRequest xmlns:abc="http://www.foo.net/abcDataService/">
    <abc:text1>This is text one</abc:text1>
    <abc:text2>This is text two</abc:text2>
</abc:textDataRequest>

And

<abc:textDataRequest xmlns:abc="http://www.foo.net/abcDataService/">
    <text1>This is text one</text1>
    <text2>This is text two</text2>
</abc:textDataRequest>

Are identical, there namespace qualifications are the same. All elements will inherit the namespace of their parents unless specifically told not to with xmlns="".

Niall

Niall Gallagher
RBS Global Banking & Markets
Office: +44 7879498724  

-----Original Message-----
From: Timo Rumland [mailto:cr@...]
Sent: 25 September 2009 13:47
To: simple-support@...
Subject: Re: [Simple-support] How to get this XML result?

Hello Niall,

> This does not look like valid XML. Where is the abc namespace declared
> in your XML. I see only an rd2 namespace? The following works with
> valid namespaces.

of course you are right, it was a missspelling... "r2d" should have been "abc", too.


> @Root(name="textDataRequest")
> @Namespace(prefix="abc",
> reference="http://www.foo.net/abcDataService/")
> [...]

> Will produce

> <abc:textDataRequest xmlns:abc="http://www.foo.net/abcDataService/">
>     <text1>This is text one</text1>
>     <text2>This is text two</text2>
> </abc:textDataRequest>

I think it will produce

> <abc:textDataRequest xmlns:abc="http://www.foo.net/abcDataService/">
>     <abc:text1>This is text one</abc:text1>
>     <abc:text2>This is text two</abc:text2> </abc:textDataRequest>

to the "abc" namespace is on the child elements also. But I know this it valid XML, if I want the null-namespace on child-elements, I have to use

----------------
@Element
@Namespace( reference = "" )
private String  text1;
----------------

Thanks


Best regards,
Timo Rumland


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
Authorised and regulated by the Financial Services Authority.
 
This e-mail message is confidential and for use by the
addressee only. If the message is received by anyone other
than the addressee, please return the message to the sender
by replying to it and then delete the message from your
computer. Internet e-mails are not necessarily secure. The
Royal Bank of Scotland plc does not accept responsibility for
changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the
transmission of viruses, it is the responsibility of the recipient to
ensure that the onward transmission, opening or use of this
message and any attachments will not adversely affect its
systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry
out such virus and other checks as it considers appropriate.

Visit our website at www.rbs.com

***********************************************************************************


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support