struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph Barefoot" <jose...@hereuare.com>
Subject RE: XML approach
Date Fri, 28 Jun 2002 21:25:22 GMT
I don't have anything to add to the XML-Java Object mapping discussion, but
I did notice that you are doing your database performance testing by loading
a flat-file of SQL statements as the first step.  So, you may find the
following useful:

I have written an engine that parses an XML template composed of SQL
queries, and produces a result XML document that contains the results of the
hierarchical queries, i.e., it "fills in" the template with the results.
The engine uses a custom syntax to do runtime replacement of query parameter
placeholders with either external query parameters or values retrieved from
a previously executed query result contained in the current (being created
in memory) result document.

For example, my engine would accept a template like the following:

<?xml version="1.0"?>
<Customer>
 <ACCOUNT--row   query="select * from account where userID like {userID}"
elementLabel="{account_seq}">
   <CUST--row   query="select * from cust where cust_seq={parent.cust_seq}"
elementLabel="{cust_seq}"/>
   <PYMNT_INSTR_ITEMS>
     <PYMNT_INSTR_ITEMS--row   query="select * from PYMT_INSTR_ITEMS where
cust_seq={parent.parent.cust_seq}" elementLabel="{pymt_instr_items_seq}">
       <AUTH_ITEMS--row    query="select * from AUTH_ITEMS where
pymt_instr_items_seq={parent.pymt_instr_items_seq}"
elementLabel="{auth_items_seq}" >
         <CC_CREDIT--row    query="select * from CC_CREDIT where
auth_items_seq={parent.auth_items_seq}"  elementLabel="{cc_credit_seq}"/>
       </AUTH_ITEMS--row>
     </PYMNT_INSTR_ITEMS--row>
   </PYMNT_INSTR_ITEMS>
   <USER_BILLING>
     <USER_BILLING--row    query="select * from USER_BILLING where
cust_seq={parent.parent.cust_seq}"  elementLabel="{user_billing_seq}">
       <AUTH_ITEMS--row    query="select * from AUTH_ITEMS ai,
USER_BILLING_TXN ubt where ubt.user_billing_seq={parent.user_billing_seq}
and ubt.auth_items_seq=ai.auth_items_seq" elementLabel="{auth_items_seq}">
         <CC_CREDIT--row    query="select * from CC_CREDIT where
auth_items_seq={parent.auth_items_seq}"  elementLabel="{cc_credit_seq}"/>
       </AUTH_ITEMS--row>
     </USER_BILLING--row>
   </USER_BILLING>
   <USER_RATE_PLAN>
     <USER_RATE_PLAN--row    query="select * from USER_RATE_PLAN where
userID={userID}" elementLabel="{user_rate_plan_seq}"/>
   </USER_RATE_PLAN>
 </ACCOUNT--row>
</Customer>

The engine would create a result document from the template above that
contained the aggregated, hierarchical data for every user in the database
who matched the external query parameter "userID".

The engine itself is dependent on JDOM and of course JAXP in order to run.
You must also supply a connection for it, etc., for it to work.  If you're
interested, let me know, and I'll send you a zip file containing the source.
I have some minimal documentation to go along with it, but the code itself
is fairly well documented.  There's also a test class that you can modify to
use different database drivers to test the engine.

I also have a Struts Action and ActionForm, plus some JavaScript and JSP
pages to render the results in a tree view, but the code for it is in flux,
as I was attempting to decouple it from out codebase and make the Action an
abstract class.  It's included in the aforementioned zip file, but you'll
have to muck with it quite a bit to get it to work.

I intend to open-source this as a database debugging tool in a
self-contained WAR file at some point, but I have some work to do first....


peace,
Joe Barefoot




> -----Original Message-----
> From: Robert Williams [mailto:rjwms@attbi.com]
> Sent: Friday, June 28, 2002 1:05 PM
> To: Struts Users Mailing List
> Subject: Re: XML approach
>
>
> You might also look at JAXB (the Java data binding approach).  Try:
> http://developer.java.sun.com/developer/technicalArticles/xml/jaxb/
>
> Another option is the XML Mapping capability of Castor
> http://www.castor.org/.
>
> bob
>
> ----- Original Message -----
> From: "Martin Cooper" <martin.cooper@tumbleweed.com>
> To: "'Struts Users Mailing List'" <struts-user@jakarta.apache.org>
> Sent: Friday, June 28, 2002 2:44 PM
> Subject: RE: XML approach
>
>
> > For something like this, I would use the Commons Digester. For your
> example,
> > you'll probably need only three lines of code to configure the parse.
> >
> > Struts also uses the Digester to read its configuration data, so you'll
> find
> > examples of its use there, if you need them. The documentation for the
> > Digester, however, is excellent.
> >
> > --
> > Martin Cooper
> >
> >
> > > -----Original Message-----
> > > From: Michael Marrotte [mailto:marrotte@nicusa.com]
> > > Sent: Friday, June 28, 2002 12:35 PM
> > > To: struts-user@jakarta.apache.org
> > > Subject: XML approach
> > >
> > >
> > > This might not be the best place to ask.  But, after all it was a
> > > struts-example that gave me the idea :)
> > >
> > > I'm doing some database performance testing using Java.  The
> > > application
> > > needs to load a flat-file of SQL select statements.  I will
> > > transform the
> > > SQL to XML --  define at set of queries in an XML file e.g.:
> > >
> > > <queries>
> > > <query>
> > > <values p1="v1" p2="v2"/>
> > > </query>
> > > <query>
> > > <values p1="v1" p2="v2"/>
> > > </query>
> > > <query>
> > > <values p1="v1" p2="v2"/>
> > > </query>
> > > </queries>
> > >
> > >
> > > I would like to read/map this XML file to a Java object, e.g.
> > > a map of some
> > > sort.
> > >
> > > However, I'm not sure what tools I should look into.  There
> > > seems to be a
> > > few projects out there that talk about doing XML parsing, mapping,
> > > validating, e.g. Digester, Crimson, Xerces, etc.  But, I'm
> > > not sure which
> > > ones I should start digging into.  So, I thought I'd ask
> > > around and get
> > > advice on where to start.
> > >
> > > If you understand my problem and have any ideas about where I
> > > should begin
> > > and/or an approach to solve this problem, please let me know.
> > >
> > > Thanks,
> > >
> > > --Michael Marrotte
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:struts-user-help@jakarta.apache.org>
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message