Example usage for org.xml.sax SAXException printStackTrace

List of usage examples for org.xml.sax SAXException printStackTrace

Introduction

In this page you can find the example usage for org.xml.sax SAXException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.notesrender.templatej.TemplateProcessor.java

public void process(String filePath) {
    try {/*from  www .j a v  a  2 s .  com*/
        XMLReader rd = XMLReaderFactory.createXMLReader();
        rd.setContentHandler(this);
        rd.parse(new InputSource(new FileInputStream(filePath)));

        String fullFilePath = new File(filePath).getAbsolutePath();
        String dir = FilenameUtils.getFullPath(fullFilePath);
        String tplFullFilePath = new File(dir, _ref).getAbsolutePath();
        String outFullFilePath = new File(dir, _out).getAbsolutePath();

        _writer = new PrintWriter(new BufferedWriter(new FileWriter(outFullFilePath)));
        rd.parse(new InputSource(new FileInputStream(tplFullFilePath)));
        _writer.close();
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.phildatoon.weather.WOEIDUtils.java

private Document convertStringToDocument(Context context, String src) {
    MyLog.d("convert string to document");
    Document dest = null;/*w  ww .j a v a 2s .  c o  m*/

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser;

    try {
        parser = dbFactory.newDocumentBuilder();
        dest = parser.parse(new ByteArrayInputStream(src.getBytes()));
    } catch (ParserConfigurationException e1) {
        e1.printStackTrace();
        Toast.makeText(context, e1.toString(), Toast.LENGTH_LONG).show();
    } catch (SAXException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    }

    return dest;
}

From source file:de.l3s.boilerpipe.sax.HtmlArticleExtractor.java

/**
 * returns the amp url from an document//from   ww  w.  j a  v a  2 s  . c  om
 *
 * @param HTMLDocument
 * @return String
 */

private URL getAmpUrl(HTMLDocument htmlDoc) throws MalformedURLException {
    final InputSource is = htmlDoc.toInputSource();
    AmpUrlExtractor extractor = AmpUrlExtractor.INSTANCE;

    try {
        extractor.parse(is);
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (StringUtils.isEmpty(extractor.getAmpUrl())) {
        return null;
    }
    return new URL(extractor.getAmpUrl());
}

From source file:in.gov.uidai.core.aua.client.BfdClient.java

private BfdRes parseBfdResponseXML(String xmlToParse) throws JAXBException {

    //Create an XMLReader to use with our filter 
    try {//from w  ww .ja  v a  2  s .  co m
        //Prepare JAXB objects 
        JAXBContext jc = JAXBContext.newInstance(BfdRes.class);
        Unmarshaller u = jc.createUnmarshaller();

        XMLReader reader;
        reader = XMLReaderFactory.createXMLReader();

        //Create the filter (to add namespace) and set the xmlReader as its parent. 
        NamespaceFilter inFilter = new NamespaceFilter("http://www.uidai.gov.in/auth/uid-bfd-response/1.0",
                true);
        inFilter.setParent(reader);

        //Prepare the input, in this case a java.io.File (output) 
        InputSource is = new InputSource(new StringReader(xmlToParse));

        //Create a SAXSource specifying the filter 
        SAXSource source = new SAXSource(inFilter, is);

        //Do unmarshalling 
        BfdRes res = u.unmarshal(source, BfdRes.class).getValue();
        return res;
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return null;
}

From source file:util.ReadXml.java

public ReadXml(String xmlFile, String beanFile) {
    this.xmlFile = xmlFile;

    //BeanFactory
    resource = new FileSystemResource(beanFile);
    factory = new XmlBeanFactory(resource);

    //DOMparser factory
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {//from   ww  w  .  jav a 2 s . c om

        //Using factory get an instance of document builder
        DocumentBuilder db = dbf.newDocumentBuilder();

        //parse using builder to get DOM representation of the XML file
        dom = db.parse(xmlFile);
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    } catch (SAXException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

    //get the root elememt
    docEle = dom.getDocumentElement();

}

From source file:com.example.apis.ifashion.WOEIDUtils.java

private Document convertStringToDocument(Context context, String src) {
    YahooWeatherLog.d("convert string to document");
    Document dest = null;/*from w w w  .j av  a 2s  .c  om*/

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser;

    try {
        parser = dbFactory.newDocumentBuilder();
        dest = parser.parse(new ByteArrayInputStream(src.getBytes()));
    } catch (ParserConfigurationException e1) {
        e1.printStackTrace();
        Toast.makeText(context, e1.toString(), Toast.LENGTH_LONG).show();
    } catch (SAXException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    }

    return dest;

}

From source file:com.doculibre.constellio.lang.html.HtmlLangDetector.java

public String getLang(String htmlContent) {

    DOMParser parser = new DOMParser();
    final StringReader contentReader = new StringReader(htmlContent);
    final InputSource input = new InputSource(contentReader);
    try {/* w  ww  .  java2s  . c  o m*/
        parser.parse(input);
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    List<String> langs = this.parse(parser.getDocument());
    if (!langs.isEmpty()) {
        return langs.get(0);
    }
    return null;
}

From source file:net.i2cat.netconf.transport.VirtualTransport.java

public VirtualTransport() {
    listeners = new Vector<TransportListener>();

    xmlHandler = new TransportContentParser();

    // populate/* w w w  .  j  a  v  a2  s .com*/
    try {
        parser = XMLReaderFactory.createXMLReader();
        parser.setContentHandler(xmlHandler);
        parser.setErrorHandler(xmlHandler);
    } catch (SAXException e) {
        e.printStackTrace();
    }
}

From source file:info.androidhive.androidsplashscreentimer.WOEIDUtils.java

private Document convertStringToDocument(Context context, String src) {
    MyLog.d("convert string to document");
    Document dest = null;//from ww w . ja  v  a 2  s.c  o  m

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser;

    try {
        parser = dbFactory.newDocumentBuilder();
        dest = parser.parse(new ByteArrayInputStream(src.getBytes()));
    } catch (ParserConfigurationException e1) {
        e1.printStackTrace();
        Toast.makeText(context, e1.toString(), Toast.LENGTH_LONG).show();
    } catch (SAXException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    }

    return dest;

}

From source file:in.gov.uidai.auth.aua.httpclient.BfdClient.java

private BfdRes parseBfdResponseXML(String xmlToParse) throws JAXBException {

    //Create an XMLReader to use with our filter 
    try {/* w  ww  .  j  a va  2s  .  c om*/
        //Prepare JAXB objects 
        JAXBContext jc = JAXBContext.newInstance(BfdRes.class);
        Unmarshaller u = jc.createUnmarshaller();

        XMLReader reader;
        reader = XMLReaderFactory.createXMLReader();

        //Create the filter (to add namespace) and set the xmlReader as its parent. 
        NamespaceFilter inFilter = new NamespaceFilter(
                "http://www.uidai.gov.in/authentication/uid-bfd-response/1.0", true);
        inFilter.setParent(reader);

        //Prepare the input, in this case a java.io.File (output) 
        InputSource is = new InputSource(new StringReader(xmlToParse));

        //Create a SAXSource specifying the filter 
        SAXSource source = new SAXSource(inFilter, is);

        //Do unmarshalling 
        BfdRes res = u.unmarshal(source, BfdRes.class).getValue();
        return res;
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return null;
}