Hi Alexander, I was reflecting back on this and I'm not familiar with JSP in XML syntax. I currently use the regular JSP syntax. Probably one is better than the other in certain situations, I was confused about it after reading a few articles on XML syntax .
I think if your application is smaller and not complex it's ok if you use JSTL SQL Tags in the JSP. But, if you want your application to be scalable and it tends to be more complex then, JSTL SQL tags are not recommended. There's supporting mention of this on this article here: http://www.javaworld.com/javaworld/jw-07-2003/jw-0725-morejsp.html?page=3 under "Database access library" MVC only covers the controller and view and the business logic is left to the developer. There might be some patterns or frameworks probably Hibernate that make it scalable to convert from SQL to XML. -Rashmi ----- Original Message ---- From: David Schwartz <[EMAIL PROTECTED]> To: Apache Jakarta Taglibs help <[email protected]> Sent: Friday, November 24, 2006 1:05:52 PM Subject: Re: Are there some examples of proper generating of XML from queries Which database are you using? ------Original Message------ From: Rashmi Rubdi To: Apache Jakarta Taglibs help ReplyTo: Apache Jakarta Taglibs help Sent: Nov 24, 2006 12:26 PM Subject: Re: Are there some examples of proper generating of XML from queries Hi Alexander, I think you might want to consider using a MVC framework to generate the XML from the database. *After* an XML file is generated then, you can easily extract the contents of the XML file with JSTL XML Tags. There are many examples of how JSTL XML Tags are used in the JSTL Spec document. I'm refering to jstl-1_1-mr2-spec.pdf <!-- parse an XML document --> <c:import url=”http://acme.com/customer?id=76567” var=”doc”/> <x:parse doc=”${doc}” var=”parsedDoc”/> <!-- access XML data via XPath expressions --> <x:out select=”$parsedDoc/name”/> <x:out select=”$parsedDoc/address”/> <!-- set a scoped variable --> <x:set var=”custName” scope=”request” select=”$parsedDoc/name”/> You can either parse a document with x:parse and then access the contents of the XML or you can transform an xml file with xslt and you can access the contents of XML this way also. There are many options and they are fully covered in the spec. There are no shortcuts, being a newbie myself I had to read the entire spec (which is very well written and easy to understand) to understand how JSTL works and what options are available. -Rashmi ----- Original Message ---- From: Alexander Shopov <[EMAIL PROTECTED]> To: [email protected] Sent: Friday, November 24, 2006 11:55:52 AM Subject: Are there some examples of proper generating of XML from queries Hi guys, I am using JSTL to generate XML from simple queries. I am doing it like the example I am giving below. I am wondering - is this the right way? Should not XML be generated with some <x:out> expressions (where x is mapped to XML taglib)? Is there to do XPath expressions on variables like "result" from above? I am reading JavaServer Pages Standard Tag Library specs Version 1.2 from Sun but am undecided whether I am doing XML generation the proper way or just making ugly hacks. ======================================================================== <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page";; xmlns:sql="http://java.sun.com/jsp/jstl/sql";; xmlns:c="http://java.sun.com/jsp/jstl/core";; version="2.0"> <jsp:directive.page contentType="text/xml; charset=UTF-8"/> <countries> <sql:setDataSource dataSource="jdbc/wallet" var="ds"/> <sql:query var="result" scope="page" dataSource="${ds}"> SELECT ID as "id", DESCRIPTION as "description" FROM CURRENCY ORDER BY ID </sql:query> <c:forEach var="row" items="${result.rows}"> <country> <c:forEach var="column" items="${row}"> <<c:out value="${column.key}"/>><c:out value="${column.value}"/></<c:out value="${column.key}"/>> </c:forEach> </country> </c:forEach> </countries> </jsp:root> ======================================================================== Kind regards: al_shopov --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] David Schwartz [EMAIL PROTECTED] Array Software Inc. ____________________________________________________________________________________ Want to start your own business? Learn how on Yahoo! Small Business. http://smallbusiness.yahoo.com/r-index --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
