Hi
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
<xsp:expr>data</xsp:expr>
output in the result, you can just wrap this with an xml
tag of your choice:
<my-ns:mytag><xsp:expr>data</xsp:expr></my-ns:mytag>
>>> [EMAIL PROTECTED] 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
database.
The problem is when the page is displayed, all the xml tag is
shown...
here is my xsp code :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page
language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
>
<xsp:structure>
<xsp:include>java.util.StringTokenizer</xsp:include>
1 <xsp:include>java.util.List</xsp:include>
<xsp:include>java.util.Collections</xsp:include>
<xsp:include>java.util.ArrayList</xsp:include>
<xsp:include>java.io.File</xsp:include>
<xsp:include>java.io.FileReader</xsp:include>
<xsp:include>java.io.BufferedReader</xsp:include>
<xsp:include>java.io.PrintWriter</xsp:include>
</xsp:structure>
<documents>
<xsp:logic>
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";
</xsp:logic>
<esql:connection>
<esql:pool>cmsDataSource</esql:pool>
<esql:execute-query>
<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 +
"'"</xsp:expr></esql:query>
<esql:results>
<esql:row-results>
<xsp:logic>
page_id = <esql:get-int column="PAGE_ID"/>;
isbn = <esql:get-string column="CATALOG_ISBN"/>;
</xsp:logic>
</esql:row-results>
</esql:results>
</esql:execute-query>
</esql:connection>
<xsp:logic>
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}" );
}
</xsp:logic>
<xsp:expr>data</xsp:expr>
<xsp:logic>
}
}
</xsp:logic>
</documents>
</xsp:page>
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 [EMAIL PROTECTED]
Brel Software Pte Ltd Tel: 65-6272-6800
Blk 1003 Bukit Merah Central Fax: 65-6272-2811
#07-01 http://www.brel.com
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]