View Javadoc

1   package net.sf.crispy.impl.rest;
2   
3   import java.io.StringReader;
4   
5   import javax.xml.parsers.SAXParser;
6   import javax.xml.parsers.SAXParserFactory;
7   
8   import org.xml.sax.InputSource;
9   import org.xml.sax.helpers.DefaultHandler;
10  
11  public class Parser {
12  	
13  	public void parse (String pvXmlString) throws Exception {
14  		parse(pvXmlString, null);
15  	}
16  	
17  	public void parse (String pvXmlString, DefaultHandler pvDefaultHandler) throws Exception {
18  		SAXParser lvParser = SAXParserFactory.newInstance().newSAXParser();		
19  		StringReader lvReader = new StringReader(pvXmlString);
20  		if (pvDefaultHandler == null) {
21  			lvParser.parse(new InputSource(lvReader), new DefaultHandler());
22  			} else {
23  				lvParser.parse(new InputSource(lvReader), pvDefaultHandler);		
24  			}
25  				
26  	}
27  	
28  //	String lvParserClass = "org.apache.xerces.parsers.SAXParser";
29  //	XMLReader lvReader = XMLReaderFactory.createXMLReader(lvParserClass);
30  //	StringReader lvStringReader = new StringReader(pvXmlStr);
31  //	lvReader.setContentHandler(this);
32  //	lvReader.parse(new InputSource(lvStringReader));
33  
34  	
35  
36  }