The getInputSource() examples

This example retrieves the XML data stored in column xmlcol and converts it to an object of type InputSource; the InputSource object i can then be used with any SAX or DOM parsing methods:
InputSource i = UtilXML.getInputSource
   (resultset.getString("xmlcol"));
This example uses the implementation of JAXP API, in xerces.jar, to parse fetched XML data in column xmlcol:
InputSource input = UtilXML.getInputSource(resultset.getString("xmlcol"));
SAXParserFactory f = SAXParserFactory.newInstance();
SAXParser parser = f.newSAXParser();
parser.parse(input);
In the examples that follow, tab1 is a table created with the SQL statement:
create table tab1 (col1 lvarchar); 
The following example fetches XML data from an LVARCHAR column into an InputSource object for parsing. This example uses SAX parsing by invoking the parser at org.apache.xerces.parsers.SAXParser.
try
    {
    String sql = "select col1 from tab1";
    Statement stmt = conn.createStatement();
    ResultSet r = stmt.executeQuery(sql);
    Parser p = ParserFactory.makeParser("org.apache.xerces.parsers.SAXParser");
    while(r.next())
        {
        InputSource i = UtilXML.getInputSource(r.getString(1));
        p.parse(i);
        }
    r.close();
    }
    catch (SQLException e)
    {
    // Error handling
    }
The following example fetches XML data from a text column into an InputSource object for parsing. This example is the same example as the previous one, but it uses JAXP factory methods instead of the SAX parser to analyze the data.
try
    {
    String sql = "select col1 from tab2";
    Statement stmt = conn.createStatement();
    ResultSet r = stmt.executeQuery(sql);
    SAXParserFactory factory = SAXParserFactory.newInstance();
    Parser p = factory.newSAXParser();
    while(r.next())
        {
        InputSource i = UtilXML.getInputSource(r.getAsciiStream(1));
        p.parse(i);
        }
    r.close();
    }
    catch (Exception e)
    {
    // Error handling
    }