


MYSQL_GETXDOC retrieves an object with given id from the LTPDA
repository specified by the input database connection. The object is
converted from its XML text format to an Xdoc. This can then be converted
into an object using the appropriate object constructor.
Usage: xdoc = mysql_getXdoc(conn, id)
Inputs:
conn - a database connection object
id - the object id
Outputs:
xdoc - an Xdoc representation of the object.
M Hewitson 30-08-07
$Id: mysql_getXdoc.m,v 1.2 2007/10/17 15:04:27 hewitson Exp $

0001 function xdoc = mysql_getXdoc(conn, id) 0002 0003 % MYSQL_GETXDOC retrieves an object with given id from the LTPDA 0004 % repository specified by the input database connection. The object is 0005 % converted from its XML text format to an Xdoc. This can then be converted 0006 % into an object using the appropriate object constructor. 0007 % 0008 % Usage: xdoc = mysql_getXdoc(conn, id) 0009 % 0010 % Inputs: 0011 % conn - a database connection object 0012 % id - the object id 0013 % 0014 % Outputs: 0015 % xdoc - an Xdoc representation of the object. 0016 % 0017 % M Hewitson 30-08-07 0018 % 0019 % $Id: mysql_getXdoc.m,v 1.2 2007/10/17 15:04:27 hewitson Exp $ 0020 % 0021 % 0022 0023 0024 curs = exec(conn, sprintf('select xml from objs where id="%d"', id)); 0025 curs = fetch(curs); 0026 objTxt = char([curs.Data{1}].'); 0027 close(curs); 0028 0029 0030 % convert to Java string 0031 str = java.lang.String(objTxt); 0032 % open stream on this string 0033 stream = java.io.StringBufferInputStream(str); 0034 % make parser 0035 factory = javaMethod('newInstance',... 0036 'javax.xml.parsers.DocumentBuilderFactory'); 0037 builder = factory.newDocumentBuilder; 0038 0039 xdoc = builder.parse(stream); 0040 0041 % END