commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sameer Nanda <sam5...@gmail.com>
Subject Fwd: Managing XML Output from Betwixt
Date Mon, 03 Oct 2005 15:46:20 GMT
Well thanks again Russell,

Whatever you said is true, I can either rename my Class to a lowercase
authorization (but then I am breaking the naming convention for writing Java
classes which I dont wanna do) , and I could also run the replaceAll() on
the XML string generated to replace all <Authorization> to <authorization>
(but that would be a hack).

My point here is, it shouldnt have to be like that ....... theres gotta be
something in Betwixt using which I can do this. I mean this is just one
example I am talking here, I have to generate much more complex XML
documents which would involve a lot of Java Bean Objects, which in turn
would contain a bunch of other Java Beans. Do you know what I mean?

Again, Russell its not that I appreciate your ideas and the time you have
spent with me discussing my problem, but all I want is to know if theres
something in Betwixt using which I can get this problem solved !!!!

And I was still woundering and looking for answers to know if its the
java.util.List with which Betwixt is behaving funny or is there something
else I am missing or not doing right here ???

Thank you again Russell...

_Sameer

On 10/3/05, Russell Simpkins <russellsimpkins@hotmail.com> wrote:
>
> Well, this is simply a case situation, so you could execute
> String.replaceAll after you get the resulting XML string back, or rename
> your classe to lowercase authorization.
>
>
> >From: Sameer Nanda < sam504u@gmail.com>
> >Reply-To: Sameer Nanda <sam504u@gmail.com>
> >To: Russell Simpkins <russellsimpkins@hotmail.com >
> >Subject: Re: Managing XML Output from Betwixt
> >Date: Mon, 3 Oct 2005 10:52:09 -0400
> >
> >Yes Russell,
> >
> >your guess is true, I am getting <Authorization> as a list of elements in
>
> >the <authorizations> parent element, which is what I want but with a
> >lowecase <authorization> not the name of my Class <Authorization>. I
hope
> >you guys understand what I am trying to say here.
> >
> >And I did look into Betwixt but couldnt find anything specific to this.
> Any
> >other clues anyone ???
> >
> >_sameer
> >
> >
> >On 10/3/05, Russell Simpkins < russellsimpkins@hotmail.com> wrote:
> > >
> > > Is the issue right now that your xml has an uppercase <Authorization>?
> I
> > > don't know bitwix, but you may look to the docs and see if there is a
> > > property there to set all attributes to lowercase. Rright now, it
> looks
> > > like
> > > you have what you requested in the first post.
> > >
> > >
> > > >From: Sameer Nanda < sam504u@gmail.com>
> > > >Reply-To: Sameer Nanda <sam504u@gmail.com>
> > > >To: Russell Simpkins < russellsimpkins@hotmail.com>
> > > >Subject: Re: Managing XML Output from Betwixt
> > > >Date: Mon, 3 Oct 2005 09:25:46 -0400
> > > >
> > > >Hello Russell,
> > > >
> > > >Thank for your reply, but guess you didnt read my previous reply to
> >Remi,
> > > >so
> > > >anyways I tried doing that and what my classes look like are:
> > > >
> > > > User.java: (has a List of Authorization)
> > > >=======
> > > >package mms.Objects;
> > > >import java.util.List;
> > > >
> > > >public class User {
> > > >private int id;
> > > >private String firstName;
> > > >private String lastName;
> > > >private List authorizations;
> > > >
> > > >public User() {}
> > > >
> > > >public User(int id, String firstName, String lastName, List
> > > authorizations)
> > > >{
> > > >this.id <http://this.id> <http://this.id> <http://this.id>
= id;
> > > > this.firstName = firstName;
> > > >this.lastName = lastName;
> > > >this.authorizations = authorizations;
> > > >}
> > > >
> > > >public int getId() {
> > > >return this.id <http://this.id> <http://this.id> <http://this.id>;
> > > >}
> > > >public void setId(int id) {
> > > > this.id <http://this.id> <http://this.id> <http://this.id>
= id;
> > > >}
> > > >
> > > >public String getFirstName()
> > > >{
> > > >return this.firstName;
> > > >}
> > > >public void setFirstName(String firstName)
> > > >{
> > > >this.firstName = firstName;
> > > >}
> > > >
> > > >public String getLastName()
> > > >{
> > > >return this.lastName;
> > > >}
> > > >public void setLastName(java.lang.String lastName)
> > > >{
> > > >this.lastName = lastName;
> > > >}
> > > >
> > > >public List getAuthorizations() {
> > > >return this.authorizations;
> > > >}
> > > >public void setAuthorizations(List auhtorizations) {
> > > >this.authorizations = authorizations;
> > > >}
> > > >
> > > >}
> > > >=========================================================
> > > >
> > > >
> > > >And my Authorization class hasnt changed its the same:
> > > >
> > > >
> > > >Authorization.java:
> > > >==============
> > > >
> > > >
> > > >package mms.Objects;
> > > >
> > > >public class Authorization {
> > > >private String objectType;
> > > >private String functionName;
> > > >
> > > >public Authorization() {}
> > > >public Authorization(String objectType,String functionName) {
> > > >this.objectType = objectType;
> > > >this.functionName = functionName;
> > > >}
> > > >
> > > >public String getObjectType() {
> > > >return this.objectType;
> > > >}
> > > >public void setObjectType(String objectType) {
> > > >this.objectType = objectType;
> > > >}
> > > >
> > > >public String getFunctionName() {
> > > >return this.functionName;
> > > >}
> > > >public void setFunctionName(String functionName) {
> > > >this.functionName = functionName;
> > > >}
> > > >
> > > >}
> > > >
> > > >======================================================
> > > >
> > > >So now when I call User from my Main class like this:
> > > >
> > > >
> > > >List authorizations = new ArrayList();
> > > >while(rs2.next()) {
> > > >String object_type = rs2.getString("object_type");
> > > >String function_name = rs2.getString ("function_name");
> > > >
> > > >Authorization authorization = new
> > > Authorization(object_type,function_name);
> > > >authorizations.add(authorization);
> > > >}
> > > >
> > > >User user = new User(person_id, firstName, lastName, authorizations);
> > > >beanWriter.write("loginResponse", new LoginResponse(user));
> > > >result = outputWriter.toString ();
> > > >
> > > >
> > > >============================================
> > > >
> > > >
> > > >where rs2 is my rsult set fetched from the DB. I get an XML o/p as
> show
> > > >below:
> > > >
> > > >
> > > >XML generated by Betwixt:
> > > >===================
> > > >
> > > ><user>
> > > ><authorizations>
> > > ><Authorization>
> > > ><functionName>read</functionName>
> > > ><objectType>employee</objectType>
> > > ></Authorization>
> > > ><Authorization>
> > > ><functionName>read</functionName>
> > > ><objectType>customer</objectType>
> > > ></Authorization>
> > > ><Authorization>
> > > ><functionName>write</functionName>
> > > ><objectType>employee</objectType>
> > > ></Authorization>
> > > ><Authorization>
> > > ><functionName>write</functionName>
> > > ><objectType>customer</objectType>
> > > ></Authorization>
> > > ></authorizations>
> > > ><firstName>Demo</firstName>
> > > ><id>569</id>
> > > ><lastName>Demo</lastName>
> > > ></user>
> > > >
> > > >
> > > >===============================
> > > >
> > > >which shows that the <authorizations> element takes Authorization
> class
> > > >name
> > > >to generate child elements <Authorization> and I am not pretty sure
> how
> > > to
> > > >get over this.
> > > >
> > > >I have a doubt in my mind, may be its stupid, but is that Betwixt
> >doesnt
> > > >like List ????
> > > >
> > > >Waiting for replies
> > > >
> > > >-Sameer
> > > >
> > > >
> > > >
> > > >
> > > >On 10/2/05, Russell Simpkins < russellsimpkins@hotmail.com> wrote:
> > > > >
> > > > > I think it is the way you have designed your classes that is
> causing
> > > you
> > > > > the problem. Bitwix is only outputting what you have created. If
> you
> > > >want
> > > > > your xml to appear as you have requested, you must re-design your
> > > class
> > > > > code. I think you need to drop the Authorizations class, and let
> >User
> > > >have
> > > > > an array of Authorization and you should get the xml you desire.
> > > > >
> > > > > ----- Original Message -----
> > > > > *From:* Sameer Nanda <sam504u@gmail.com>
> > > > > *To:* commons-user@jakarta.apache.org
> > > > > *Sent:* Sunday, October 02, 2005 1:12 PM
> > > > > *Subject:* Re: Managing XML Output from Betwixt
> > > > >
> > > > > Guys,
> > > > >
> > > > > I tried different things, but still not getting the perfect XML
> >output
> > > > > what
> > > > > I need from Betwixt... Did anyone get a change to look at my
> >problem?
> > > > >
> > > > > Thanks
> > > > > Sam
> > > > >
> > > > > On 9/30/05, Sameer Nanda <sam504u@gmail.com > wrote:
> > > > > >
> > > > > > HI All,
> > > > > >
> > > > > > I have this scenario where I want an XML document to be
> generated
> >by
> > > > > > BEtwixt which should look like this:
> > > > > > ------------------------------
> > > > > >
> > > > > > <user>
> > > > > > <authorizations>
> > > > > >
> > > > > > <authorization>
> > > > > > <functionName>read</functionName>
> > > > > > <objectType>employee</objectType>
> > > > > > </authorization>
> > > > > >
> > > > > > <authorization>
> > > > > > <functionName>read</functionName>
> > > > > > <objectType>customer</objectType>
> > > > > > </authorization>
> > > > > >
> > > > > > <authorization>
> > > > > > <functionName>write</functionName>
> > > > > > <objectType>employee</objectType>
> > > > > > </authorization>
> > > > > >
> > > > > > <authorization>
> > > > > > <functionName>write</functionName>
> > > > > > <objectType>customer</objectType>
> > > > > > </authorization>
> > > > > >
> > > > > > </authorizations>
> > > > > > <firstName>sameer</firstName>
> > > > > > <id>1</id>
> > > > > > <lastName>nanda</lastName>
> > > > > > </user>
> > > > > > ------------------------------
> > > > > >
> > > > > >
> > > > > >
> > > > > > So I have a User Bean which has an id, firstName,lastName and
> > > > > > authorizations of type Authorizations :
> > > > > > ------------------------------
> > > > > >
> > > > > > import java.util.ArrayList;
> > > > > > import java.util.List;
> > > > > >
> > > > > > public class User {
> > > > > >
> > > > > > private int id;
> > > > > > private String firstName;
> > > > > > private String lastName;
> > > > > > private Authorizations authorizations;
> > > > > >
> > > > > > public User() {}
> > > > > >
> > > > > > public User(int id, String firstName, String lastName,
> > > Authorizations
> > > > > > authorizations) {
> > > > > > this.id <http://this.id> <http://this.id> <http://this.id>
<
> http://this.id> = id;
> > > > > > this.firstName = firstName;
> > > > > > this.lastName = lastName;
> > > > > > this.authorizations = authorizations;
> > > > > > }
> > > > > >
> > > > > > public int getId() {
> > > > > > return this.id <http://this.id> <http://this.id>
<http://this.id> <
> http://this.id>;
> > > > > > }
> > > > > > public void setId(int id) {
> > > > > > this.id <http://this.id> < http://this.id> <http://this.id>
<
> http://this.id> = id;
> > > > > > }
> > > > > >
> > > > > > public String getFirstName()
> > > > > > {
> > > > > > return this.firstName;
> > > > > > }
> > > > > > public void setFirstName(String firstName)
> > > > > > {
> > > > > > this.firstName = firstName;
> > > > > > }
> > > > > >
> > > > > > public String getLastName()
> > > > > > {
> > > > > > return this.lastName;
> > > > > > }
> > > > > > public void setLastName(java.lang.String lastName)
> > > > > > {
> > > > > > this.lastName = lastName;
> > > > > > }
> > > > > >
> > > > > > public Authorizations getAuthorizations() {
> > > > > > return this.authorizations;
> > > > > > }
> > > > > > public void setAuthorizations(Authorizations auhtorizations)
{
> > > > > > this.authorizations = authorizations;
> > > > > > }
> > > > > >
> > > > > > }
> > > > > > ------------------------------
> > > > > >
> > > > > >
> > > > > > Then, I have an Authorizations class which has a list of
> > > authorization
> > > > > of
> > > > > > type Authorization (shown below)
> > > > > >
> > > > > > code:
> > > > > > ------------------------------
> > > > > >
> > > > > >
> > > > > >
> > > > > > package mms.Objects;
> > > > > > import java.util.Iterator
> > > > > > ;
> > > > > > import java.util.List;
> > > > > >
> > > > > > public class Authorizations {
> > > > > >
> > > > > > private Authorization[] authorization = new Authorizations[50];
> > > > > >
> > > > > > public Authorizations() {}
> > > > > >
> > > > > > public Authorizations(List l1, List l2) {
> > > > > >
> > > > > > for(int i=0; i < l1.size(); i++) {
> > > > > > String object_type = (String)l1.get(i);
> > > > > > String function_name = (String)l2.get(i);
> > > > > > authorization[i] = new Authorization(object_type,function_name);
> > > > > > }
> > > > > >
> > > > > > }
> > > > > >
> > > > > > public Authorization[] getAuthorization() {
> > > > > > return this.authorization;
> > > > > > }
> > > > > > public void setAuthorization(Authorization[] auhtorization)
{
> > > > > > this.authorization = authorization;
> > > > > > }
> > > > > >
> > > > > >
> > > > > > ------------------------------
> > > > > >
> > > > > >
> > > > > > And finally my Authorization class has a String object_type
and
> > > String
> > > > > > function_name. Here's how the Authorization class looks like:
> > > > > >
> > > > > > code:
> > > > > > ------------------------------
> > > > > >
> > > > > >
> > > > > >
> > > > > > package mms.Objects;
> > > > > >
> > > > > > import java.util.List
> > > > > > ;
> > > > > >
> > > > > > public class Authorization {
> > > > > >
> > > > > > private String objectType;
> > > > > > private String functionName;
> > > > > >
> > > > > > public Authorization() {}
> > > > > > public Authorization(String objectType,String functionName)
{
> > > > > > this.objectType
> > > > > > = objectType;
> > > > > > this.functionName = functionName;
> > > > > > }
> > > > > >
> > > > > > public String getObjectType() {
> > > > > > return this.objectType;
> > > > > > }
> > > > > > public void setObjectType(String objectType) {
> > > > > > this.objectType = objectType;
> > > > > >
> > > > > > }
> > > > > >
> > > > > > public String getFunctionName() {
> > > > > > return this.functionName;
> > > > > > }
> > > > > > public void setFunctionName(String functionName) {
> > > > > > this.functionName = functionName;
> > > > > > }
> > > > > >
> > > > > >
> > > > > > ------------------------------
> > > > > >
> > > > > >
> > > > > >
> > > > > > And now when I call the Authorizations Class passsing two Lists
> l1
> > > and
> > > > > l2
> > > > > > (which are records fetched from the DB) and make a call to
> Betwixt
> > > to
> > > > > > generate XML documents,
> > > > > >
> > > > > > Authorizations a = new Authorizations(l1,l2);
> > > > > >
> > > > > > beanWriter.write("user", new User(1, "abc", "xyz", a));
> > > > > > my_result = outputWriter.toString();
> > > > > >
> > > > > > the XML output that is generated by Betwixt is :
> > > > > >
> > > > > > ------------------------------
> > > > > >
> > > > > >
> > > > > > <user>
> > > > > > <authorizations>
> > > > > > <authorization>
> > > > > > <Authorization>
> > > > > > <functionName>read</functionName>
> > > > > > <objectType>employee</objectType>
> > > > > > </Authorization>
> > > > > > <Authorization>
> > > > > > <functionName>read</functionName>
> > > > > > <objectType>customer</objectType>
> > > > > > </Authorization>
> > > > > > <Authorization>
> > > > > > <functionName>write</functionName>
> > > > > > <objectType>employee</objectType>
> > > > > > </Authorization>
> > > > > > <Authorization>
> > > > > > <functionName>write</functionName>
> > > > > > <objectType>customer</objectType>
> > > > > > </Authorization>
> > > > > > </authorization>
> > > > > > </authorizations>
> > > > > > <firstName>sameer</firstName>
> > > > > > <id>1</id>
> > > > > > <lastName>nanda</lastName>
> > > > > > </user>
> > > > > >
> > > > > > ------------------------------
> > > > > >
> > > > > > which is not really what I want. All I want is a root element
> ><user>
> > > >to
> > > > > > have a <authorizations> which has a bunch of <authorization>
in
> > > them.
> > > > > >
> > > > > > <user>
> > > > > >
> > > > > > <authorizations>
> > > > > >
> > > > > > <authorization>
> > > > > > .........
> > > > > > </authorization>
> > > > > >
> > > > > > <authorization>
> > > > > > ......
> > > > > > </authorization>
> > > > > >
> > > > > > <authorization>
> > > > > > .......
> > > > > > </authorization>
> > > > > >
> > > > > > </authorizations>
> > > > > >
> > > > > > </user>
> > > > > >
> > > > > >
> > > > > >
> > > > > > Can someone help me solve this ???? This is bugging me since
> long
> > > >.....
> > > > > > ALso if anybody could guide to me some working examples on
> Betwixt
> > > >that
> > > > > > would be great.
> > > > > >
> > > > > > Thanks for all the help. Looking forward to hear from someone
> >ASAP.
> > > > > >
> > > > > > Regards
> > > > > > -Sam
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > >
> > >
> > >
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message