[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Storing XSL Documents In Database

Subject: Re: Storing XSL Documents In Database
From: "Steve Muench" <smuench@xxxxxxxxxxxxx>
Date: Wed, 16 Feb 2000 19:47:16 -0800
oracleresultset rs .getclob 1
| I have a need to store many xsl/xml documents in a 
| database and would like to know what the best solution
| everyone has found is.  I am using Oracle 8i on Solaris,
| and Java.

Assuming you don't *want* to break down the templates
into their own tables (for perhaps doing some dynamic
assembly of the right set of templates based on
runtime personalization info), just storing entire
XML documents as is with Oracle8i your best options are:

   -> CLOB  (Character Large OBject)
   -> BFILE (Reference to an external file)

Both of these types support streaming input and output
interfaces in JDBC. The big difference is that the CLOB
is updateable and stored *in* the database and can be
XML-Search indexed (might not be something you want
to do on Stylesheets, but...) while the BFILE is a 
read-only reference to a file on the external filesystem.

You can read a CLOB from a table like...

  public static CLOB read(Connection conn,
                          String tableName,
                          String colName,
                            String idCol,
                               int idVal) throws Exception {

    PreparedStatement p = conn.prepareStatement("SELECT " + colName   +
                                                "  FROM " + tableName +
                                                " WHERE " + idCol     + "= ?");
    p.setInt(1,idVal);
    OracleResultSet rs = (OracleResultSet)p.executeQuery();
    rs.next();
    CLOB theClob = rs.getCLOB(1);
    rs.close();
    p.close();

    return theClob;
  }

And parse an XML document from a clob like:

  public static XMLDocument read( CLOB theClob ) throws Exception {

    // Create an oracle.xml.parser.v2.DOMParser 
    DOMParser theParser = new DOMParser();

    // Get the input stream from the CLOB
    Reader in = theClob.getCharacterStream();

    // Parse the document from the stream
    theParser.parse(in);
    in.close();

    // Get the parsed XML Document from the parser
    return theParser.getDocument();

  }

__________________________________________________________
Steve Muench, Lead XML Evangelist / Consulting Product Mgr
Oracle Corp, Business Components for Java Development Team
http://technet.oracle.com/tech/xml




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.