Jsp Xerces Checker Plugin Java

From Fxp Wiki

Jump to: navigation, search
 
package vendo;
 
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import java.io.IOException;
import java.io.*;
import com.ecyrd.jspwiki.WikiContext;
import java.util.Map;
import com.ecyrd.jspwiki.plugin.WikiPlugin;
import com.ecyrd.jspwiki.plugin.PluginException;
 
public class XercesCheckerPlugin implements WikiPlugin
{
    public String execute(WikiContext context,
                          Map params)
        throws PluginException
    {
	    String message="";
	    String docname="";
        // Get the names of the XML and XSL files to use
        String document = (String)params.get( "xml" );
 
    DOMParser parser = new DOMParser();
    try {
	    File mydoc = new File(document);
	    docname = mydoc.getName();
      parser.parse(document); 
      message = (docname + " is well-formed.");
    }
    catch (SAXException e) {
      message = ("<br /><b>" + docname + "<br /> </b> is not well-formed.<br />" + e.getMessage());
    }
    catch (IOException e) { 
      message = (
       "Due to an IOException, the parser could not check " 
       + docname
      ); 
    }
   return message;
  }
 
}
 
 
 
Personal tools