1 Reply Latest reply on Sep 13, 2013 3:27 AM by Jason_(A_Non)

    autogenerate XMLP data template


      Community, Can I add any kind of tag element to be able to auto generate data template using dbms_xmldom. While the first query works the second query fails with the following error


      Sample of example "XMLP data template" can be found at the end of this link Building a Data Template</title><meta http-equiv="Content-Type" content="text/html; charset=us-a…


      1. select xmltype('<ROOT> <LEAF1>''''TEST123''''</LEAF1>  </ROOT>'   ) xml from dual;


      2. select xmltype('<group name="''G_SOURCE''" dataType="''varchar2''" source=''"Q_MAIN"''><GROUP name=''''test''''> <element name="''Source"'' dataType="''varchar2"'' value="''Source''"/>  </GROUP>'   ) xml  from dual;



      ORA-31011: XML parsing failed

      ORA-19202: Error occurred in XML processing

      LPX-00240: element-start tag is not well formed

      Error at line 1

      ORA-06512: at "SYS.XMLTYPE", line 310

      ORA-06512: at line 1


      Thanks in advance.


        • 1. Re: autogenerate XMLP data template

          Not really sure where you are going, but this fixes several errors in the second statement.

          SQL> select xmltype('<group name="G_SOURCE" dataType="varchar2" source="Q_MAIN"><GROUP name="test"> <element name="Sourc
          e" dataType="varchar2" value="Source"/>  </GROUP></group>') xml  from dual;
          <group name="G_SOURCE" dataType="varchar2" source="Q_MAIN">
            <GROUP name="test"


          My SQL*Plus session is not set to show the full XML, but it is there given no error was returned.


          As long as you are creating valid XML, you can do pretty much whatever is needed via dbms_xmldom.  You can also do the same using the SQL/XML functions as shown in Generating XML using SQL Functions