[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Storing XSL Documents In Database
| 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|