XMLDOM.appendChild performance

Hi All,
I have a large xml (52,000 messages under the root element). There's about 5 elements under each Message element. Parsing each element takes about 2 minutes which is great. However, when I try to add two more elements under the message element using XMLDOM.appendChild , the execution time goes up to 11 minutes.
DB Version: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit
Any ideas on how to make it run faster?
Is there an issue with XMLDOM.appendChild

Hi,
Any ideas on how to make it run faster?
Is there an issue with XMLDOM.appendChildActually, there's an issue with the whole approach.
Given your db version, you should stop using DOM and start using binary XMLType and related functionalities.
Could you describe a little bit more what you want to do? A sample data with expected output would help.
- What does "parsing" mean to you? Extracting XML data into variables or columns?
- Do you want to add two more elements under each of the 52000 Messages?
Here's a glimpse of what you can do :
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table tmp_xml of xmltype;
Table created.Creating a sample document with 10000 messages...
SQL> set timing on
SQL> insert into tmp_xml
  2  select xmlelement("root",
  3           xmlagg(
  4             xmlelement("message",
  5               xmlforest(
  6                 'A'||to_char(level, 'fm09999') as "item1"
  7               , 'B'||to_char(level, 'fm09999') as "item2"
  8               , 'C'||to_char(level, 'fm09999') as "item3"
  9               , 'D'||to_char(level, 'fm09999') as "item4"
10               , 'E'||to_char(level, 'fm09999') as "item5"
11               )
12             )
13           )
14         )
15  from dual
16  connect by level <= 10000 ;
1 row created.
Elapsed: 00:00:00.56
SQL>Parsing into a relational structure...
SQL> select x.*
  2  from tmp_xml t
  3     , xmltable(
  4         '/root/message'
  5         passing t.object_value
  6         columns item1 varchar2(6) path 'item1'
  7               , item2 varchar2(6) path 'item2'
  8               , item3 varchar2(6) path 'item3'
  9               , item4 varchar2(6) path 'item4'
10               , item5 varchar2(6) path 'item5'
11       ) x
12  where rownum <= 10 ;
ITEM1  ITEM2  ITEM3  ITEM4  ITEM5
A00001 B00001 C00001 D00001 E00001
A00002 B00002 C00002 D00002 E00002
A00003 B00003 C00003 D00003 E00003
A00004 B00004 C00004 D00004 E00004
A00005 B00005 C00005 D00005 E00005
A00006 B00006 C00006 D00006 E00006
A00007 B00007 C00007 D00007 E00007
A00008 B00008 C00008 D00008 E00008
A00009 B00009 C00009 D00009 E00009
A00010 B00010 C00010 D00010 E00010
10 rows selected.
Elapsed: 00:00:00.37
SQL>Appending two more children to each message using XQuery Update (11.2.0.3 only) :
SQL> update tmp_xml t
  2  set t.object_value =
  3         xmlquery(
  4           'copy $d := .
  5            modify (
  6              for $i in $d/root/message
  7              return insert node $e into $i
  8            )
  9            return $d'
10          passing t.object_value
11               ,  xmlconcat(
12                    xmlelement("item6")
13                  , xmlelement("item7")
14                  ) as "e"
15          returning content
16         )
17  ;
1 row updated.
Elapsed: 00:00:04.25
SQL>
SQL> set long 500
SQL> set pages 100
SQL> select object_value from tmp_xml ;
OBJECT_VALUE
<root>
  <message>
    <item1>A00001</item1>
    <item2>B00001</item2>
    <item3>C00001</item3>
    <item4>D00001</item4>
    <item5>E00001</item5>
    <item6/>
    <item7/>
  </message>
  <message>
    <item1>A00002</item1>
    <item2>B00002</item2>
    <item3>C00002</item3>
    <item4>D00002</item4>
    <item5>E00002</item5>
    <item6/>
    <item7/>
  </message>
  <message>
    <item1>A00003</item1>
    <item2>B00003</item2>
    <item3>C00003</item3>
    <item4>D00003</item4>
    <item5>E000
Elapsed: 00:00:00.14Edited by: odie_63 on 7 janv. 2013 00:12

Similar Messages

  • Using xmldom.appendChild function

    Hi , I'm trying to parse 2 xml strings.
    I have successfully generated the 2 strings names xmlString1 & xmlString2.
    Next I do parsing. This is some part of the code --
    p := xmlparser.newParser;
    xmlparser.parseClob(p, xmlString1);
    xmldoc1 := xmlparser.getDocument(p);
    xmlparser.parseClob(p, xmlString2);
    xmldoc2 := xmlparser.getDocument(p);
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc,'1.0');
    -- create a root element for the new document
    rootElement := xmldom.createElement(xmldoc , 'ORDER');
    root1Element := xmldom.getDocumentElement(xmldoc1);
    root2Element := xmldom.getDocumentElement(xmldoc2);
    domNode1 := xmldom.makeNode(rootElement);
    domNode2 := xmldom.makeNode(root1Element);
    domNode3 := xmldom.makeNode(root2Element);
    dbms_output.put_line('hi1');
    xmldocnode := xmldom.appendChild(domNode1,domNode2);
    dbms_output.put_line('hi2');
    While executing I get the 'hi1' but not 'hi2'.
    It gives PL/SQL procedure successfully completed. But does nothing from the appendChild function call.
    xmldocnode,domNode1,domNode2 have been declared xmldom.DOMNode type.
    Thanks
    null

    Hi , I'm trying to parse 2 xml strings.
    I have successfully generated the 2 strings names xmlString1 & xmlString2.
    Next I do parsing. This is some part of the code --
    p := xmlparser.newParser;
    xmlparser.parseClob(p, xmlString1);
    xmldoc1 := xmlparser.getDocument(p);
    xmlparser.parseClob(p, xmlString2);
    xmldoc2 := xmlparser.getDocument(p);
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc,'1.0');
    -- create a root element for the new document
    rootElement := xmldom.createElement(xmldoc , 'ORDER');
    root1Element := xmldom.getDocumentElement(xmldoc1);
    root2Element := xmldom.getDocumentElement(xmldoc2);
    domNode1 := xmldom.makeNode(rootElement);
    domNode2 := xmldom.makeNode(root1Element);
    domNode3 := xmldom.makeNode(root2Element);
    dbms_output.put_line('hi1');
    xmldocnode := xmldom.appendChild(domNode1,domNode2);
    dbms_output.put_line('hi2');
    While executing I get the 'hi1' but not 'hi2'.
    It gives PL/SQL procedure successfully completed. But does nothing from the appendChild function call.
    xmldocnode,domNode1,domNode2 have been declared xmldom.DOMNode type.
    Thanks
    null

  • Creating XML File Using xmldom Package

    How can I create an XML file from scratch using the PL/SQL xmldom package?
    I want to create an XML file using the xmldom package instead of building the individual tags as strings of VARCHAR2 character data. There is quite a bit of documentation regarding manipulating input XML files using DOM -- but not for creating XML files from scratch given known "tagnames" (<lastName>) and retrieved database "values" ("Smith").
    <person>
    <lastName>Smith</lastName>
    </person>
    Is there any documentation that you can recommend?
    Thank you.

    Here is an example.
    The create_file procedure creates the file.
    The other procedures are generic procs that can be used with any XML.
    PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
    pi_root_tag IN VARCHAR2,
                                            po_root_element OUT xmldom.domelement,
                                            po_root_node OUT xmldom.domnode,
                                            pi_doctype_url IN VARCHAR2) IS
    xmldoc xmldom.DOMDocument;
    root xmldom.domnode;
    root_node xmldom.domnode;
    root_element xmldom.domelement;
    record_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
    -- Create the root --
    root := xmldom.makeNode(xmldoc);
    -- Create the root element in the file --
    create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
    po_xmldoc := xmldoc;
    po_root_node := root_node;
    po_root_element := root_element;
    END create_file_with_root;
    PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
    pi_element_name IN VARCHAR2,
                                            pi_parent_node IN xmldom.domnode,
                                            po_new_element OUT xmldom.domelement,
                                            po_new_node OUT xmldom.domnode) IS
    element xmldom.domelement;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    element := xmldom.createElement(pi_xmldoc, pi_element_name);
    child_node := xmldom.makeNode(element);
    -- Append the new node to the parent --
    newelenode := xmldom.appendchild(pi_parent_node, child_node);
    po_new_node := child_node;
    po_new_element := element;
    END create_element_and_append;
    FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
    pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
    parent_node xmldom.domnode;                                   
    child_node xmldom.domnode;
    child_element xmldom.domelement;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
    parent_node := child_node;
    -- Create a text node --
    textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
    child_node := xmldom.makeNode(textele);
    -- Link the text node to the new node --
    compnode := xmldom.appendChild(parent_node, child_node);
    RETURN newelenode;
    END create_text_element;
    PROCEDURE create_file IS
    xmldoc xmldom.DOMDocument;
    root_node xmldom.domnode;
    xml_doctype xmldom.DOMDocumentType;
    root_element xmldom.domelement;
    record_element xmldom.domelement;
    record_node xmldom.domnode;
    parent_node xmldom.domnode;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
    xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
    parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
    parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
    -- write the newly created dom document into the buffer assuming it is less than 32K
    xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
    EXCEPTION
    WHEN xmldom.INDEX_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
    WHEN xmldom.DOMSTRING_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'String Size error');
    WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
    WHEN xmldom.WRONG_DOCUMENT_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
    WHEN xmldom.INVALID_CHARACTER_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
    WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
    WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
    WHEN xmldom.NOT_FOUND_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not found error');
    WHEN xmldom.NOT_SUPPORTED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
    WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
    WHEN OTHERS THEN
    dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
    END create_file;

  • Update passed in XML doc with pl/sql xmldom

    Hi,
    I have an xml document that is passed in through a stored procedure as CLOB. I'm trying to use the XMLParser and XMLDOM to add an additional node
    The XML looks something like the following
    <rowset>
    <row>
    <firstname>john</firstname>
    </row>
    <row>
    <firstname>jane</firstname>
    </row>
    </rowset>
    I need to loop through each of <mynames> nodes and then add another node <lastame> so it looks like the following
    <rowset>
    <row>
    <firstname>john</firstname>
    <lastame>smith</lastame>
    </row>
    <row>
    <firstname>jane</firstname>
    <lastame>smith</lastame>
    </row>
    </rowset>
    I have the following code
    parseClob XMLPARSER.Parser;
    newNames XMLDOM.DOMDocument;
    tempNode XMLDOM.DOMNode;
    mye xmldom.domelement;
         item_text xmldom.DOMText;
    numofrows number;
         nodeList xmldom.DOMNodeList;
         newnode xmldom.domnode;
    parseClob := xmlparser.newParser;
    XMLPARSER.parseClob(parseClob,names);
    newNames := XMLPARSER.getDocument(parseClob);
    XMLPARSER.freeParser(parseClob);
    nodeList := xslprocessor.selectNodes(xmldom.makeNode(newNames), '//rowset/row');
    numOfRows := xmldom.getlength(nodeList)-1;
    for i in 0..numOfRows LOOP
    newnode := xmldom.item(nodeList, i);
              --create the new node
    mye := xmldom.createElement(newName, 'lastname');
    --add it to the new node   
    tempNode := xmldom.appendChild(newnode, xmldom.makeNode(mye));
    --update the text in the lastname   
    item_text := xmldom.createTextNode(newNames, 'smith');
    tempNode := xmldom.appendChild(tempNode, xmldom.makeNode(item_text));
    end loop;
    what happens is that when i write out the newnode xml out to a buffer i see the <lastname> tag
    but when i write out the newNames xml out to a buffer after the loop is finished the <lastname> tag is
    missing. like it didn't update the newNames xml
    I've seen lots of example on how to create an XML document with the DOM from scratch but nothing about updating
    an passed in xml document. any help would be appreciated

    Updatexml is reference in Oracle 9i, I'm sorry i should have mentioned that I am using oracle 8i. Is there something you can use in oracle 8i?

  • Problem due to xmldom.DOMDocument

    Hi,
    I have written a function where i have used xmldom in the matter as listed below :
    doc xmldom.DOMDocument;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    user_node xmldom.DOMNode;
    item_node xmldom.DOMNode;
    root_elmt xmldom.DOMElement;
    item_elmt xmldom.DOMElement;
    item_text xmldom.DOMText;
    abc clob;
    doc := xmldom.newDOMDocument;
    main_node := xmldom.makeNode(doc);
    root_elmt := xmldom.createElement(
    doc,
    'Menubar'
    root_node := xmldom.appendChild(
    main_node,
    xmldom.makeNode(root_elmt)
    like wise i am writing into Doc but i have to return evry root or node written using doc to calling environment so i need to read this doc and convert it xmltype so i as to read it but there is complilation error at the point
    abc :=doc
    and the error is PLS-00382: expression is of wrong type
    any suggestion how can i overcome it i can paste the whole code if needed.
    Regards
    Vikas Kumar

    Hello
    The error is coming as you are trying to put DOM Document in either clob or xmltype which are not of the same datatype as xmldom. In the post you have abc of clob type where as in the code you mailed it is xmltype.
    In first scenario i.e. if abc is clob you may have to write something similar to
    xmldom.writetoclob(doc,abc);
    In second Scenario i.e. if abc is xmltype
    DBMS_LOB.CreateTemporary(v_xml_clob, TRUE);
    xmldom.writetoclob(doc,v_xml_clob);
    abc := new xmltype(v_xml_clob);

  • DOMException after XMLNode.appendChild() with xdk 9.2.0.5.0

    Hi,
    the XMLNode.appendChild(XMLNode)- method returns a DOMException (Message: Node doesn't belong to the current document. Code: 4) while using the Oracle XDK Java 9.2.0.5.0 Production. Tested on Oracle8 and 9i.
    Changing to the older Version Oracle XML Parser 2.0.2.9.0 Production everything works fine!
    Code:
    import oracle.xml.parser.v2.XMLNode;
    XMLNode subRoot = (XMLNode)((XMLNode)(subDoc.getDocumentElement())).cloneNode(true);
    XMLNode targetNode = (XMLNode)doc.selectSingleNode(data.nodePath);
    targetNode.appendChild(subRoot); => EXCEPTION
    (Oracle JDeveloper9i Vers.9.0.3.1035)
    Any suggestions?
    Thanks,
    Stefan

    Found solution in Oracle Metalink (DOC 228834.1):
    Use functions to detach the node from its owner document before using xmldom.appendChild:
    xmldom.importNode - to make a copy of the node
    xmldom.adoptNode - to move the node
    See API for more details!

  • Problem with XMLDOM package (Oracle 10.2.0.1.0)

    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 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 if it's a problem with xmldom or with dbms_output package...
    Please someone can help me ?

    Works fine for me
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    SQL> set serveroutput on;
    SQL>
    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     --buffer_problem := 'a';  -- added to initialize clob
    42     xmldom.writetobuffer(doc, buffer_problem);  -- change to writetoclob
    43     dbms_output.put_line(buffer_problem);
    44     xmldom.freeDocument(doc);
    45 
    46  END;
    47  /
    <?xml version="1.0"?>
    <InvoiceTransmission>
      <TransmissionHeader>
        <TransmissionDateTime>26-10-2010</TransmissionDateTime>
        <IssuingOrganiszationID>0258</IssuingOrganiszationID>
        <Version>IATA:ISXMLInvoiceV3.0</Version>
      </TransmissionHeader>
    </InvoiceTransmission>Suggestions:
    - Use dbms_xmldom instead of just xmldom. Oracle changed the name in the 9i days and xmldom is a synonym to dbms_xmldom.
    - Use .writeToClob intead of .writeToBuffer
    - I would suggest trying to upgrade to .4 as you pick up a lot of improvements and bug fixes. Whether what you are encountering is a bug I cannot say but would seem so.
    - See the FAQ under your sign-in name to learn how to use the tag to format the code like I did above.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • XMLdom - saves only in UTF-8 :-(

    Here is a sample, wich generates XML:
    declare
    p xmlparser.parser;
    doc xmldom.DOMDocument;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    root_elmt xmldom.DOMElement;
    item_node xmldom.DOMNode;
    item_elmt xmldom.DOMElement;
    item_text xmldom.DOMText;
    begin
    p := xmlparser.newparser;
    doc := xmldom.newDOMDocument;
    main_node := xmldom.makeNode(doc);
    root_elmt := xmldom.createElement(doc, 'DOCUMENT');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    item_text := xmldom.createTextNode(doc, 'РУССКИЙ ТЕКСТ (CYRILLIC)');
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_text));
    xmldom.setcharset(doc, 'Windows-1251');
    xmldom.setVersion(doc, '1.0');
    xmldom.writeToFile(doc , '/u/doc4.xml');
    xmldom.freeDocument(doc);
    end;
    Results:
    <?xml version = '1.0'?><DOCUMENT>╨б╨г╨а</DOCUMENT>
    Without a suggestion to use given charset. For some reason the package saves always in UTF-8...
    How force the package to generate XML in given charset? It's desirable to show encoding directly in <?xml encoding="..."?>

    Hi Vlad!
    I have the same problem, but I know that parsing a non UTF8 XML works fine.
    So here is a workaround.
    This works on Oracle8i Enterprise Edition Release 8.1.6.3.0
    with XDK_PLSQL_9_2_0_5_0
    Regards,
    Peter
    p := xmlparser.newparser;
    --doc := xmldom.newDOMDocument;
    xmlparser.parsebuffer(p,'<?xml version="1.0" encoding="Windows-1251"?><DOCUMENT/>');
    doc := xmlparser.getdocument(p);
    --xmldom.setcharset(doc, 'Windows-1251');
    --xmldom.setVersion(doc, '1.0');
    main_node := xmldom.makeNode(doc);
    --root_elmt := xmldom.createElement(doc, 'proba');
    --root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    root_node := xmldom.makenode(xmldom.getdocumentelement(doc));
    item_text := xmldom.createTextNode(doc, 'YOUR TEXT HERE');
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_text));
    xmldom.writeToFile(doc , '/u/doc4.xml');
    xmldom.freeDocument(doc);
    end;
    -----------------------------------------------------

  • Specify encoding in PL/SQL XMLDOM

    Hi,
    I am Using Oracle 8.1.7 and trying to construct XML using xmldom object in a PL/SQL block. The XMl is generated fine but the header is
    <?xml version = '1.0' encoding = 'ASCII'?>
    Can anyone tell me how to change 'ASCII' to 'utf-8'. Is there any methods available for specifying encoding type??
    1. xmldom.setcharset() does not have any impact on the output
    2. xmldom.writeToFile(doc,'/tmp/op.xml','UTF-8'); removes the entire header.
    Code:
    DECLARE
    doc xmldom.DOMDocument;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    root_elmt xmldom.DOMElement;
    BEGIN
    doc := xmldom.newDOMDocument;
    main_node := xmldom.makeNode(doc);
    root_elmt := xmldom.createElement(doc, 'EMP');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    xmldom.setCharset(doc,'UTF-8');
    xmldom.writeToFile(doc,'/tmp/op.xml');
    xmldom.freeDocument(doc);
    END;
    Output:
    <?xml version = '1.0' encoding = 'ASCII'?>
    <EMP/>
    Any help/suggestions would be highly appreciated.
    Thanks and Regards,
    Prakash

    hi,
    Here in this code instead of xmldom.setCharset(doc,'UTF-8') use xmldom.setversion(doc,'1.0') which actually sets the character set as 'UTF-8'.Try this it might work.
    DECLARE
    doc xmldom.DOMDocument;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    root_elmt xmldom.DOMElement;
    BEGIN
    doc := xmldom.newDOMDocument;
    main_node := xmldom.makeNode(doc);
    root_elmt := xmldom.createElement(doc, 'EMP');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    xmldom.setversion(doc,'1.0');
    xmldom.writeToFile(doc,'/tmp/op.xml');
    xmldom.freeDocument(doc);
    END;

  • XMLDOM and CDATA

    Guru's,
    I have a requirement using PL/SQL whereby I need to store more that 32K bytes of HTML in an XML Element. Since the content is HTML, it seems to me that I have to use the CDATA method of XMLDOM
    (for example item_node := xmldom.appendChild(item_node, xmldom.makeNode(xmldom.createCDATASection(doc, p_bodycopy)));)
    My issue is that the createCDATASection can only handle a VARCHAR2, and I require it to handle (at most) 64K of information.
    I can use the AppendData procedure w/ Character data, but that creates decode,translation and transformation issues.
    Is there any light at the end of this tunnel? or should I punt.
    The following works very well for everything <= 32K
    item_elmt := xmldom.createElement(doc, 'BodyCopy');
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(xmldom.createCDATASection(doc, p_bodycopy)));
    I am looking for a solution for content >32K
    Any insight is much appreciated.
    -Scot

    Hi Scot. Unfortunately most of the xml packages and functions are brain dead when it comes to handling large data. Most are implicitly tied to varchar limits and lob limitations in PL/SQL.
    To get a CDATA element exactly as you describe, I think you need to resort to building it up from 1st principles using lob methods.
    e.g.
    declare
    v_lob clob;
    v_lob_temp clob;
    begin
    v_lob := '<FamilyHistory><![CDATA[';
    select x.bigdata into v_lob_temp from x1 x where x.item='mysample';
    DBMS_LOB.APPEND(v_lob, v_lob_temp );
    DBMS_LOB.APPEND(v_lob, ']]></FamilyHistory>');
    insert into x2 values('mysample',v_lob);
    end;
    There is an approach using xmltype views based on object types, but these will implicitly xml encode your clob rather than quote it as CDATA (and I don't know a way to prevent this).
    e.g.
    CREATE TABLE x1 (item varchar(25) primary key, bigdata clob);
    -- (insert a very large record)
    CREATE OR REPLACE TYPE x1_t AS OBJECT
    (Holder varchar(25),BookData CLOB);
    CREATE OR REPLACE VIEW vx1 OF XMLTYPE
    WITH OBJECT ID (ExtractValue(sys_nc_rowinfo$, '/ROW/HOLDER')) AS
    SELECT sys_XMLGen(x1_t(x.item, x.bigdata)) from x1 x;
    Here's a sample entry:
    SELECT
         extractvalue(x.SYS_NC_ROWINFO$,'/ROW/HOLDER') as holder
         ,'xml_length: ' || dbms_lob.getlength(x.SYS_NC_ROWINFO$.getclobval()) as xml_length
    FROM vx1 x;
    HOLDER XML_LENGTH
    mysample xml_length: 324198
    Note sql*plus has a problem querying this:
    SQL> select * from vx1;
    ERROR:
    OCI-31167: XML nodes over 64K in size cannot be inserted
    Unless we just go for the clob. In this example the "BOOKDATA" is pure unencoded XML in table X1, but automatically encoded in the xmltype view vx1:
    SQL> set long 200
    SQL> select (SYS_NC_ROWINFO$).GETCLOBVAL() from vx1;
    (SYS_NC_ROWINFO$).GETCLOBVAL()
    &lt;?xml version=&quot;1.0&quot;?&gt;
    &lt;ROW&gt;
    &lt;HOLDER&gt;mysample&lt;/HOLDER&gt;
    &lt;BOOKDATA&gt;&amp;lt;books&amp;gt;
    &amp;lt;book id=&amp;quot;1&amp;quot;&amp;gt;
    &amp;lt;title&amp;gt;the book 1 title&amp;lt;/title&amp;gt;
    &amp;lt;/book&amp;gt;
    &amp;lt;book id=&amp;quot;2&amp;qu

  • Is it possible to add variable defined as xmltype to an xmldom node?

    Hi,
    I'm trying to produce a complex XML document that doesn't lend itself well to using SQL XML functions (xmlagg, xmlelement, etc.) because various disparate data needs to be pulled together via seperate queries and then stuck into the final document in the correct spots.
    So I've resorted to using the convoluted pl/sql xmldom functions. What I'm wondering though is if it is possible to take data in an xmltype variable and somehow append it as a node within my xml document? Something as in the following pseudo code:
    begin
    doc := xmldom.newDOMDocument;
    main_node := xmldom.makeNode (doc);
    select xmlelement("Address",...) -- more xmlelements containing related address info (street, city, etc.)
    into l_address
    from ...;
    new_node := xmldom.appendChild (main_node, xmldom.makeNode (l_address));
    end;
    If possible, this would save me a tremendous amount of time from having to code every element and attributes via the xmldom functions.
    Thanks,
    Alan

    I've done the same scenario you are describing, shove XML defined in an XMLType into a DOMDocument. I munged the code to hide system specific references so the code works, just not as pasted here. The document is being built in o_response_doc and goes after the node previously built in l_rsp_msg_nd. The input is l_xmltype. May be a better way but I never found one and came up with this based on the Oracle documentation and trial and error.
        -- Convert the XMLType to a DOMDocument so we can extract the needed node
        --  and insert it into the response DOMDocument
        l_temp_domdoc := dbms_xmldom.newdomdocument(l_xmltype);
        l_inq_nodelist := dbms_xmldom.getelementsbytagname(l_temp_domdoc,
                                                           'DesiredXMLTypeNodeName');
        l_inq_nl_len := xmldom.getlength(l_inq_nodelist);
        IF l_inq_nl_len > 0 THEN
           -- Take the node above and adopt it into the response document
           l_temp2_nd := dbms_xmldom.importNode(o_response_doc,
                                                dbms_xmldom.item(l_inq_nodelist, 0),
                                                TRUE);
           -- Remove the a: namespace that was autoadded.  (this was defined in the l_xmltype XML)
           dbms_xmldom.removeattribute(dbms_xmldom.makeelement(l_temp2_nd),
                                       <ns_pfx>,
                                       <ns_uri>);
           -- Put the node in the correct position in the response document                                          
           l_temp2_nd := xdb.dbms_xmldom.appendChild(l_rsp_msg_nd, l_temp2_nd);
        END IF;
        dbms_xmldom.freeDocument(l_temp_domdoc);

  • Xmldom.writeToClob error. [URGENT]

    Any idea why I get the following error when I call:
    xmldom.writeToClob(root, xml_out);
    ORA-20000: An internal error has occurred: CLOB to write to can not be null ORA-06512: at "XML.XMLDOM", line 37 ORA-06512: at "XML.XMLDOM", line 358 ORA-06512: at line 131
    'xml_out' is initialised with null, but 'root' have some nodes and elements, but no text nodes. I do not get this error if I use
    xmldom.writeToBuffer(root, v_xml);
    Thanks
    null

    Thx for your response
    the program looks like this:
    I executed it from a Form;
    PROCEDURE PRUEBA IS
    xml clob;
    vxml varchar2(100);
    len integer := 1;
    pos integer := 1;
    f utl_file.file_type;
    doc xmldom.DOMDocument;
    ppal_node xmldom.DOMNode;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    user_node xmldom.DOMNode;
    tercer_node xmldom.DOMNode;
    item_node xmldom.DOMNode;
    ppal_elmt xmldom.DOMElement;
    root_elmt xmldom.DOMElement;
    item_elmt xmldom.DOMElement;
    item_text xmldom.DOMText;
    --Elementos de la cabecera
    header_pi xmldom.DOMProcessingInstruction;
    header_node xmldom.DOMNode;
    CURSOR MODULOS IS
    SELECT T_COAPI AS COAPI,
    T_DNAPI AS DNAPI     
    FROM     T
    WHERE     T_COAPI = 'PES';
    BEGIN
    --Creamos un nuevo DOM document
    doc := xmldom.newDOMDocument();
    ppal_node := xmldom.makeNode(doc);
    FOR Modulo IN Modulos LOOP
    -- El nodo es cada modulo
    root_elmt := xmldom.createElement(doc, 'Modulo');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    --COAPI
    item_elmt := xmldom.createElement(doc, lit_COAPI);
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_text := xmldom.createTextNode(doc, Modulo.COAPI);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    --DNAPI
    item_elmt := xmldom.createElement(doc, lit_DNAPI);
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_text := xmldom.createTextNode(doc, Modulo.DNAPI);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    END LOOP
    f := utl_file.fopen('TEMP_DIR','PRUEBA.xml','w');
    --Obtenemos la longitud del xml lob
    len := dbms_lob.getlength(xml);
    DBMS_LOB.CreateTemporary(xml,TRUE);
    xmldom.writeToClob(doc,xml); -- HERE I GET THE ERROR
    dbms_xmldom.WriteToFile(f,xml);
    WHILE (pos < len) LOOP
    vxml := dbms_lob.substr(xml,100,pos);
    utl_file.put(f,vxml);
    pos := pos+100;
    END LOOP;
    utl_file.fclose(f);
    END;

  • ERROR WITH XMLDOM.WRITETOCLOB

    Hi,
    I have written the following procedure...............
    procedure Prc_UpdateNodes(clString in out clob, nodename varchar2, nodeValue varchar2) is
         l_doc_node xmldom.DOMNode;
         l_xml_out varchar2(2000);
         begin
                   domDocument      := Fn_GetXmlDocument(clString);
                   nodeList           := xmldom.getElementsByTagName(domDocument, nodename);
                   intNoOfNode      := xmldom.getLength(nodeList);
                   l_doc_node := xmldom.item(nodeList, 0);
                   for loopCount_int in 0.. intNoOfNode - 1 loop
         node := XmlDom.item(nodeList, loopCount_int);
                        valueNode := XmlDom.getFirstChild(node);
                        XmlDom.setNodeValue(valueNode,nodeValue);
                   end loop;
                   XmlDom.writeToClob(domDocument,clString);
    end;
    This below XML Is passed as the first parameter
    The output after this operation for an xml should be..
    <ROWSET>
    <ROW>
    <SITE_NO Key="Yes">1</SITE_NO>
    <PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
    <PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
    <PARAMETER_SPEC_NO>1</PARAMETER_SPEC_NO>
    <REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
    <REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
    <SEQ_NO>1</SEQ_NO>
    <SUB_SEQN_NO>0</SUB_SEQN_NO>
    <DATA_TYPE_NO>1</DATA_TYPE_NO>
    <INTEGER_VALUE>0</INTEGER_VALUE>
    <STRING_VALUE>00039</STRING_VALUE>
    <NUMERIC_VALUE>0</NUMERIC_VALUE>
    <DATE_VALUE>01/01/1600</DATE_VALUE>
    <CREATED_ON>0</CREATED_ON>
    <MODIFIED_ON>0</MODIFIED_ON></ROW>
    <ROW>
    <SITE_NO Key="Yes">1</SITE_NO>
    <PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
    <PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
    <PARAMETER_SPEC_NO>2</PARAMETER_SPEC_NO>
    <REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
    <REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
    <SEQ_NO>2</SEQ_NO><SUB_SEQN_NO>0</SUB_SEQN_NO>
    <DATA_TYPE_NO>2</DATA_TYPE_NO>
    <INTEGER_VALUE>0</INTEGER_VALUE>
    <STRING_VALUE/>
    <NUMERIC_VALUE>0</NUMERIC_VALUE>
    <DATE_VALUE/>
    <CREATED_ON>0</CREATED_ON>
    <MODIFIED_ON>0</MODIFIED_ON>
    </ROW>
    </ROWSET>
    But the output I get is ……….
    <ROWSET>
    <ROW>
    <SITE_NO Key="Yes">1</SITE_NO>
    <PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
    <PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
    <PARAMETER_SPEC_NO>1</PARAMETER_SPEC_NO>
    <REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
    <REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
    <SEQ_NO>1</SEQ_NO>
    <SUB_SEQN_NO>0</SUB_SEQN_NO>
    <DATA_TYPE_NO>1</DATA_TYPE_NO>
    <INTEGER_VALUE>0</INTEGER_VALUE>
    <STRING_VALUE>00039</STRING_VALUE>
    <NUMERIC_VALUE>0</NUMERIC_VALUE>
    <DATE_VALUE>01/01/1600</DATE_VALUE>
    <CREATED_ON>0</CREATED_ON>
    <MODIFIED_ON>0</MODIFIED_ON></ROW>
    <ROW>
    <SITE_NO Key="Yes">1</SITE_NO>
    <PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
    <PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
    <PARAMETER_SPEC_NO>2</PARAMETER_SPEC_NO>
    <REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
    <REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
    <SEQ_NO>2</SEQ_NO><SUB_SEQN_NO>0</SUB_SEQN_NO>
    <DATA_TYPE_NO>2</DATA_TYPE_NO>
    <INTEGER_VALUE>0</INTEGER_VALUE>
    <STRING_VALUE/>
    <NUMERIC_VALUE>0</NUMERIC_VALUE>
    <DATE_VALUE/>
    <CREATED_ON>0</CREATED_ON>
    <MODIFIED_ON>0</MODIFIED_ON>
    </ROW>
    </ROWSET>
    0</MODIFIED_ON>
    </ROW>
    </ROWSET>
    The letter in bold above are the newly introduced junk letters
    I think this problem is due to the buffer isssues………….
    Do we have any solution for clearing the buffer….
    Also this error doesnt occur all the time.........
    Sometimes it comes, Sometimes it works fine
    The error is introduced during execution of the statement
    XmlDom.writeToClob(domDocument,clString);
    Can anyone help me on this front?????
    Thanks
    Message was edited by:
    user609257

    Thx for your response
    the program looks like this:
    I executed it from a Form;
    PROCEDURE PRUEBA IS
    xml clob;
    vxml varchar2(100);
    len integer := 1;
    pos integer := 1;
    f utl_file.file_type;
    doc xmldom.DOMDocument;
    ppal_node xmldom.DOMNode;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    user_node xmldom.DOMNode;
    tercer_node xmldom.DOMNode;
    item_node xmldom.DOMNode;
    ppal_elmt xmldom.DOMElement;
    root_elmt xmldom.DOMElement;
    item_elmt xmldom.DOMElement;
    item_text xmldom.DOMText;
    --Elementos de la cabecera
    header_pi xmldom.DOMProcessingInstruction;
    header_node xmldom.DOMNode;
    CURSOR MODULOS IS
    SELECT T_COAPI AS COAPI,
    T_DNAPI AS DNAPI     
    FROM     T
    WHERE     T_COAPI = 'PES';
    BEGIN
    --Creamos un nuevo DOM document
    doc := xmldom.newDOMDocument();
    ppal_node := xmldom.makeNode(doc);
    FOR Modulo IN Modulos LOOP
    -- El nodo es cada modulo
    root_elmt := xmldom.createElement(doc, 'Modulo');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    --COAPI
    item_elmt := xmldom.createElement(doc, lit_COAPI);
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_text := xmldom.createTextNode(doc, Modulo.COAPI);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    --DNAPI
    item_elmt := xmldom.createElement(doc, lit_DNAPI);
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_text := xmldom.createTextNode(doc, Modulo.DNAPI);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    END LOOP
    f := utl_file.fopen('TEMP_DIR','PRUEBA.xml','w');
    --Obtenemos la longitud del xml lob
    len := dbms_lob.getlength(xml);
    DBMS_LOB.CreateTemporary(xml,TRUE);
    xmldom.writeToClob(doc,xml); -- HERE I GET THE ERROR
    dbms_xmldom.WriteToFile(f,xml);
    WHILE (pos < len) LOOP
    vxml := dbms_lob.substr(xml,100,pos);
    utl_file.put(f,vxml);
    pos := pos+100;
    END LOOP;
    utl_file.fclose(f);
    END;

  • Exception when using  XMLDOM.appendData

    I am trying to create an xml-document containing base64 encoded data by using the xmldom packages on an 8.1.7 DB.
    Everthing works o.k. until I try to append data to an DOMCharacterData Node.This is the point where my function always ends up catching an ORA-29532 java.lang.ClassCastException exception
    I did a lot of research the last few days but did not find any similar cases.
    Does anyone have a solution or can provide hints where to find informations regarding.
    Thank you
    Edmund
    The following function is not exactly the one I am using but it also ends up in an exception!
    FUNCTION fddoc_CreateUploadDoc(pvi_Docname IN VARCHAR2, pvi_Doctype IN VARCHAR2, pvi_Data IN VARCHAR2)
    RETURN xmldom.DOMDocument
    IS
    doc                xmldom.DOMDocument;
    main_node           xmldom.DOMNode;
    root_node           xmldom.DOMNode;
    cmd_node           xmldom.DOMNode;
    document_node          xmldom.DOMNode;
    data_node          xmldom.DOMNode;
    data_cont          xmldom.DOMCharacterData;
    root_elmt           xmldom.DOMElement;
    cmd_elmt          xmldom.DOMElement;
    data_elmt               xmldom.DOMElement;
    BEGIN
         doc := xmldom.newDOMDocument;
         xmldom.setVersion(doc,'1.0');
         -- Root
         main_node := xmldom.makeNode(doc);
         root_elmt := xmldom.createElement(doc, 'ArchiveCommand');
         xmldom.setAttribute(root_elmt, 'version', '1.0');
         root_node := xmldom.appendChild( main_node, xmldom.makeNode(root_elmt));
         -- Command
         cmd_elmt := xmldom.createElement(doc,'ArchiveInsert');
         xmldom.setAttribute(cmd_elmt,'type','HYPARCHIV');
         xmldom.setAttribute(cmd_elmt,'archiveid',1);
         cmd_node := xmldom.appendChild( root_node, xmldom.makeNode(cmd_elmt));
         -- Document
         document_elmt := xmldom.createElement(doc,'Document');
         xmldom.setAttribute(document_elmt,'archiveid',1);
         xmldom.setAttribute(document_elmt, 'id','');
         xmldom.setAttribute(document_elmt, 'name',pvi_Docname);
         xmldom.setAttribute(document_elmt, 'type',pvi_Doctype);
         document_node := xmldom.appendChild(cmd_node, xmldom.makeNode(document_elmt));
         -- Data
         data_elmt := xmldom.createElement(doc,'Data');
         xmldom.setAttribute(data_elmt, 'type',pvi_Doctype);
         data_node := xmldom.appendChild(document_node, xmldom.makeNode(data_elmt));
         data_cont := xmldom.makeCharacterData(data_node);
         xmldom.appendData( data_cont,pvi_Data);/* <- this causes the Exception*/
         RETURN doc;
    END;

    Try something like requestScope or backingBeanScope.

  • HELP: DEADLINE!!!! ERROR PLS-00306: WITH APPENDCHILD

    I am new to this... any help is greatly appreciated..
    set serveroutput on
    CREATE OR REPLACE FUNCTION uf_buildWRDetail(pi_lWRNum IN NUMBER) RETURN VARCHAR2 IS
    xmlDoc xmlDom.DOMDocument;
    xmlDocOriginal xmlDom.DOMDocument;
    xmlDocAddOn xmlDom.DOMDocument;
    parserWRDetail xmlparser.Parser;
    parserWRAssoc xmlparser.Parser;
    parserTemp xmlparser.Parser;
    xmlDocElementO xmlDom.DOMElement;
    xmlDocElementA xmlDom.DOMElement;
    el xmlDom.DOMElement;
    xmlDOMList xmlDOM.DOMNodeList;
    xmlDOMNodeO xmlDOM.DOMNode;
    xmlDOMNodeA xmlDOM.DOMNode;
    xmlNodeVal xmlDOM.DOMNode;
    xmlNodeName xmlDOM.DOMNode;
    docNodeROOT xmlDOM.DOMNode;
    docNodeROWSET xmlDOM.DOMNode;
    docNodeROW xmlDOM.DOMNode;
    docNodeFIELD xmlDOM.DOMNode;
    docNodeTEXT xmlDOM.DOMNode;
    nodeAssocParty xmlDOM.DOMNode;
    nodeAPROW xmlDOM.DOMNode;
    xmlElement xmlDOM.DOMElement;
    cWRDetail CLOB;
    cWRAssoc CLOB;
    sNodeName VARCHAR2(2000);
    sNodeValue VARCHAR2(2000);
    nodeCount NUMBER;
    sTempOut VARCHAR2(32767);
    temp2 varchar2(255);
    BEGIN
    --=======================================================================
    -- MASTER OUT
    --=======================================================================
    parserTemp := xmlparser.newParser;
    xmlparser.parseBuffer(parserTemp,'<ROWSET/>');
    xmlDoc := xmlparser.getDocument(parserTemp);
    xmldom.setVersion(xmlDoc, '1.0');
    docNodeROOT := xmldom.makeNode(xmlDoc);
    docNodeROWSET := xmldom.getLastChild(docNodeROOT);
    el := xmldom.createElement(xmlDoc, 'ROW');
    docNodeROW := xmldom.appendChild(docNodeROWSET, xmldom.makeNode(el));
    --=======================================================================
    -- WORK DETAIL
    --=======================================================================
    -- this function returns a clob with the standard ROWSET/ROW namings
    --==============================================================================
    select uf_getWRDetail(pi_lWRNum) into cWRDetail from dual;
    --=============================================================================
    parserWRDetail := xmlparser.newParser;
    xmlparser.ParseCLOB(parserWRDetail, cWRDetail);
    xmlDocOriginal := xmlparser.getDocument(parserWRDetail);
    xmlDOMList := xmldom.getElementsByTagName(xmlDocOriginal, '*');
    nodeCount := xmldom.getLength(xmlDOMList);
    if nodeCount > 0 then
    for i in 2..nodeCount-1 loop
    xmlDOMNodeO := xmldom.item(xmlDOMList, i);
    sNodeName := xmldom.getNodeName(xmlDOMNodeO);
    xmlDOMNodeO := xmldom.getFirstChild(xmlDOMNodeO);
    sNodeValue := xmldom.getNodeValue(xmlDOMNodeO);
    docNodeFIELD := xmldom.makeNode(xmldom.createElement(xmlDoc, sNodeName));
    docNodeTEXT := xmldom.makeNode(xmldom.createTextNode(xmlDoc, NVL(sNodeValue,' ')));
    xmlNodeVal := xmldom.appendChild(docNodeROW, docNodeFIELD);
    xmlNodeVal := xmldom.appendChild(docNodeFIELD, sNodeValue);
    end loop;
    end if;
    --=======================================================================
    -- WORK DETAIL END
    --=======================================================================
    -- TEMPORARILTY REMOVED...
    --=======================================================================
    -- ASSOCIATED PARTIES
    --=======================================================================
    -- select uf_getWRAssocParties(pi_lWRNum) into cWRAssoc from dual;
    -- parserWRAssoc := xmlparser.newParser;
    -- xmlparser.ParseCLOB(parserWRAssoc, cWRAssoc);
    -- xmlDocAddOn := xmlparser.getDocument(parserWRAssoc);
    -- xmlDOMList := xmldom.getElementsByTagName(xmlDocAddOn, '*');
    -- nodeCount := xmldom.getLength(xmlDOMList);
    -- if nodeCount > 0 then
    -- el := xmldom.createElement(xmlDoc, 'ASSOCPARTIES');
    -- nodeAssocParty := xmldom.appendChild(docNodeROW, xmldom.makeNode(el));
    -- for i in 2..nodeCount-1 loop
    -- el := xmldom.createElement(xmlDoc, 'ASSOCPARTIESROW');
    -- nodeAPROW := xmldom.appendChild(nodeAssocParty, xmldom.makeNode(el));
    -- xmlDOMNodeO := xmldom.item(xmlDOMList, i);
    -- sNodeName := xmldom.getNodeName(xmlDOMNodeO);
    -- xmlDOMNodeO := xmldom.getFirstChild(xmlDOMNodeO);
    -- sNodeValue := xmldom.getNo deValue(xmlDOMNodeO);
    -- docNodeFIELD := xmldom.makeNode(xmldom.createElement(xmlDoc, sNodeName));
    -- docNodeTEXT := xmldom.makeNode(xmldom.createTextNode(xmlDoc, NVL(sNodeValue,' ')));
    -- xmlNodeVal := xmldom.appendChild(nodeAPROW, docNodeFIELD);
    -- xmlNodeVal := xmldom.appendChild(docNodeFIELD, sNodeValue);
    -- end loop;
    -- end if;
    --=======================================================================
    -- ASSOCIATED PARTIES END
    --=======================================================================
    xmldom.writeToBuffer(xmlDoc, sTempOut);
    RETURN sTempOut;
    END;
    /

    Hello!
    Please check Type and Number of Parameters of the called Procedure/Function
    This is a common PL/SQL-Error, not an XML-specific one.
    Bye and be blessed

Maybe you are looking for

  • Transaction type 148: affiliated company indicator not allowed

    I am trying to create new transfer variant for intercompany asset transfers, but when saving I am getting error AC768 Transaction type 148: affiliated company indicator not allowed'. Interesting, transaction type 148 is not used in any of the existin

  • READ DATASET

    Hi Friends, I'm getting problem in reading only 100 records from the application server using the READ DATASET statement. The file on the application server may have 8000 records but i wanted to get only 100 records and process them. Then i wanted to

  • How do you reduce the burn speed on a pc???

    I've been getting the dreaded 4310 error and discovered, through searching the discussions, that reducing the burn speed could solve the problem. However, I can't find anything on how to do that on a pc? I have a compaq nc6000 laptop. I've had the pr

  • Sequence issue with Toplink 9048

    We are trying to get sequences to work using Toplink 9.048 but keep getting errors. We reference are sequences in our descriptors like the following: descriptor.setSequenceNumberFieldName("ACRS_APPOINTMENT.ID"); descriptor.setSequenceNumberName("ACRS

  • How to use Boot Camp without an operating disk

    Purchased my iMac and received an upgrade to Snow Leapord a week later.  Have upgraded several times and now have Lion operating system.  Have never received an operating system disc. Used Boot Camp to partition for PC programs.  Boot Camp does not w