cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <>
Subject Re: How to include a xml to a xsp ?
Date Mon, 07 Jun 2004 11:19:24 GMT

Why not separate this operation into a number of steps:
1. read the data in from the file and/or database
2. process them to get the resulting output; this
step could be tackled via XSLT - XSP is not really
ideal for doing this type of processing
3. transform the resulting data into presentation...

However, if you really just want the 
output in the result, you can just wrap this with an xml
tag of your choice:


>>> 2004/06/07 12:55:13 PM >>>
Hi all,

   currently, i am developing a program that able to merge data in the
database and the data in 
xml file. I have created a xsp file that able to read data from
database and open a xml file. 
the xsp will then read the xml file and replace some of the identifier
with the data from 

  The problem is when the page is displayed, all the xml tag is

here is my xsp code :

<?xml version="1.0" encoding="ISO-8859-1"?>


1  <xsp:include>java.util.List</xsp:include>


   int page_id = 0;
   int folder_id = 0;      
   String isbn = null;
   String servletPath = "";
   String filePath = "E:/Tomcat-4.1/webapps/tpl/xml/";  
   servletPath = request.getServletPath();
   servletPath = servletPath.substring(1, servletPath.lastIndexOf(".")

   filePath = filePath + servletPath + ".xml";   

      <esql:query><xsp:expr>"select p.PAGE_ID, c.CATALOG_ISBN from
catalog c, page p where 
c.PAGE_ID=p.PAGE_ID and p.PAGE_PATH='" + servletPath +
             page_id = <esql:get-int column="PAGE_ID"/>;
             isbn = <esql:get-string column="CATALOG_ISBN"/>;          


if( page_id > 0 )
    //here i read the xml file..
      BufferedReader br = new BufferedReader( new FileReader( new
File(filePath) ) );      
      System.out.println("filePath : " + filePath );
      System.out.println("isbn : " + isbn );
      String data = null;
      //read the xml file and replace it with the data from database.
  while( ( data = br.readLine() ) != null )
      if( data.indexOf("{isbn}") != -1 )
          data = data.replaceAll( isbn, "{isbn}" );

how to return the result (<xsp:expr>data</xsp:expr>), so cocoon able to
parse and transform the 
result with xsl file ?

Thanks you.

Ling Kok Choon                
Brel Software Pte Ltd                  Tel: 65-6272-6800
Blk 1003 Bukit Merah Central           Fax: 65-6272-2811
Singapore 159836                       06/07/04 18:55:13
           Pls call us for the following services
         Web Creation, Web, Email & Domain Hosting
           Java Devt B2B B2C ASP CMS E-Commerce


To unsubscribe, e-mail: 
For additional commands, e-mail: 

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message