Trying to Insert an XML Element into XML data stored in CLOB column
Hi all,
My ORACLE DB version is:
('Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production');
('PL/SQL Release 11.2.0.2.0 - Production');
('CORE 11.2.0.2.0 Production');
('TNS for Linux: Version 11.2.0.2.0 - Production');
('NLSRTL Version 11.2.0.2.0 - Production');
I have this XML data stored in a CLOB column:
<Activity>
<Changes>
</Changes>
<Inserts>
</Inserts>
<Definition>
</Definition>
<Assignment TYPE="Apply">
</Assignment>
<Spawned>
<Activity>576D8CD9-57A1-8608-1563-8F6DC74BDF3C</Activity>
<Activity>11226E79-5D24-02EB-A950-D34A9CCFB3FF</Activity>
<Activity>DAA68DC0-CA9A-BB15-DE31-9596E19513EE</Activity>
<Activity>93F667D6-966A-7EAD-9B70-630D9BEFDDD2</Activity>
<Activity>FA63D9D3-86BB-3FF0-BE69-17EAA7581637</Activity>
</Spawned>
<SpawnedBy>AFC49BD4-5AA7-38C0-AE27-F59D16EE1B1C</SpawnedBy>
</Activity>
I am in need of some assistance in creating an update that will insert another <Activity>SomeGUID</Activity> into the <Spawned> parent.
Any help is greatly appreciated.
Thanks.
Edited by: 943783 on Dec 14, 2012 12:58 PM
See XML updating functions : http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb04cre.htm#i1032611
For example :
UPDATE my_table t
SET t.my_clob =
XMLSerialize(document
insertChildXML(
XMLParse(document t.my_clob)
, '/Activity/Spawned'
, 'Activity'
, XMLElement("Activity", 'Some GUID')
WHERE ...
;Although it works, there's overhead introduced by parsing the CLOB, then serializing again.
Is there any chance you can change the CLOB to SECUREFILE binary XMLType storage instead?
You would then be able to benefit from optimized piecewise update of the XML and improved storage.
Similar Messages
-
How to publish XML document whose source is stored in clob column
I have to create simple application:
in one table are stored some information about XML documents (date of creation, etc.) and the document source itself in one (unfortunatelly clob type) column.
The point is to anable users finding document(s) and viewing it.
Using forms I can search and display information about documents. But I have no idea how to publish XML document whose source is stored in clob column.
I am using Oracle Portal 3.0 on NT.
Thanks in advance.Hi Sergio,
This link might be helpful:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/apex31blob.htm
Also refer the BLOB Download Format Mask :
{message:id=9716335}
Here I have given the format mask for APEX 4.0, which will slightly differ for 3.2.1 and proposed changes
in the format mask are:
1) Format Mask: DOWNLOAD
2) Content Disposition: Inline
This will be achieved with it:
>
But now, my user would like to know if it´s possible that APEX application can OPEN some of these files stored on this BLOB column WITHOUT download it.
My user would like to see a hiperlink (or button) that, if pressed/acessed, can open a new page (or a page inside application) with the document. He doesn´t need to edit this oppened file. He only wants to see it.
>
Hope it helps!
Regards,
Kiran -
Update XML data stored in CLOB Column
Hi All,
i am new to Oracle and new to SQL
i am trying to update XML data stored in CLOB cloumn,data is stored with the follwoing format
<attrs><attr name="name"><string>Schade</string></attr></attrs>
i am using the following query for updating the value
UPDATE PRODUCT p SET ATTRIBUTES_nl_nl=UPDATEXML(XMLTYPE.createXML(ATTRIBUTES_nl_nl),'/attrs/attr[@name="name"]/string/text()','Schade').getClobVal() WHERE p.sku='000000000000040576_200911-5010057'
this query is working fine but it changing the data to the following format
<attrs><attr name="name">Schade</attr></attrs>
some how it is ommiting the <string> tag from it, i am unable to figure it out whats the reason.
any help in this regard will b e much appriciated
Thanks in Advance
-UmeshHi,
You should have created your own thread for this, and included database version.
This works for me on 11.2.0.2 and 10.2.0.5 :
SQL> create table t_org ( xml_clob clob );
Table created
SQL>
SQL> insert into t_org
2 values(
3 '<Message>
4 <Entity>
5 <ASSIGNMENT>
6 <OAVendorLocation> </OAVendorLocation>
7 <Vendorid>1</Vendorid>
8 </ASSIGNMENT>
9 </Entity>
10 </Message>'
11 );
1 row inserted
SQL> commit;
Commit complete
SQL> select '*' ||
2 extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
3 || '*' as result
4 from t_org;
RESULT
SQL> update t_org set xml_clob =
2 updatexml(xmltype(xml_clob),
3 '/Message/Entity/ASSIGNMENT/OAVendorLocation/text()','LONDON').getClobVal()
4 ;
1 row updated
SQL> select '*' ||
2 extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
3 || '*' as result
4 from t_org;
RESULT
*LONDON*
Does the OAVendorLocation really have a whitespace value?
If not then it's expected behaviour, you're trying to update a text() node that doesn't exist. In this case, the solution is to use appendChildXML to create the text() node, or update the whole element.
Is it your real document? Do you actually have some namespaces? -
Possible to Convert XML element into XML comments?
Dear All,
I need to automate perticular elements to be convertToXMLComments in InDesign using XML rule processer.
It's Possible in InDesign Javascript (CS3 5.0.4 - windows)? else to help me any alternative ways?
Thanks,
NagarajYou have to Imagine using conversion of comments
-
Moving an existing xml element into aTable
Hi Everyone,
After importing the xml I need to place or convert the xml elements into the table. Is there any way to do this by JS?
Here is the sample Table xml elements....
<table-wrap id="ch3_t1">
<label>Table 3.1</label>
<caption>
<title>Anatomy and Classification of Major Hepatic Resections</title>
</caption>
<table>
<thead>
<tr>
<th align="left" valign="top" colspan="5">Anatomic Classification</th>
</tr>
<tr>
<th align="left" valign="top">Couinaud</th>
<th align="left" valign="top" colspan="2">Goldsmith and Woodburne</th>
<th align="left" valign="top">Brisbane</th>
<th align="left" valign="top">Segments resected</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="top">Right hepatectomy</td>
<td align="left" valign="top" colspan="2">Right hepatic lobectomy</td>
<td align="left" valign="top">Right hemihepatectomy</td>
<td align="left" valign="top">V, VI, VII, VIII</td>
</tr>
<tr>
<td align="left" valign="top">Right lobectomy<sup>a</sup>
</td>
<td align="left" valign="top" colspan="2">Extended right hepatic lobectomy</td>
<td align="left" valign="top">Right trisectionectomy</td>
<td align="left" valign="top">IV,V,VI, VII, VIII<sup>b</sup>
</td>
</tr>
<tr>
<td align="left" valign="top">Left hepatectomy</td>
<td align="left" valign="top" colspan="2">Left hepatic lobectomy</td>
<td align="left" valign="top">Left hemihepatectomy</td>
<td align="left" valign="top">II, III, IV</td>
</tr>
<tr>
<td align="left" valign="top">Extended left hepatectomy<sup>a</sup>
</td>
<td align="left" valign="top" colspan="2">Extended left lobectomy</td>
<td align="left" valign="top">Left lateral sectionectomy</td>
<td align="left" valign="top">II, III, IV, V, VIII<sup>b</sup>
</td>
</tr>
<tr>
<td align="left" valign="top">Left lobectomy</td>
<td align="left" valign="top" colspan="2">Left lateral segmentectomy</td>
<td align="left" valign="top">Left trisectionectomy</td>
<td align="left" valign="top">II, III</td>
</tr>
</tbody>
</table>
</table-wrap>
Looking forward your replies... Your help will be thankful....You may want to look again, specifically section 20.11 Moving Oracle Enterprise Content Management to a Production System, Task 4.
The same basic steps would apply to 10g, minus the WebLogic parts. (Also note that prior to 11g, what you are attempting is really a non-supported configuration. In 11g, Oracle at least gives this set of supported pointers.) -
Simple Transformation to deserialize an XML file into ABAP data structures?
I'm attempting to write my first simple transformation to deserialize
an XML file into ABAP data structures and I have a few questions.
My simple transformation contains code like the following
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns:pp="http://www.sap.com/abapxml/types/defined" >
<tt:type name="REPORT" line-type="?">
<tt:node name="COMPANY_ID" type="C" length="10" />
<tt:node name="JOB_ID" type="C" length="20" />
<tt:node name="TYPE_CSV" type="C" length="1" />
<tt:node name="TYPE_XLS" type="C" length="1" />
<tt:node name="TYPE_PDF" type="C" length="1" />
<tt:node name="IS_NEW" type="C" length="1" />
</tt:type>
<tt:root name="ROOT2" type="pp:REPORT" />
<QueryResponse>
<tt:loop ref="ROOT2" name="line">
<QueryResponseRow>
<CompanyID>
<tt:value ref="$line.COMPANY_ID" />
</CompanyID>
<JobID>
<tt:value ref="$line.JOB_ID" />
</JobID>
<ExportTypes>
<tt:loop>
<ExportType>
I don't know what to do here (see item 3, below)
</ExportType>
</tt:loop>
</ExportTypes>
<IsNew>
<tt:value ref="$line.IS_NEW"
map="val(' ') = xml('false'), val('X') = xml('true')" />
</IsNew>
</QueryResponseRow>
</tt:loop>
</QueryResponse>
</tt:loop>
1. In a DTD, an element can be designated as occurring zero or one
time, zero or more times, or one or more times. How do I write the
simple transformation to accommodate these possibilities?
2. In trying to accommodate the "zero or more times" case, I am trying
to use the <tt:loop> instruction. It occurs several layers deep in the
XML hierarchy, but at the top level of the ABAP table. The internal
table has a structure defined in the ABAP program, not in the data
dictionary. In the simple transformation, I used <tt:type> and
<tt:node> to define the structure of the internal table and then
tried to use <tt:loop ref="ROOT2" name="line"> around the subtree that
can occur zero or more times. But every variation I try seems to get
different errors. Can anyone supply a working example of this?
3. Among the fields in the internal table, I've defined three
one-character fields named TYPE_CSV, TYPE_XLS, and TYPE_PDF. In the
XML file, I expect zero to three elements of the form
<ExportType exporttype='csv' />
<ExportType exporttype='xls' />
<ExportType exporttype='pdf' />
I want to set field TYPE_CSV = 'X' if I find an ExportType element
with its exporttype attribute set to 'csv'. I want to set field
TYPE_XLS = 'X' if I find an ExportType element with its exporttype
attribute set to 'xls'. I want to set field TYPE_PDF = 'X' if I find
an ExportType element with its exporttype attribute set to 'pdf'. How
can I do that?
4. For an element that has a value like
<ErrorCode>123</ErrorCode>
in the simple transformation, the sequence
<ErrorCode> <tt:value ref="ROOT1.CODE" /> </ErrorCode>
seems to work just fine.
I have other situations where the XML reads
<IsNew value='true' />
I wanted to write
<IsNew>
<tt:value ref="$line.IS_NEW"
map="val(' ') = xml('false'), val('X') = xml('true')" />
</IsNew>
but I'm afraid that the <tt:value> fails to deal with the fact that in
the XML file the value is being passed as the value of an attribute
(named "value"), rather than the value of the element itself. How do
you handle this?Try this code below:
data l_xml_table2 type table of xml_line with header line.
W_filename - This is a Path.
if w_filename(02) = '
open dataset w_filename for output in binary mode.
if sy-subrc = 0.
l_xml_table2[] = l_xml_table[].
loop at l_xml_table2.
transfer l_xml_table2 to w_filename.
endloop.
endif.
close dataset w_filename.
else.
call method cl_gui_frontend_services=>gui_download
exporting
bin_filesize = l_xml_size
filename = w_filename
filetype = 'BIN'
changing
data_tab = l_xml_table
exceptions
others = 24.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif. -
Got error message when store XML documents into XML DB repository, via WebD
Hi experts,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I got error message when store XML documents into XML DB repository, via WebDAV.
I have successfully registered 5 related schemas and generated 1 table.
I have inserted 40 .xml files into this auto generated table.
using these data I created relational view successfully.
but since I couldn't store XML documents into XML DB repository, via WebDAV
when I query using below code:
SELECT rv.res.getClobVal()
FROM resource_view rv
WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
I got nothing.
My ftp code is listed below:
ftp> open localhost 2100
Connected to I0025B368E2F9.
220- C0025B368E2F9
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
User (I0025B368E2F9:(none)): fda_xml
331 pass required for FDA_XML
Password:
230 FDA_XML logged in
ftp> cd /home/DEV/message
250 CWD Command successful
ftp> pwd
257 "/home/DEV/message" is current directory.
ftp> ls -la
200 PORT Command successful
150 ASCII Data Connection
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
226 ASCII Transfer Complete
ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
250 SET_CHARSET Command Successful
ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
200 PORT Command successful
150 ASCII Data Connection
550- Error Response
ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
550 End Error Response
ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
I have tried all suggestion from another thread such as:
alter system set events ='31150 trace name context forever, level 0x4000'
SQL> alter system set shared_servers = 1;
but failed.
is there anyone can help?
Thanks.
Edited by: Cow on Mar 29, 2011 12:58 AMHi experts,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I got error message when store XML documents into XML DB repository, via WebDAV.
I have successfully registered 5 related schemas and generated 1 table.
I have inserted 40 .xml files into this auto generated table.
using these data I created relational view successfully.
but since I couldn't store XML documents into XML DB repository, via WebDAV
when I query using below code:
SELECT rv.res.getClobVal()
FROM resource_view rv
WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
I got nothing.
My ftp code is listed below:
ftp> open localhost 2100
Connected to I0025B368E2F9.
220- C0025B368E2F9
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
User (I0025B368E2F9:(none)): fda_xml
331 pass required for FDA_XML
Password:
230 FDA_XML logged in
ftp> cd /home/DEV/message
250 CWD Command successful
ftp> pwd
257 "/home/DEV/message" is current directory.
ftp> ls -la
200 PORT Command successful
150 ASCII Data Connection
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
226 ASCII Transfer Complete
ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
250 SET_CHARSET Command Successful
ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
200 PORT Command successful
150 ASCII Data Connection
550- Error Response
ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
550 End Error Response
ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
I have tried all suggestion from another thread such as:
alter system set events ='31150 trace name context forever, level 0x4000'
SQL> alter system set shared_servers = 1;
but failed.
is there anyone can help?
Thanks.
Edited by: Cow on Mar 29, 2011 12:58 AM -
Hi All,
Can you please let me know for any sample code in xslt/java mapping for converting XML string into XML. We use SAP Pi 7.0
My XML string starts like this
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MT_ReceiverFileStructure <namespace>"><Output><?xml version="1.0" encoding="ISO-8859-9"?><?xml-stylesheet type="text/xsl" href="<xsl>"?><Tarih_Date Tarih="11.09.2014" Date="09/11/2014>
Thanks,
PavithraThanks Praveen. It worked.
However, the xml i have is an extract from a exchange rate URL and it has the reference to a xsl in it as below
<?xml version="1.0" encoding="ISO-8859-9"?><?xml-stylesheet type="text/xsl" href="<ABC.xsl>"?>.
So there is an error in sxmb_moni. Is it possible to remove this. -
I am not familiar with MAC's. I am trying to insert Turbo Tax CD into my Dad's Mac. But, the CD will not go in/stay in. Need some help with this, anyone have an answer? I would greatly appreciate it! Thanks!
Confused: You say nothing will "catch" in the slot, which I take to mean the optical drive won't accept anything. Just spits it out. Then you say you thought there was an eject button to push, which would imply there's a stuck disc inside.
If it's the latter, try holding down the mouse while booting.
http://support.apple.com/kb/TS2097 -
I am trying to insert a cutaway photo into a movie clip. The cuaway photo appears over the clip and will appear in the clip when you manually moce the curser across it, but will not appear in the clip during playback. What am I missing?
Try using the SHARE menu to share your movie in the sizes you need. It should work on the shared copy.
Another thing to try would be to restart your Mac so you have fresh memory. -
How to read XML data stored in CLOB in Concurrent prog Output
Hi All,
I'm trying to Generate the XML Data as concurrent Program output. I have a PL/SQL package which generated the XML data by using SQL/XML functions. I'm storing the generated XML data in a CLOB variable. But when i try to read the data using fnd_file.put_line(fnd_file.OUTPUT,XML_Data) it doesn't display data more than 32767 bytes.
Please help me out to understand what could be done to read the data in chunks. I have tried many logic's to print chunks of data but the output tags are either chopped off and errors out saying Tag not found.
My logic is as below:
v_handler:= DBMS_XMLGEN.newContext(v_xml_query);
--Sets NULL handling options
DBMS_XMLGen.SetNullHandling(v_handler, dbms_xmlgen.EMPTY_TAG ) ;
--Set special character handling
DBMS_XMLGEN.setConvertSpecialChars(v_handler, TRUE);
-- Specified whether to use an XML attribute to indicate NULLness of particular entity in the XML document
DBMS_XMLGen.useNullAttributeIndicator(v_handler,TRUE);
-- set Checking invalid chars
DBMS_XMLGEN.setCheckInvalidChars(v_handler, TRUE);
-- get the xml data as required
v_xml_data:= DBMS_XMLGEN.getXMLtype(v_handler);
SELECT XMLROOT(v_xml_data.extract('/*'),VERSION '1.0').getClobVal() into v_new_xml_Data from dual;
-- get the length of the xml generated
v_clob_len := dbms_lob.getlength(v_new_xml_Data);
FND_FILE.PUT_LINE(FND_FILE.LOG,'The Clob length is :'|| v_clob_len);
-- logic to process string more than 32767 Processing by each character
v_offset :=1;
while (v_offset <= v_clob_len)
LOOP
v_char := dbms_lob.substr(v_new_xml_Data, 1, v_offset);
IF (v_char = CHR(10))
then
fnd_file.new_line(fnd_file.output, 1);
else
fnd_file.put(fnd_file.output, v_char);
end if;
v_offset := v_offset + 1;
END LOOP;
FND_FILE.PUT_LINE(FND_FILE.LOG,'The offset is :'|| v_offset);
FND_FILE.NEW_LINE(FND_FILE.OUTPUT, 1);
THe above logic is for character by character which is a performance burden? Please let me know if there is any other work around for thisHi,
Thanks for Replying. I have refered http://blog.oraclecontractors.com/?p=69 and then i added that piece of code. Basically, i'm trying to generate a report using XML publisher. To generate the XML data i'm writing a pl/sql package with SQl/XML functions. DBMS_XMLGEN would help me convert the XML Data as is. When the concurrent program runs this XML data will merge with RTF layout and generate required report. I'm able to generate the Report for data less then 32767 bytes. More than the limit i need to pass chunks of XML data to read as output. That's the reason i'm using fnd_file.output. But it reads only 32767 size at a time.
WHen i use the given logic, it works perfectly fine, but it loops for each character, for example if you have 30,000 characters it loops the same, which is peformance burden.
So i tried to write the logic of chunks but still i get the error that XML tag is not found or missing. I'm hoping this is very common issue, but after all my trails, i didn't find the right solution.
the other logic i tried was :
v_new_xml_data varchar2(32767)
v_iterations := CEIL(v_clob_len/v_chunk_length); -- v_chunk_length is 32767 and v_clob_length is length of the XML data stored inthe clob variable
For i in 0..v_iterations
LOOP
FND_FILE.put_line (fnd_file.log,'the loops v_pos :'||i||' and v_clob_length :'||v_clob_len);
v_new_xml_data := DBMS_LOB.SUBSTR ( V_XML_DATA,v_chunk_length,(i*v_chunk_length)+1);
FND_FILE.PUT_LINE (FND_FILE.OUTPUT,v_new_xml_data); -- read the output for every 32767 chunks
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Chunk length is :'||((i*v_chunk_length)+1));
END LOOP;
FND_FILE.put_line (fnd_file.log,'out of loop');
FND_FILE.put_line (fnd_file.log,'length of new xml is '||v_clob_len);
Please, let me know if you need Further clarifications on the same. -
I am unable to add Data element into existing Data Type
Hi Experts,
I am unable to add Data element into existing Data Type, It shows disable mode, suggest me this..
ThanksYep got it...
Edited by: Manoj on Aug 20, 2008 1:09 AM -
Insert XML String into XML file at a certain position
Hello,
I have this xml string:
<jdbc-driver-params>
<url>jdbc:oracle:thin:@localhost:1521:mydb</url>
<driver-name>oracle.jdbc.OracleDriver</driver-name>
<properties>
<property>
<name>user</name>
<value>myuser</value>
</property>
</properties>
<password-encrypted>myuser</password-encrypted>
</jdbc-driver-params>and i need to insert it into an xml file at a certain position (as child for a node)
The xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:sec="http://www.bea.com/ns/weblogic/90/security"
xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/920 http://www.bea.com/ns/weblogic/920.xsd">
<name>myDB</name>
<jdbc-data-source-params>
<global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>
</jdbc-data-source-params>
</jdbc-data-source>And this is how I would like to get it in the end:
<?xml version='1.0' encoding='UTF-8'?>
<jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/90" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xsi:schemaLocation="http://www.bea.com/ns/weblogic/920 http://www.bea.com/ns/weblogic/920.xsd">
<name>mydb</name>
<jdbc-driver-params>
<url>jdbc:oracle:thin:@localhost:1521:myDB</url>
<driver-name>oracle.jdbc.OracleDriver</driver-name>
<properties>
<property>
<name>user</name>
<value>myuser</value>
</property>
</properties>
<password-encrypted>myuser</password-encrypted>
</jdbc-driver-params>
<jdbc-connection-pool-params>
<test-table-name>SQL SELECT 1 FROM DUAL</test-table-name>
</jdbc-connection-pool-params>
<jdbc-data-source-params>
<global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>
</jdbc-data-source-params>
</jdbc-data-source>So, I obtain the node for the given xml string, the jdbc-data-source node from the xml file and i attempt the appendChild. The problem is that nothing really gets inserted into the xml file.
Someone, any idea?
My code:
try
DOMParser parser = new DOMParser();
parser.parse(xmlFileName);
Document doc = parser.getDocument(); // the document we will insert node into
Node root = doc.getElementsByTagName("jdbc-data-source").item(0);
//get XML string node
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder db = factory.newDocumentBuilder();
InputSource inStream = new InputSource();
inStream.setCharacterStream(new StringReader(xmlString));
Document doc4XMLString = db.parse(inStream);
Node rootXMLString = doc4XMLString.getElementsByTagName("jdbc-driver-params").item(0);
root.appendChild(doc.importNode(rootXMLString, true));
return true;
catch (Exception e)
e.printStackTrace();
}Thanks,
johnny
Edited by: smeag0l on Aug 6, 2008 5:08 PM
Edited by: smeag0l on Aug 6, 2008 5:43 PMWell, you helped me again :-) Thank you very much!
Here is how the code should look:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder db4XMLFile = factory.newDocumentBuilder();
Document doc4XMLFile = db4XMLFile.parse(xmlFileName);
Node root4XMLFile = doc4XMLFile.getElementsByTagName(rootNodeName).item(0);
DocumentBuilder db4XMLString = factory.newDocumentBuilder();
InputSource inStream = new InputSource();
inStream.setCharacterStream(new StringReader(xmlString));
Document doc4XMLString = db4XMLString.parse(inStream);
Node root4XMLString = doc4XMLString.getElementsByTagName(xmlStringNodeName).item(0);
root4XMLFile.appendChild(doc4XMLFile.importNode(root4XMLString, true));
File file = new File(xmlFileName);
Result result = new StreamResult(file.toURI().getPath());
Source source = new DOMSource(doc4XMLFile);
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(source, result); -
Read XML file into databased using stored procedure
I need to read an xml file into my database using a stored procedure. I looked at a couple of tutorials, but I am kind of lost and am looking for some guidance. I will eventually need to only pull a handfull of the data in based on the USER ID. Any help will be greatly appreciated. I have been given a schema file and an example file of how the data will me sent to me. The schema file is below:
<h1>Schema File</h1>
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by Turbo XML 2.4.1.100. Conforms to w3c http://www.w3.org/2001/XMLSchema-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="root">
<xsd:complexType />
</xsd:element>
<xsd:element name="Report">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Biller" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Biller">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="BillerName" />
<xsd:element ref="BillerIdNumber" />
<xsd:element ref="PartnerInfo" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="BillerName">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="BillerIdNumber">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="PartnerInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="PartnerName" />
<xsd:element ref="PartnerVenderNumber" />
<xsd:element ref="PartnerStreet01" />
<xsd:element ref="PartnerStreet02" />
<xsd:element ref="PartnerCity" />
<xsd:element ref="PartnerState" />
<xsd:element ref="PartnerZip" />
<xsd:element ref="PartnerCountry" />
<xsd:element ref="PartnerActive" />
<xsd:element ref="PartnerContactName" />
<xsd:element ref="PartnerEmailAddress" />
<xsd:element ref="PartnerContactPhone" />
<xsd:element ref="PartnerFaxNumber" />
<xsd:element ref="PartnerUpdateUser" />
<xsd:element ref="PartnerUpdateDate" />
<xsd:element ref="PartnerDocColor" />
<xsd:element ref="PartnerDocDistribution" />
<xsd:element ref="PartnerDocPrinting" />
<xsd:element ref="PartnerDocTiming" />
<xsd:element ref="Delivery" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PartnerName">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="PartnerVenderNumber">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="PartnerStreet01">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerStreet02">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerCity">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerState">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerZip">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerCountry">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerActive">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerContactName">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerEmailAddress">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerContactPhone">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerFaxNumber">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerUpdateUser">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerUpdateDate">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerDocColor">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerDocDistribution">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerDocPrinting">
<xsd:complexType />
</xsd:element>
<xsd:element name="PartnerDocTiming">
<xsd:complexType />
</xsd:element>
<xsd:element name="Delivery">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="DeliveryType" />
<xsd:element ref="DeliveryContactName" />
<xsd:choice>
<xsd:element ref="ReceivingStreet01" />
<xsd:element ref="ReceivingStreet02" />
<xsd:element ref="ReceivingCity" />
<xsd:element ref="ReceivingState" />
<xsd:element ref="ReceivingZip" />
<xsd:element ref="ReceivingCountry" />
<xsd:element ref="DeliveryEmailAddress" />
<xsd:element ref="DeliveryCompanyId" />
<xsd:element ref="DeliveryUserId" />
<xsd:element ref="DeliveryFormatType" />
<xsd:element ref="SecureType" />
<xsd:element ref="SecureQuestion" />
<xsd:element ref="SecureAnswer" />
<xsd:element ref="DeliveryFaxNumber" />
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryType">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryContactName">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryEmailAddress">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="SecureType">
<xsd:complexType />
</xsd:element>
<xsd:element name="SecureQuestion">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="SecureAnswer">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryFormatType">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryCompanyId">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryUserId">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryFaxNumber">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="ReceivingStreet01">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="ReceivingStreet02">
<xsd:complexType />
</xsd:element>
<xsd:element name="ReceivingCity">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="ReceivingState">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="ReceivingZip">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
<xsd:element name="ReceivingCountry">
<xsd:complexType mixed="true">
<xsd:choice />
</xsd:complexType>
</xsd:element>
</xsd:schema>
<h1>Example File</h1>
<?xml version="1.0" encoding="utf-8"?>
<Report>
<Biller>
<BillerName>DONATO TEST BILLER</BillerName>
<BillerIdNumber>999999999</BillerIdNumber>
<PartnerInfo>
<PartnerName>TEST TRADING PARTNER</PartnerName>
<PartnerVenderNumber>999999999</PartnerVenderNumber>
<PartnerStreet01 />
<PartnerStreet02 />
<PartnerCity />
<PartnerState />
<PartnerZip />
<PartnerCountry />
<PartnerActive />
<PartnerContactName />
<PartnerEmailAddress />
<PartnerContactPhone />
<PartnerFaxNumber />
<PartnerUpdateUser />
<PartnerUpdateDate />
<PartnerDocColor />
<PartnerDocDistribution />
<PartnerDocPrinting />
<PartnerDocTiming />
<Delivery>
<DeliveryType>EMAIL</DeliveryType>
<DeliveryContactName>Kiran</DeliveryContactName>
<DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
</Delivery>
<Delivery>
<DeliveryType>SECURE</DeliveryType>
<DeliveryContactName />
<DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
<SecureType />
<SecureQuestion>Pet Name</SecureQuestion>
<SecureAnswer>040698de9bf14ef87d8cbaf46b8ecddc</SecureAnswer>
<DeliveryFormatType />
</Delivery>
<Delivery>
<DeliveryType>CEO</DeliveryType>
<DeliveryContactName />
<DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
<DeliveryCompanyId>WFADM618</DeliveryCompanyId>
<DeliveryUserId>PAULSEN</DeliveryUserId>
<DeliveryFormatType />
</Delivery>
<Delivery>
<DeliveryType>FAX</DeliveryType>
<DeliveryContactName>Kiran</DeliveryContactName>
<DeliveryFaxNumber>4807244340</DeliveryFaxNumber>
<DeliveryFormatType>PDF</DeliveryFormatType>
</Delivery>
<Delivery>
<DeliveryType>DOC</DeliveryType>
<DeliveryContactName />
<ReceivingStreet01>2600 South Price Road</ReceivingStreet01>
<ReceivingStreet02 />
<ReceivingCity>Chandler</ReceivingCity>
<ReceivingState>AZ</ReceivingState>
<ReceivingZip>85248</ReceivingZip>
<ReceivingCountry>United States</ReceivingCountry>
</Delivery>
<Delivery>
<DeliveryType>DR</DeliveryType>
<DeliveryContactName />
<DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
<DeliveryCompanyId>WFADM618</DeliveryCompanyId>
<DeliveryUserId>PAULSEN</DeliveryUserId>
<DeliveryFormatType />
</Delivery>
</PartnerInfo>
</Biller>
</Report>Try with a XMLTABLE function
For example to Extract BillerName and BillerID
with t as(select xmltype( '<?xml version="1.0" encoding="utf-8"?>
<Report>
<Biller>
<BillerName>DONATO TEST BILLER</BillerName>
<BillerIdNumber>999999999</BillerIdNumber>
<PartnerInfo>
<PartnerName>TEST TRADING PARTNER</PartnerName>
<PartnerVenderNumber>999999999</PartnerVenderNumber>
<PartnerStreet01 />
<PartnerStreet02 />
<PartnerCity />
<PartnerState />
<PartnerZip />
<PartnerCountry />
<PartnerActive />
<PartnerContactName />
<PartnerEmailAddress />
<PartnerContactPhone />
<PartnerFaxNumber />
<PartnerUpdateUser />
<PartnerUpdateDate />
<PartnerDocColor />
<PartnerDocDistribution />
<PartnerDocPrinting />
<PartnerDocTiming />
<Delivery>
<DeliveryType>EMAIL</DeliveryType>
<DeliveryContactName>Kiran</DeliveryContactName>
<DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
</Delivery>
<Delivery>
<DeliveryType>SECURE</DeliveryType>
<DeliveryContactName />
<DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
<SecureType />
<SecureQuestion>Pet Name</SecureQuestion>
<SecureAnswer>040698de9bf14ef87d8cbaf46b8ecddc</SecureAnswer>
<DeliveryFormatType />
</Delivery>
<Delivery>
<DeliveryType>CEO</DeliveryType>
<DeliveryContactName />
<DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
<DeliveryCompanyId>WFADM618</DeliveryCompanyId>
<DeliveryUserId>PAULSEN</DeliveryUserId>
<DeliveryFormatType />
</Delivery>
<Delivery>
<DeliveryType>FAX</DeliveryType>
<DeliveryContactName>Kiran</DeliveryContactName>
<DeliveryFaxNumber>4807244340</DeliveryFaxNumber>
<DeliveryFormatType>PDF</DeliveryFormatType>
</Delivery>
<Delivery>
<DeliveryType>DOC</DeliveryType>
<DeliveryContactName />
<ReceivingStreet01>2600 South Price Road</ReceivingStreet01>
<ReceivingStreet02 />
<ReceivingCity>Chandler</ReceivingCity>
<ReceivingState>AZ</ReceivingState>
<ReceivingZip>85248</ReceivingZip>
<ReceivingCountry>United States</ReceivingCountry>
</Delivery>
<Delivery>
<DeliveryType>DR</DeliveryType>
<DeliveryContactName />
<DeliveryEmailAddress>[email protected]</DeliveryEmailAddress>
<DeliveryCompanyId>WFADM618</DeliveryCompanyId>
<DeliveryUserId>PAULSEN</DeliveryUserId>
<DeliveryFormatType />
</Delivery>
</PartnerInfo>
</Biller>
</Report>')xml from dual)
select q.* from t,xmltable('/Report' passing t.xml columns
BillerName varchar2(20) PATH
'/Report//Biller/BillerName')q
BILLERNAME BILLERID
DONATO TEST BILLER 999999999 -
XML Element of XML Element of XML Element (and so on...)
Here is my XML data (shorted, in a file myFile):
<LiveData>
<Voltage>
<Total>
<VoltageNow>1052</VoltageNow>
</Total>
</Voltage>
<Power>
<Total>
<PowerNow>345</PowerNow>
</Total>
</LiveData>
I would like to get the VoltageNow and PowerNow values, but the following script does not work:
tell application "System Events"
set elem1 to XML element 1 of XML file myFile /*<LiveData>
set power to XML elements of elem1 whose name is "Power"
set total to XML elements of power whose name is "Total"
set powernow to value of XML elements of total whose name is "PowerNow"
end tell
Error: System Events got an error: Can’t make {} into type string.
BTW, I don't want to use XML Element X because the order may change.
What is the correct method to traverse these elements to obtain values?AppleScript can handle the strings, but the System Events XML Suite doesn't work with text strings - it deals with the XML objects, which have name and value properties. The handler can be modified to show the names of an element, but it is just designed to work with the XML Suite.
The contents of an XML file is just text, so you can forgo System Events and just use regular text manipulation statements, or use another tool such as the Satimage XMLLib osax, which is much more robust and does include commands to display the XML object as a string.
By the way, my original handler was designed and tested in Leopard, but I discovered a Snow Leopard bug that alters the way it returns array/list contents. The following script has changes that return the functionality, in addition to a dialog handler that will display lists:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run -- example
set XMLFile to (choose file without invisibles)
show("element value:", (getXMLElement from {XMLFile, "LiveData", "Voltage", "Total", "VoltageNow"}))
end run
to show(label, something)
show an alert for something, formatting lists and records
parameters - label [text]: the alert text
something [mixed]: an item to put in the alert message
returns nothing
if something is not in {null, missing value} then
try -- show the message
if (class of something) is in {list, record} then (something as number) -- force an error
display alert label message (something as text)
on error errorMessage -- lists and records don't format very well, so cheat
set {here, there} to {(offset of "{" in errorMessage), -(offset of "}" in (reverse of text items of errorMessage) as text)}
display alert label message text here thru there of errorMessage
end try
else
display alert label message "*null or missing value*"
end if
end show
to getXMLElement from XMLItems
get the specified element from a simple XML structure by name or index
the number of items is not fixed, but must be at least 2 (the XML file and an XML element)
parameters: XMLItems [list] -
item 1 [text]: the XML file path (Finder or POSIX)
item 2 [mixed]: the XML element name or index (names are case sensitive)
item(s) 3+ [mixed]: sub item(s)
returns [list]: value of the element
try
if (count XMLItems) is less than 2 then error "getXMLElement handler: item list contains too few items"
tell application "System Events"
set theXMLData to contents of XML file ((the first item of XMLItems) as text)
-- get text of theXMLData
set theXMLElement to XML element 1 of theXMLData -- start at the root element
repeat with anItem in rest of XMLItems -- add on the sub items
set anItem to contents of anItem
try
set anItem to anItem as integer -- index number?
end try
set theXMLElement to (get XML element anItem of theXMLElement)
end repeat
try -- return the element(s)
-- return name of XML elements of theXMLElement
set theResult to value of theXMLElement -- SL built-in result variable does not get set
if theResult is missing value then error -- SL does not error on empty or missing value
return theResult
on error errorMessage number errorNumber -- the element is empty, or a list of items
log errorMessage
return value of XML elements of theXMLElement
end try
end tell
on error errorMessage number errorNumber
log errorMessage
-- return null
error "getXMLElement handler: element not found (" & errorNumber & ")"
end try
end getXMLElement</pre>
Maybe you are looking for
-
Can't open downloads to desktop (Error code - 10660)
Hi Everyone, I'm having a problem opening documents that are downloaded to my desktop. I recieve the following error, "The operation could not be completed. An unexpected error occurred (Error code - 10660)." I can go into the required program (i.e.
-
Pdf file won't be read out in Adobe Reader
Having tried unsuccessfully to get Reader Version 9 (with Read It Aloud plugin present and correct) to read a particular PDF file, I'm thinking that perhaps the problem is with the document properties...but in File>Document properties there is nothin
-
Hi guys, I have a sony dcr-trv14e I am trying to connect to my iMac and iMovies '11... It isn't on the compatibility list (which is annoying) and I have tried to connect it via usb and via firewire but I can't get it to connect in any way at all. I c
-
Read following fields from BSIK and use as input fields for table BSEG Company code BSIK-BUKRS Document # BSIK-BELNR Fiscal year BSIK-GJAHR When BSEG-LIFNR ≠ BSIK-LIFNR; Group details by Document number (BSEG-BELNR), Company code (BSEG-BUKRS), Busi
-
Required Field Seperator in Strict2XML plain bean
Hi Experts, In Strict2XML plain bean, in the parameters we are using fixed length, there is no field seperator, in my module i required that field seperator. So wat to do??? So please any one can help me regarding this urgently Thanks ANIL Edited by