1 Reply Latest reply: Sep 12, 2013 10:27 PM by Jason_(A_Non) RSS

    autogenerate XMLP data template

    User418766

      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;

       

      Error::

      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.

      Maha

        • 1. Re: autogenerate XMLP data template
          Jason_(A_Non)

          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;
          
          XML
          --------------------------------------------------------------------------------
          <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