I figured at least someone "might" find it useful. I know I HATE putting SQL into Java strings, and trying to copy/paste that out into an SQL tool. And, iBatis isn't any better (for the copy/paste problem) if you do use fragments. And, I can't do without fragments (LOL), so I figured it's nice to be able to view the whole SQL query.
On a side note, if anyone else has additions to it, I'd appreciate getting a hold of them! :D Perhaps we can have this put on the iBatis website, and people can send suggestions in for new features for the XSL? I haven't used iBatis a whole lot yet, so I'm sure there's more things that can be done with it, such as transforming other forms of iBatis configurations that perhaps I don't know about. Thanks. Trenton D. Adams Systems Analyst/Web Software Engineer Navy Penguins at your service! Athabasca University (780) 675-6195 :wq! ----- "Jeff Stahl" <[email protected]> wrote: > From: "Jeff Stahl" <[email protected]> > To: [email protected] > Sent: Wednesday, January 28, 2009 1:37:06 PM GMT -07:00 US/Canada Mountain > Subject: Re: XSL transformation > > Doesn't matter if it's actually useful for anybody or not. Nice!! > > Jeff Stahl > > Trenton D. Adams wrote: > > Hi Everyone, > > > > I'm not sure if this is useful for you or not. But, I created an > XSL file to transform iBatis configurations into beans and SQL > fragments into full SQL output. > > > > I have attached an example. > > > > > > It is helpful to open the xml file in your browser, as the XSL file > will automatically create a "full" SQL output for you. For example, > the fragment below, uses a fragment called "ledgerTypeSelect"... > > > > <select id="getLedger" resultMap="LedgerTypes" > > parameterClass="java.util.Map"> > > <include refid="ledgerTypeSelect"/> > > > > WHERE ledger_id = #ledgerID#; > > </select> > > > > <sql id="ledgerTypeSelect"> > > SELECT ledger_id, > > ledger_name, > > ledger_description, > > ledger_number > > FROM ledger_types > > </sql> > > > > If opening the ledger.xml in the browser, it will translate the > "getLedger" select statement into a complete select statement for you, > by automatically including the refid element into the output. And, it > even includes one line comments to let you know which fragment was > included. Pretty cool. That way it is easy to copy and paste SQL > into tora, toad, or some other SQL tool, etc, for testing. > > > > So, the output is like so. As you can see, it tells you the > beginning of the included fragment. > > -- BEGIN getLedger > > > > -- BEGIN ledgerTypeSelect > > SELECT ledger_id, > > ledger_name, > > ledger_description, > > ledger_number > > FROM ledger_types > > > > -- END ledgerTypeSelect > > WHERE ledger_id = #ledgerID#; > > > > -- END getLedger > > > > Trenton D. Adams > > Systems Analyst/Web Software Engineer > > Navy Penguins at your service! > > Athabasca University > > (780) 675-6195 > > :wq! > > > > __ > > This communication is intended for the use of the recipient to > whom it > > is addressed, and may contain confidential, personal, and or > privileged > > information. Please contact us immediately if you are not the > intended > > recipient of this communication, and do not copy, distribute, or > take > > action relying on it. Any communications received in error, or > > subsequent reply, should be deleted or destroyed. > > --- > >
