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:$
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:$ 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 % convert to Java string 0030 str = java.lang.String(objTxt); 0031 % open stream on this string 0032 stream = java.io.StringBufferInputStream(str); 0033 % make parser 0034 factory = javaMethod('newInstance',... 0035 'javax.xml.parsers.DocumentBuilderFactory'); 0036 builder = factory.newDocumentBuilder; 0037 0038 xdoc = builder.parse(stream); 0039 0040 % END