From: Tun L. <ch...@si...> - 2004-08-17 10:07:35
|
Hi, Thanks for replying me again. Please pardon me as I am new to XSP. I have tried what you have advised but I still have the following error message: === The content of elements must consist of well-formed character data or markup. === Below is the actual code that I have used: Hope to hear from you soon. ========== <?xml version="1.0"?> <?cocoon-process type="xsp"?> <?cocoon-process type="xslt"?> <?xml-stylesheet href="page-html.xsl" type="text/xsl"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xdb="http://exist-db.org/xmldb/1.0" xmlns:log="http://apache.org/xsp/log/2.0"> <xsp:structure> <xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:i nclude> <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:inclu de> <xsp:include>java.io.BufferedReader</xsp:include> <xsp:include>java.io.FileReader</xsp:include> <xsp:include>java.io.File</xsp:include> <xsp:include>java.util.StringTokenizer</xsp:include> <xsp:include>org.apache.cocoon.servlet.multipart.Part</xsp:include> <xsp:include>org.exist.dom.XMLUtil</xsp:include> </xsp:structure> <xsp:logic> static private int counter = 0; static String list []; private synchronized int count() { return counter++; } private String getDirectory() { File file = new File("C:\\Documents and Settings\\Administrator\\My Documents\\eXist_source_codes_jar\\webapp\\xquery\\db"); String dir=""; if(file.isDirectory()) { list=file.list(); for (int i=0;i<list.length;i++) { dir+=list[i]; } } return dir; } </xsp:logic> <page> <xsp:logic> String[] dirs = getDirectory(); for (int i=0;i < list.length; i++) { <p> <xsp:expr>dirs[i]</xsp:expr> </p> } </xsp:logic> </page> </xsp:page> =========== ----- Original Message ----- From: "Jean-Marc Vanel" <jm...@fr...> To: "Tun Lin" <ch...@si...> Sent: Tuesday, August 17, 2004 2:44 PM Subject: Re: [Exist-open] < and > as < and > problem. > Tun Lin wrote: > > > Hi, > > > > I have tried the following code in xsp. However, xsp only recognise > > < and > as < and > respectively. Also when this is display on > > browser, it will print <p> instead of having a paragraph between the > > lines. How do I make xsp to recognise as a html tag? > > Nothing special, just put: > <p> > > Remember, contrary to JSP, XSP is *real* XML. > > When you need to add a fragment of Java inside an XML part, use > <xsp:logic> > > When you need to add an XML part inside a fragment of Java, use > <xsp:expr> > > See below the modified XSP : > > > > > <xsp:logic> > > private String getDirectory() { > > File file = new File("C:\\Documents and Settings\\Administrator\\My > > Documents\\eXist_source_codes_jar\\webapp\\xquery\\db"); > > String dir=""; > > > > if(file.isDirectory()) { > > String list []; > > list=file.list(); > > > > for (int i=0;i<list.length;i++) { > > dir+=list[i]+"</p>"; > > } > > } > > return dir; > > } > > </xsp:logic> > > I didn't check that code, but it should work, and *please* try to learn > by yourself and look at the examples in the eXist distribution. > > <xsp:logic> > <![CDATA[ > private String[] getDirectory() { > File file = new File("C:\\Documents and Settings\\Administrator\\My > Documents\\eXist_source_codes_jar\\webapp\\xquery\\db"); > String dir[]= new String(0); > > if(file.isDirectory()) { > String list []; > list=file.list(); > > String dir[] = new String(list.length); > for (int i=0;i < list.length; i++) { > dir+=list[i]; > } > } > return dir; > } > > //.... > String[] dirs = getDirectory(); > for (int i=0;i < list.length; i++) { > <p> <xsp:expr>dirs[i]</xsp:expr> </p> > } > ]]> > </xsp:logic> > |