cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nadine Carlton" <nadine_carl...@hp.com>
Subject xspParser use and debugging
Date Tue, 05 Dec 2000 17:46:29 GMT
Hi,

  I'm trying to use the xspParser to insert input into my document
from an xml input file.  I'm getting classnotfound exceptions when
I try to run it.  A sample of the code is below.  Does anyone
see what is wrong?  
 
Also, what is the best way to debug these
classnotfound errors?  I tried writing a java program that calls
the xsp processor, similar to the one I use for Xalan debugging,
but it is returning null pointer exceptions even on xml files using
xsp that work correctly.  So, I assume I haven't written that
correctly.  Is there a program to do this?  I've attached my
code that doesn't work.

Nadine Carlton
HP

<?xml version="1.0" ?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?cocoon-format type="text/xml"?>

<Evue:OracleDataSource xmlns:evueODS="http://www.hp.com/evue/">
 
<xsp:page

  language="java"
  xmlns:sql="http://www.apache.org/1999/SQL"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core">
  
  <page title="SQL Search Results">
  <xsp:logic>
  <![CDATA[

     String filename = request.getParameter("filename");
     
        
        if (filename != null) {
          String filepath = XSPUtil.relativeFilename(filename, request, (ServletContext) context);

          <h3 style="color:navy; text-align: center">
            <xsp:expr>filename</xsp:expr>
          </h3>
      
          <xsp:content>
           <xsp:expr>
            
              this.xspParser.parse(
                new InputSource(
                  new FileReader(filepath)
                )
              )
            
           </xsp:expr>
          </xsp:content>
        
        }

     // The page will contain the dom tree.  

     Document doc = this.xspParser.getDocument();
     Element root = doc.getDocumentElement();

     Nodelist nodes = doc.getElementsByTagNameNS(NAMESPACE_URI,"primaryRole");

     if (nodes.getLength() > 0) {
        String primaryRole = nodes.item(0).getFirstChild().getNodeValue();
     }

      ]]>

</xsp:logic>

  </page>
</xsp:page>
 
</Evue:OracleDataSource>

Simple xsp processor program that doesn't work, returning nullpointer
exceptions on valid xml files using xsp:

public class Simplexsp
{
 public static void main(String[] args)
    throws java.io.IOException,
           java.lang.Exception,
           java.net.MalformedURLException,
           org.xml.sax.SAXException
 {
    // result = new java.io.StringWriter();

    XercesParser parser = new XercesParser();
    Document xspdoc = parser.parse(new XSLTInputSource("usecaseinput.xml"));
    // Hashtable parms= new Hashtable();
    // parms.put("request","");
    // parms.put("response","");

    XSPProcessor myxspprocessor = new XSPProcessor();

    Document result = myxspprocessor.process(xspdoc, null);

    
    System.out.println("Stylesheet output: " + result.toString());
 }
}

Mime
View raw message