Home » Developer & Programmer » JDeveloper, Java & XML » problem with xmldom package (Oracle - 10.2.0.1.0)
problem with xmldom package [message #480598] |
Tue, 26 October 2010 00:35 |
czinsou
Messages: 23 Registered: August 2009
|
Junior Member |
|
|
Hi,
I am using the dbms_xmldom package to generate xml files (specific structure).
Below is the code but It produces nothing (dbms_output does not return) :
DECLARE
doc xmldom.DOMDocument;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
root_elmt xmldom.DOMElement;
transmissionHeaderNode xmldom.DOMNode;
transmissionHeaderElement xmldom.DOMElement;
item_node xmldom.DOMNode;
item_elmt xmldom.DOMElement;
item_text xmldom.DOMText;
buffer_problem CLOB;
BEGIN
doc := xmldom.newDOMDocument;
main_node := xmldom.makeNode(doc);
xmldom.setversion(doc,'1.0');
root_elmt := xmldom.createElement(doc, 'InvoiceTransmission');
root_node := xmldom.appendChild( main_node, xmldom.makeNode(root_elmt));
transmissionHeaderElement := xmldom.createElement(doc, 'TransmissionHeader');
transmissionHeaderNode := xmldom.appendChild(root_node, xmldom.makeNode(transmissionHeaderElement));
item_elmt := xmldom.createElement(doc, 'TransmissionDateTime');
item_node := xmldom.appendChild(transmissionHeaderNode, xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc, TO_CHAR(SYSDATE,'DD-MM-YYYY'));
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
item_elmt := xmldom.createElement(doc, 'IssuingOrganiszationID');
item_node := xmldom.appendChild(transmissionHeaderNode, xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc,'0258');
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
item_elmt := xmldom.createElement(doc, 'Version');
item_node := xmldom.appendChild(transmissionHeaderNode, xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc, 'IATA:ISXMLInvoiceV3.0');
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
xmldom.writetobuffer(doc, buffer_problem);
dbms_output.put_line(buffer_problem);
xmldom.freeDocument(doc);
END;
That's strange because when I remove a code part like :
item_elmt := xmldom.createElement(doc, 'Version');
item_node := xmldom.appendChild(transmissionHeaderNode, xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc, 'IATA:ISXMLInvoiceV3.0');
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
I can get the ouput xml :
<?xml version="1.0"?>
<InvoiceTransmission>
<TransmissionHeader>
<TransmissionDateTime>26-10-2010</TransmissionDateTime>
<IssuingOrganiszationID>0258</IssuingOrganiszationID>
</TransmissionHeader>
</InvoiceTransmission>
I don't know if it's a problem with xmldom or with dbms_output package...
Please someone can help me ?
|
|
|
Re: problem with xmldom package [message #480602 is a reply to message #480598] |
Tue, 26 October 2010 01:02 |
|
Michel Cadot
Messages: 68731 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
It works for me:
SQL> DECLARE
2 doc xmldom.DOMDocument;
3 main_node xmldom.DOMNode;
4 root_node xmldom.DOMNode;
5 root_elmt xmldom.DOMElement;
6
7 transmissionHeaderNode xmldom.DOMNode;
8 transmissionHeaderElement xmldom.DOMElement;
9 item_node xmldom.DOMNode;
10 item_elmt xmldom.DOMElement;
11 item_text xmldom.DOMText;
12
13 buffer_problem CLOB;
14
15 BEGIN
16
17 doc := xmldom.newDOMDocument;
18 main_node := xmldom.makeNode(doc);
19 xmldom.setversion(doc,'1.0');
20 root_elmt := xmldom.createElement(doc, 'InvoiceTransmission');
21 root_node := xmldom.appendChild( main_node, xmldom.makeNode(root_elmt));
22
23 transmissionHeaderElement := xmldom.createElement(doc, 'TransmissionHeader');
24 transmissionHeaderNode := xmldom.appendChild(root_node, xmldom.makeNode(transmissionHeaderElement));
25
26 item_elmt := xmldom.createElement(doc, 'TransmissionDateTime');
27 item_node := xmldom.appendChild(transmissionHeaderNode, xmldom.makeNode(item_elmt));
28 item_text := xmldom.createTextNode(doc, TO_CHAR(SYSDATE,'DD-MM-YYYY'));
29 item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
30
31 item_elmt := xmldom.createElement(doc, 'IssuingOrganiszationID');
32 item_node := xmldom.appendChild(transmissionHeaderNode, xmldom.makeNode(item_elmt));
33 item_text := xmldom.createTextNode(doc,'0258');
34 item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
35
36 item_elmt := xmldom.createElement(doc, 'Version');
37 item_node := xmldom.appendChild(transmissionHeaderNode, xmldom.makeNode(item_elmt));
38 item_text := xmldom.createTextNode(doc, 'IATA:ISXMLInvoiceV3.0');
39 item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
40
41 xmldom.writetobuffer(doc, buffer_problem);
42 dbms_output.put_line(buffer_problem);
43 xmldom.freeDocument(doc);
44
45 END;
46
47 /
<?xml version="1.0"?>
<InvoiceTransmission>
<TransmissionHeader>
<TransmissionDateTime>26-10-2010</TransmissionDat
eTime>
<IssuingOrganiszationID>0258</IssuingOrganiszationID>
<Version>IATA:ISXMLInvoiceV3.0</Version>
</Transm
issionHeader>
</InvoiceTransmission>
PL/SQL procedure successfully completed.
I think it is a SQL*Plus setting issue.
execute the following and retry:
set long 10000
Please when something "does not work", copy and paste your session as we did in all your questions.
Regards
Michel
[Updated on: Tue, 26 October 2010 01:03] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Jan 26 01:15:37 CST 2025
|