F
f_Parlant
Hi,
This is the most simple sax parser.
I took it from a java book and transformed it into a jsp page.
But after the class description, how do I tell it to WORK !
I guess I must "call" a function, and pass arguments ... but what
I've tried something like (with no succes):
<%
BandReader montest = new BandReader();
montest.main("webapps/JSPWiki/bands.xml");
%>
**********
*sax2.jsp*
**********
<%@ page import="org.xml.sax.helpers.XMLReaderFactory" %>
<%@ page import="org.xml.sax.XMLReader" %>
<%@ page import="org.xml.sax.SAXException" %>
<%@ page import="org.xml.sax.Attributes" %>
<%@ page import="org.xml.sax.helpers.DefaultHandler" %>
<!%
public class BandReader extends DefaultHandler
{
public static void main(String[] args) throws Exception
{
System.out.println("Here we go ...");
BandReader readerObj = new BandReader();
readerObj.read(args[0]);
}
public void read (String fileName) throws Exception
{
XMLReader readerObj =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
readerObj.setContentHandler (this);
readerObj.parse (fileName);
}
public void startDocument() throws SAXException
{
System.out.println("Starting ...");
}
public void endDocument() throws SAXException
{
System.out.println("... Finished");
}
public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException
{
System.out.println("Element is " + qName);
}
}
%>
//HOW DO I FINISH ??
// I've tried something like
<%
BandReader montest = new BandReader();
montest.main("webapps/JSPWiki/bands.xml");
%>
***** end code ******
Thanks for your help
François
This is the most simple sax parser.
I took it from a java book and transformed it into a jsp page.
But after the class description, how do I tell it to WORK !
I guess I must "call" a function, and pass arguments ... but what
I've tried something like (with no succes):
<%
BandReader montest = new BandReader();
montest.main("webapps/JSPWiki/bands.xml");
%>
**********
*sax2.jsp*
**********
<%@ page import="org.xml.sax.helpers.XMLReaderFactory" %>
<%@ page import="org.xml.sax.XMLReader" %>
<%@ page import="org.xml.sax.SAXException" %>
<%@ page import="org.xml.sax.Attributes" %>
<%@ page import="org.xml.sax.helpers.DefaultHandler" %>
<!%
public class BandReader extends DefaultHandler
{
public static void main(String[] args) throws Exception
{
System.out.println("Here we go ...");
BandReader readerObj = new BandReader();
readerObj.read(args[0]);
}
public void read (String fileName) throws Exception
{
XMLReader readerObj =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
readerObj.setContentHandler (this);
readerObj.parse (fileName);
}
public void startDocument() throws SAXException
{
System.out.println("Starting ...");
}
public void endDocument() throws SAXException
{
System.out.println("... Finished");
}
public void startElement(String uri, String localName, String qName,
Attributes atts) throws SAXException
{
System.out.println("Element is " + qName);
}
}
%>
//HOW DO I FINISH ??
// I've tried something like
<%
BandReader montest = new BandReader();
montest.main("webapps/JSPWiki/bands.xml");
%>
***** end code ******
Thanks for your help
François