|
If
you have zero or very little business logic to apply to the data that is
retrieved from the database, then (if using Oracle) I would recommend using the
xml packages found in Oracle 8 onwards. These packages allow you to apply xsl to
the xml lifted out of the tables in the database and only retrieve the wanted
xml.
I
have just implemented a system that relies on xml brokering over a CORBA
interface to integrate with our legacy front end applications. The approach I
used was to use the JAXB packages and unmarshal the received xml strings into
Java objects. This is very useful and fast (although JAXB is nowhere close to
final draft) and because I need to apply a huge amount of business processing to
the information, this was the obvious choice at the end.
Unfortunately this design implies that you are fully
aware of the precise format of the xml that you will receive, and JAXB only
supports DTDs so far. JAXB does buy you a lot of flexibility by alleviating you
to write parsing logic, and also allows you to work with Java objects directly
from xml with only one unmarshalling method call. These JAXB objects also allows
you to marshal your object state back to XML for whatever
purposes...
Hope
this helped!
Alwyn
Hi all, I have used a strange approach to
generating XML based on data retrieved from database and have consequently
displayed it in HTML format using XSL
here is the code ihave used:
Properties pEnv = new Properties(); pEnv.load(new
FileInputStream("C:\\jboss-2.4\\tomcat\\webapps\\ROOT\\jspxml\\abc.dtd"));//loaded
my DTD file in same directory where my XML file will be
generated
try{ *****Creating a string that looks like
XML*****
String xmlG="<?xml version=\"1.0\"
?>\n";
xmlG=xmlG+"<!DOCTYPE abc
>\n\n";
xmlG=xmlG+"<abc>\n";
v5=remote1.getEmployeeNames();//fetching data from database and writng it as
part of string using EJB method call for(int
i=0;i<v5.size();i++) { vRow=new
Vector(); vRow=(Vector)v5.elementAt(i);
xmlG=xmlG+"<people>\n"+
"<person>\n"+ "<name>\n"+
"<firstname>"+(String)vRow.get(1)+"</firstname>\n"+
"<lastname>"+(String)vRow.get(2)+"</lastname>\n"+
"<ecn>"+(String)vRow.get(0)+"</ecn>\n"+
"</name>\n"+
"</person>\n"+
"</people>"; }
xmlG=xmlG+"</abc>"; ******making a xml file using the
String*****
FileOutputStream f= new
FileOutputStream("C:/jboss-2.4/tomcat/webapps/ROOT/jspxml/myxml.xml");
DataOutputStream d= new DataOutputStream(f);
d.writeBytes(xmlG);
}catch(Exception ex) { out.println("
Exceptionin in exp.jsp: "+ex);
}
response.sendRedirect("bookdata.jsp");//here,the xml file generated
together with xsl(written separately) is being converted into html
format for display using Taglibs. %> I have not used any XML parser
for the xml generation ...this works...I had also written a DTD . Is
this the correct approach...what would the negative implications be...can
anyone comment..
thanks in advance, Saurabh
To
change your membership options, refer to:
http://www.sys-con.com/java/list.cfm
|
To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm