-
Create a new tag in XML
I have the following java file(Customer.java).
public class Customer
{
private String ID;
private FirstName firstName;
private MiddleName middleName;
private LastName lastName;
private String streetno;
private String city;
private String pin;
private String phone;
public FirstName getFirstName() {
return firstName;
}
public void setFirstName(FirstName firstName) {
this.firstName = firstName;
}
public String getID() {
return ID;
}
public void setID(String id) {
ID = id;
}
public LastName getLastName() {
return lastName;
}
public void setLastName(LastName lastName) {
this.lastName = lastName;
}
public MiddleName getMiddleName() {
return middleName;
}
public void setMiddleName(MiddleName middleName) {
this.middleName = middleName;
}
public String getStreetNo() {
return streetno;
}
public void setStreetNo(String streetno) {
this.streetno= streetno;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city= city;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone= phone;
}
public String getPin() {
return pin;
}
public void setPin(String pin) {
this.pin= pin;
}
Using castor i have created an xml file(customer.xml) which has the following format.
<?xml version="1.0" encoding="UTF-8" ?>
- <customer ID="fbs0001">
<FIRSTNAME>Fred</FIRSTNAME>
<MIDDLENAME>B</MIDDLENAME>
<LASTNAME>Scerbo</LASTNAME>
<STREETNO>19</STREETNO>
<CITY>Bangalore</CITY>
<PIN>560054</PIN>
<PHONE>9886582108</PHONE>
</customer>
I have used a mapping file to get this output.Is there a way where i can get the output xml in the following format without changing the Java object structure.If yes then please suggest how this can be done.
<?xml version="1.0" encoding="UTF-8" ?>
- <customer ID="fbs0001">
<FIRSTNAME>Fred</FIRSTNAME>
<MIDDLENAME>B</MIDDLENAME>
<LASTNAME>Scerbo</LASTNAME>
<ADDRESS>
<STREETNO>19</STREETNO>
<CITY>Bangalore</CITY>
<PIN>560054</PIN>
<PHONE>9886582108</PHONE>
</ADDRESS>
</customer>
Last edited by tarun.arora; 01-09-2006 at 11:11 PM.
Reason: Change in requirement
-
That would be invalid XML. You will need a root element. Even if you do have a valid root xml, I am not sure you can easily do it with Castor, if at all. Try doing an additional XLT on the original output xml.
Similar Threads
-
By Tim in forum xml.announcements
Replies: 0
Last Post: 10-11-2001, 04:00 PM
-
By xmlstartkabel in forum XML
Replies: 0
Last Post: 10-10-2001, 04:07 AM
-
By Tim Frost in forum xml.announcements
Replies: 0
Last Post: 04-02-2001, 10:53 AM
-
By Extensibility in forum web.announcements
Replies: 0
Last Post: 07-20-2000, 06:20 PM
-
By Sales in forum xml.announcements
Replies: 0
Last Post: 07-20-2000, 06:18 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks