Are there some examples of proper generating of XML from queries

Alexander Shopov <[email protected]>
Newsgroups gmane.comp.jakarta.taglibs.user
Message-ID <[email protected]>
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}">
                     &lt;<c:out value="${column.key}"/>&gt;<c:out 
value="${column.value}"/>&lt;/<c:out value="${column.key}"/>&gt;
                 </c:forEach>
             </country>
         </c:forEach>

     </countries>

</jsp:root>
========================================================================



Kind regards:
al_shopov
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.