Formatting XML using DBMS_XMLGEN

Hi.
Having Problems with generating XML out of a query using nested table types
-- Heres a test case
drop type test_tab
drop type test_type
drop type sub_type_tab
drop type sub_type
create or replace type sub_type as object ( "@a" varchar2(10), "@b" varchar2(10) );
create or replace type sub_type_tab as table of sub_type;
create or replace type test_type as object ( "@c" VARCHAR2(10), test sub_type_tab );
CREATE OR REPLACE TYPE test_tab AS TABLE OF test_type;
CREATE OR REPLACE VIEW test_view OF test_type
WITH OBJECT IDENTIFIER ("@c")
AS
SELECT
'C',
CAST(MULTISET(SELECT 'A', 'B' FROM DUAL) AS sub_type_tab)
FROM dual
The resultant XML out of DBMS_XMLGEN.GETXML is :
<?xml version="1.0"?>
<ROWSET>
<ROW c = "C">
<TEST>
<SUB_TYPE a="A" b="B"/>
</TEST>
</ROW>
</ROWSET>
As you can see as a consequence of the column collection type alias in the view
i have an extraneous <TEST> tag.
Does anyone know how I can remove this tag entry?
Thanks in advance

Marco,
I tryed to work with dbms_xslprocessor.clob2file,
that works good,
but what is in this matter with encoding UTF-8 ?
in my understandig, the xmltyp created should be UTF8 (16),
but when open the xml-file in xmlSpy as UTF-8,
it is not well ( german caracter like Ä, Ö .. ):
my dbms is
NLS_CHARACTERSET = WE8MSWIN1252
NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_RDBMS_VERSION = 10.2.0.1.0
-- test:
create table nh_test ( s0 number, s1 varchar2(20) ) ;
insert into nh_test (select 1,'hallo' from dual );
insert into nh_test (select 2,'straße' from dual );
insert into nh_test (select 3,'mäckie' from dual );
insert into nh_test (select 4,'euro_€' from dual );
commit;
select * from nh_test ;
S0     S1
1     hallo
1     hallo
2     straße
3     mäckie
4     euro_€
declare
rc sys_refcursor;
begin
open rc FOR SELECT * FROM ( SELECT s0,s1 from nh_test );
dbms_xslprocessor.clob2file( xmltype( rc ).getclobval( ) , 'XML_EXPORT_DIR','my_xml_file.xml');
end;
( its the same when using output with DBMS_XMLDOM.WRITETOFILE )
open in xmlSpy is:
<?xml version="1.0"?>
<ROWSET>
<ROW>
<S0>1</S0>
<S1>hallo</S1>
</ROW>
<ROW>
<S0>2</S0>
<S1>straޥ</S1>
</ROW>
<ROW>
<S0>3</S0>
<S1>m㢫ie</S1>
</ROW>
<ROW>
<S0>4</S0>
<S1>euro_€</S1>
</ROW>
</ROWSET>
regards
Norbert

Similar Messages

  • How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?

    How to get UTF-8 encoding when create XML using DBMS_XMLGEN and UTL_FILE ?
    Hi,
    I do generate XML-Files by using DBMS_XMLGEN with output by UTL_FILE
    but it seems, the xml-Datafile I get on end is not really UTF-8 encoding
    ( f.ex. cannot verifying it correct in xmlspy )
    my dbms is
    NLS_CHARACTERSET          = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET     = AL16UTF16
    NLS_RDBMS_VERSION     = 10.2.0.1.0
    I do generate it in this matter :
    declare
    xmldoc CLOB;
    ctx number ;
    utl_file.file_type;
    begin
    -- generate fom xml-view :
    ctx := DBMS_XMLGEN.newContext('select xml from xml_View');
    DBMS_XMLGEN.setRowSetTag(ctx, null);
    DBMS_XMLGEN.setRowTag(ctx, null );
    DBMS_XMLGEN.SETCONVERTSPECIALCHARS(ctx,TRUE);
    -- create xml-file:
    xmldoc := DBMS_XMLGEN.getXML(ctx);
    -- put data to host-file:
    vblob_len := DBMS_LOB.getlength(xmldoc);
    DBMS_LOB.READ (xmldoc, vblob_len, 1, vBuffer);
    bHandle := utl_file.fopen(vPATH,vFileName,'W',32767);
    UTL_FILE.put_line(bHandle, vbuffer, FALSE);
    UTL_FILE.fclose(bHandle);
    end ;
    maybe while work UTL_FILE there is a change the encoding ?
    How can this solved ?
    Thank you
    Norbert
    Edited by: astramare on Feb 11, 2009 12:39 PM with database charsets

    Marco,
    I tryed to work with dbms_xslprocessor.clob2file,
    that works good,
    but what is in this matter with encoding UTF-8 ?
    in my understandig, the xmltyp created should be UTF8 (16),
    but when open the xml-file in xmlSpy as UTF-8,
    it is not well ( german caracter like Ä, Ö .. ):
    my dbms is
    NLS_CHARACTERSET = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET = AL16UTF16
    NLS_RDBMS_VERSION = 10.2.0.1.0
    -- test:
    create table nh_test ( s0 number, s1 varchar2(20) ) ;
    insert into nh_test (select 1,'hallo' from dual );
    insert into nh_test (select 2,'straße' from dual );
    insert into nh_test (select 3,'mäckie' from dual );
    insert into nh_test (select 4,'euro_€' from dual );
    commit;
    select * from nh_test ;
    S0     S1
    1     hallo
    1     hallo
    2     straße
    3     mäckie
    4     euro_€
    declare
    rc sys_refcursor;
    begin
    open rc FOR SELECT * FROM ( SELECT s0,s1 from nh_test );
    dbms_xslprocessor.clob2file( xmltype( rc ).getclobval( ) , 'XML_EXPORT_DIR','my_xml_file.xml');
    end;
    ( its the same when using output with DBMS_XMLDOM.WRITETOFILE )
    open in xmlSpy is:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <S0>1</S0>
    <S1>hallo</S1>
    </ROW>
    <ROW>
    <S0>2</S0>
    <S1>straޥ</S1>
    </ROW>
    <ROW>
    <S0>3</S0>
    <S1>m㢫ie</S1>
    </ROW>
    <ROW>
    <S0>4</S0>
    <S1>euro_€</S1>
    </ROW>
    </ROWSET>
    regards
    Norbert

  • Creating XML using DBMS_XMLGEN with a namespace

    Is it possible to create an XMLTYPE using the DBMS_XMLGEN function set that contains a namespace. As far as I can see only the 'setrowsettag' function allows any control over what goes into the root element - should I be including, for example, an attribute called 'xmlns' with a value?
    The reason I ask all this is I'm trying to validate xml created from a select statement against a registered xsd.
    The xsd I've registered:
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <xs:schema targetNamespace="http://www.sepa.org/2007/XMLSchemas/Site" xmlns:sit="http://www.sepa.org/2007/XMLSchemas/Site" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sepa.org/2007/XMLSchemas/Site Site.xsd" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:flags="311" oraxdb:schemaURL="http://www.sepa.org/2007/XMLSchemas/Site.xsd" oraxdb:schemaOwner="XMLDBMASTER" oraxdb:numProps="14">
    <xs:element name="site" oraxdb:propNumber="5953" oraxdb:global="true" oraxdb:SQLName="site" oraxdb:SQLType="site1681_T" oraxdb:SQLSchema="XMLDBMASTER" oraxdb:memType="258" oraxdb:defaultTable="site1683_TAB" oraxdb:defaultTableSchema="XMLDBMASTER">
    <xs:annotation>
    <xs:documentation>Comment describing your root element</xs:documentation>
    </xs:annotation>
    <xs:complexType oraxdb:SQLType="site1681_T" oraxdb:SQLSchema="XMLDBMASTER">
    <xs:sequence>
    <xs:element name="SiteIDType" type="xs:ID" oraxdb:propNumber="5940" oraxdb:global="false" oraxdb:SQLName="SiteIDType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="SiteNameType" type="xs:string" minOccurs="1" oraxdb:propNumber="5941" oraxdb:global="false" oraxdb:SQLName="SiteNameType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="SiteAddressStructure" oraxdb:propNumber="5947" oraxdb:global="false" oraxdb:SQLName="SiteAddressStructure" oraxdb:SQLType="SiteAddressStructure1682_T" oraxdb:SQLSchema="XMLDBMASTER" oraxdb:memType="258" oraxdb:SQLInline="true" oraxdb:MemInline="false" oraxdb:JavaInline="false">
    <xs:complexType oraxdb:SQLType="SiteAddressStructure1682_T" oraxdb:SQLSchema="XMLDBMASTER">
    <xs:sequence>
    <xs:element name="AddressLine1" type="xs:string" minOccurs="1" oraxdb:propNumber="5942" oraxdb:global="false" oraxdb:SQLName="AddressLine1" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="AddressLine2" type="xs:string" minOccurs="0" oraxdb:propNumber="5943" oraxdb:global="false" oraxdb:SQLName="AddressLine2" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="AddressLine3" type="xs:string" minOccurs="0" oraxdb:propNumber="5944" oraxdb:global="false" oraxdb:SQLName="AddressLine3" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="AddressLine4" type="xs:string" minOccurs="1" oraxdb:propNumber="5945" oraxdb:global="false" oraxdb:SQLName="AddressLine4" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="PostCode" type="xs:string" minOccurs="0" oraxdb:propNumber="5946" oraxdb:global="false" oraxdb:SQLName="PostCode" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="SiteTelephoneNoType" type="xs:string" minOccurs="0" oraxdb:propNumber="5948" oraxdb:global="false" oraxdb:SQLName="SiteTelephoneNoType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="SiteMobilePlantType" type="xs:string" minOccurs="0" oraxdb:propNumber="5949" oraxdb:global="false" oraxdb:SQLName="SiteMobilePlantType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="SiteFaxNoType" type="xs:string" minOccurs="0" oraxdb:propNumber="5950" oraxdb:global="false" oraxdb:SQLName="SiteFaxNoType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <!--***Location code must reference the code in the Location Dataset***-->
    <xs:element name="SiteLocationCode" type="xs:string" minOccurs="1" oraxdb:propNumber="5951" oraxdb:global="false" oraxdb:SQLName="SiteLocationCode" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    <xs:element name="SitePopulationEquivType" type="xs:positiveInteger" minOccurs="0" oraxdb:propNumber="5952" oraxdb:global="false" oraxdb:SQLName="SitePopulationEquivType" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:SQLInline="true" oraxdb:MemInline="true" oraxdb:JavaInline="true"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    The method for generating the XML:
    DECLARE
    v_ctx DBMS_XMLGEN.ctxhandle;
    v_xml XMLTYPE;
    BEGIN
    v_ctx:=DBMS_XMLGEN.newcontext
    SELECT e.site_id "SiteIDType", e.site_name "SiteNameType", sit_address(e.addr_line1, e.addr_line2,
    e.addr_line3, e.addr_line4, e.post_code) AS "SiteAddressStructure", e.tel_no "SiteTelephoneNoType"
    , e.mobile_plant "SiteMobilePlantType",
    e.fax_no "SiteFaxNoType", e.ge1_location_code "SiteLocationCodeType" ,e.population_equivalent "SitePopulationEquivType"
    FROM EL03_SITES e
    WHERE e.site_id = 15'
    DBMS_XMLGEN.setrowsettag (v_ctx, 'site');
    DBMS_XMLGEN.setrowtag (v_ctx, NULL);
    v_xml := DBMS_XMLGEN.getxmltype (v_ctx);
    INSERT INTO js_xml_test
    (ID, xml_data
    VALUES ('site test', v_xml
    COMMIT;
    DBMS_XMLGEN.closecontext (v_ctx);
    END;
    The resulting XML:
    <site>
    <SiteIDType>15</SiteIDType>
    <SiteNameType>Finlas Water Treatment Works</SiteNameType>
    <SiteAddressStructure>
    <AddressLine1>Finlas Water Treatment Works</AddressLine1>
    <AddressLine2>Shermor Farm</AddressLine2>
    <AddressLine3>Luss</AddressLine3>
    <AddressLine4>Alexandria</AddressLine4>
    <PostCode>G83 8RH</PostCode>
    </SiteAddressStructure>
    <SiteTelephoneNoType>01389 850224</SiteTelephoneNoType>
    <SiteMobilePlantType>N</SiteMobilePlantType>
    <SiteLocationCodeType>123428</SiteLocationCodeType>
    </site>
    When I try to validate it, I get:
    ORA-30937: No schema definition for 'site' (namespace '') in parent '/'
    ORA-06512: at "SYS.XMLTYPE", line 345
    ORA-06512: at line 30
    How do I get a namespace declaration in the XML? Any suggestions gratefully received.

    Did you change any of the text in the lob write statements ?
    I believe you get this error if you increase the number of characters without increasing the 1st argument which looks as though it represents the number of characters

  • Exception When trying to Format XML using JSTL

    Hi all
    I m trying to display content of XML in a .jsp page using JSTL ,
    When i try to dispaly the content it is thowing an exception :
    org/saxpath/SAXPathException
    Can any one please help ....
    i m using jstl1.0.6.jar and standard-1.0.6.jar
    Code Snppet Used:
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
    <c:set var="someXML">
    <name>Sri</name>
    </c:set>
    <x:parse var="parsedDocument" xml="${someXML}" />
    <x:out select="$parsedDocument/name" />
    Thanks in Advance

    Thank for reply
    I had even tried with this code:
    <c:set var="someXML">
         <person>
              <name>Joe</name>
              <age>30</age>
         </person>
    </c:set>
    <x:parse varDom="parsedDocument" xml="${someXML}" />
         <x:set var="name" select="$parsedDocument/person/name" />
         <c:out value="${name}" />
    even then i m getting the same exception:
    Message: org/saxpath/SAXPathException

  • Setting Two Row Tags issue using DBMS_XMLGEN.setrowtag ?

    Hi All,
         Am generating a xml using DBMS_XMLGEN.
         I want to generate a XML in the following format
         <MAIN>
         <PACK = 1>
         <EMP DETAILS>
              Some data goes here     
         <EMP DETAILS>     
    <PACK = 2>
         <EMP DETAILS>
                   Some data goes here
         <EMP DETAILS>     
                   Some data goes here
         <EMP DETAILS>
                   Some data goes here
    <PACK = 3>
         <EMP DETAILS>
                   Some data goes here
         <EMP DETAILS>     
                   Some data goes here               
         <EMP DETAILS>
         <MAIN>
         Am able to set the only the following
         DBMS_XMLGEN.setrowsettag('xmlhandle','MAIN');
         DBMS_XMLGEN.setrowtag('xmlhandle','EMP DETAILS');
         But the problem is setting another row tag <PACK>
         Is it possible to set another rowtag ?
         Please any inputs on this will be really helpful?

    I don't think you can set two different row tags in dbms_xmlgen. I'm also not sure about the "= 1", "= 2", etc. strings in your PACK tags. Perhaps I'm missing something but that doesn't look like legal XML.
    Here's an approach that may help anyway though ...
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    set echo on
    set long 10000
    set longchunksize 10000
    set pagesize 100
    create or replace type emp_details as object
    ( empno integer, ename varchar2(10) )
    Type created.
    create or replace function getxmldata return clob
    is
      mysql dbms_xmlgen.ctxHandle ;
      v_result clob ;
    begin
      mysql :=
        dbms_xmlgen.newContext
          'select emp_details( empno, ename ) as emp_details
          from emp where deptno = 10'
      dbms_xmlgen.setrowsettag(mysql,'MAIN');
      dbms_xmlgen.setrowtag(mysql,'PACK');
      v_result := dbms_xmlgen.getXML(mysql) ;
      dbms_xmlgen.closeContext( mysql );
      return( v_result );
    end;
    Function created.
    show errors
    No errors.
    select getxmldata from dual ;
    GETXMLDATA
    <?xml version="1.0"?>
    <MAIN>
    <PACK>
      <EMP_DETAILS>
       <EMPNO>7782</EMPNO>
       <ENAME>CLARK</ENAME>
      </EMP_DETAILS>
    </PACK>
    <PACK>
      <EMP_DETAILS>
       <EMPNO>7839</EMPNO>
       <ENAME>KING</ENAME>
      </EMP_DETAILS>
    </PACK>
    <PACK>
      <EMP_DETAILS>
       <EMPNO>7934</EMPNO>
       <ENAME>MILLER</ENAME>
      </EMP_DETAILS>
    </PACK>
    </MAIN>
    1 row selected.
    drop function getxmldata ;
    Function dropped.
    drop type emp_details ;
    Type dropped.--
    Joe Fuda
    SQL Snippets

  • Dynamically creating XML using Sap-xMII Colum and Row Action Block

    Hi,
    I am trying to create a xMII-format XML using IlluminatorDocument Action Block.
    My problem statement is during run time I am required to create columns on the fly.which I have done using xMII Colum Action block.but now I am required to assing values to these dynamically created columns.I have tried using Data Item and Row action block but am not sucessful in doing so.Can anyone help in creating this xml Dynamically.
    The steps that I have followed is
    defined
    tagquery action block and defined tagquery
    blank Illuminator Document Action block
    put a repeater on result of tag query
    set a counter
    updated the counter
    used column action block and mapped the column name i.e IlluminatorColumn_0.Name------"test"&Local.count
    my column output looks like
    Rowsets DateCreated="2007-03-27T12:59:39" EndDate="2007-03-27T11:42:40" StartDate="2007-03-27T11:42:40" Version="11.5.0">
         <Rowset>
              <Columns>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test1" SQLDataType="1" SourceColumn="test1"/>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test2" SQLDataType="1" SourceColumn="test2"/>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test3" SQLDataType="1" SourceColumn="test3"/>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test4" SQLDataType="1" SourceColumn="test4"/>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test5" SQLDataType="1" SourceColumn="test5"/>
              </Columns>
    </Rowset>
    </Rowsets>
    after this action block i want to assign values to each column i.e
         <Row/>
              <Row/>
              <Row/>
              <Row/>
              <Row/>
    i.e erach row tags should be filled with columntag and value
    but i am not able to achieve the same
    Can anyone help me doing this

    After adding IllumColum Action block I have created 5 columns dynamically
    but now I am unable to add row.
    currently for everycolumn created it is giving one row  without any column node
    the configurations that I have done in Data Item Action Block is
    In My Link Editor
    IlluminatorColumn_0.Name----
    >IlluminatorDataItem_0.Name
    hardcoded the value i.e 20----
    >IlluminatorDataItem_0.Value
    IlluminatorDocument_0.Output----
    >IlluminatorDataItem_0.IlluminatorDocument
    current resultset I am getting is
    <?xml version="1.0" encoding="UTF-8"?>
    <Rowsets DateCreated="2007-03-27T12:59:39" EndDate="2007-03-27T11:42:40" StartDate="2007-03-27T11:42:40" Version="11.5.0">
         <Rowset>
              <Columns>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test1" SQLDataType="1" SourceColumn="test1"/>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test2" SQLDataType="1" SourceColumn="test2"/>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test3" SQLDataType="1" SourceColumn="test3"/>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test4" SQLDataType="1" SourceColumn="test4"/>
                   <Column Description="" MaxRange="100" MinRange="0" Name="test5" SQLDataType="1" SourceColumn="test5"/>
              </Columns>
              <Row/>
              <Row/>
              <Row/>
              <Row/>
              <Row/>
         </Rowset>
    </Rowsets>

  • Generate XML output using DBMS_XMLGEN.getxmltype and not from rdf

    Hi,
    I have a requirement to display output from a particular table in XL format. Out of all the known possible options, I am planning to use the XML publisher to generate XL output.
    For the data source, instead of using the conventional way of creating XML data using rdf,I am planning to use DBMS_XMLGEN.getxmltype pl/sql procedure to generate the XML output. And from the output, call the template to generate the required Excel output.
    Now, I am using the following code to generate XML output but am not sure how to proceed from here. I need to first print the XML data in the FND Output file after which I was planning to call the 'XML Report Publisher' (XDOREPPB) program and use the current request id to get the excel output but I am not able to find the way to print the XML data in the output file as:
    fnd_file.put_line (fnd_file.output, l_xml_type); - is throwing an error as l_xml_type is an XML data output.
    PROCEDURE xml_main (
    errbuf OUT VARCHAR2
    ,retcode OUT VARCHAR2
    ,p_project_from IN VARCHAR2
    ,p_project_to IN VARCHAR2
    AS
    l_xml_type XMLTYPE;
    BEGIN
    SELECT DBMS_XMLGEN.getxmltype
    ('SELECT fnd_global.conc_request_id
    ,TO_CHAR (segment1)
    ,to_char(start_date,''MM/DD/RRRR'')
    ,to_char(xxmcc_project_details_pkg.current_profit_projection
    (project_id),''999,999,990.90'')
    ,to_char(xxmcc_project_details_pkg.cost_to_date (project_id),''999,999,990.90'')
    ,''1''
    FROM pa_projects_all
    WHERE segment1 BETWEEN NVL (p_project_from, segment1)
    AND NVL (p_project_to, segment1)')
    INTO l_xml_type
    FROM DUAL;
         fnd_file.put_line (fnd_file.output, l_xml_type);
    END xml_main;
    Can anyone point me as to how to publish XML output using a PL/SQL procedure (DBMS_XMLGEN.getxmltype)
    Thanks.

    Pl see if the example included in this presentation helps http://www.oracle.com/technology/products/applications/Events/OOW-2006/EBS/S281401_Sridhar_Bogelli.pdf
    Also, you do not need to explicitly call XDOREPPB in later versions of XML Publisher. If you set up everything correctly (as described in the presentation above and the link below) the Output Post Processor is called automatically after the XML file is generated successfully.
    Another excellent tutorial is at http://www.oracle.com/technology/obe/fusion_middleware/fusion/bi/xmlp_ebiz/index.html
    HTH
    Srini

  • XML File Generation Issues using DBMS_XMLGEN

    Hi,
    I am using DBMS_XMLGEN package in a stored procedure to generate an XML file on Oracle 10 G R2 .But, the problem is the format in which the file is generated.
    CREATE OR REPLACE TYPE "state_info" as object (
    "@product_type" Number
    CREATE OR REPLACE TYPE prod_tab as TABLE OF "state_info";
    CREATE OR REPLACE TYPE state_t as object (
    "state_code" CHAR(2),
    "state_info" prod_tab
    CREATE OR REPLACE PROCEDURE get_xml_serviced_state (p_clob OUT clob)
    IS
    v_xmlctx DBMS_XMLGEN.ctxhandle;
    v_str VARCHAR2 (1000);
    BEGIN
    v_str := 'SELECT state_t(a.st_cd,CAST(MULTISET(select veh_type_id from svcd_st where st_cd =a.st_cd)as prod_tab)) as "state_info"
    from svcd_st a where a.st_cd in (select distinct st_cd from svcd_st) group by a.st_cd having count(*)>=1';
    v_xmlctx := DBMS_XMLGEN.newcontext (v_str);
    DBMS_XMLGEN.setrowsettag (v_xmlctx,'serviced_state');
    DBMS_XMLGEN.setrowtag (v_xmlctx,NULL);
    p_clob := DBMS_XMLGEN.getxml (v_xmlctx);
    printclobout(p_clob);
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    RAISE;
    END;
    SHOW ERRORS
    Output :
    <serviced_state>
    <state_info state_code="VA">
    <state_info>
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </state_info>
    <state_info state_code="AB">
    <state_info>
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </state_info>
    </serviced_state>
    Required it in below format:
    <serviced_state>
    <state_info state_code="VA">
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    <state_info state_code="AB">
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </serviced_state>
    I just need to put in all the rows under one single tag.Appreciate your early responses.
    Thanks.

    Your wanted XML output is NOT VALID...(try it yourself on http://tools.decisionsoft.com/schemaValidate/)

  • Xml report output in excel format without using options tab in EBS

    How to get xml publisher report output in excel format without using options tab in EBS?
    I am getting XML Publisher report output in excel format by using options tab while submitting the concurrent request .
    But i want to get excel output automatically.
    Can anyone give idea to get XML publisher Report output in excel without selecting options tab.
    Thanks in advance
    Sandeep V

    Hey Sandeep,
    I am working on a similar format for a report and if possible can you please give me some guidelines. I have initially created reports using XML Publisher, but for those , the output preview format was PDF. So, if I select the preview format as EXCEL will it give me output in Excel and for this to happen, how do I define the rtf template. I believe the working will be same as for PDF, create a rdf report, get output in XML and apply the template to get the data in Excel or there is something different to this.
    Thanks,
    Sunil

  • How to filter particular xml tag value using -DBMS_XMLGEN / DBMS_XMLSTORE

    Hi,
    I am using dbms_xmlgen and dbms_xmlstore package to extract xml datafile tag value from file server to oracle database table.
    I have used the below pl/sql program to extract the xml tag values to oracle relational table.Its working fine for me.
    But I would like to extract the values based on particular filter condition.
    The following xml program I have 3 rows I would like extract the xml data based on the following condition .
    Filter condition
    ==============
    the tag <STATE_ABBREVIATION> value shuold be 'CA' and the <CITY> tag value should be Palo_Alto then I will store the ZIPCODE
    ZIP_CODE_EXTN,STATE_ABBREVIATION tag values in the Oracle Relational table.
    The below pl/sql program storing all the three rows but I required the values based on the filter condition that I mentioned earlier.
    Kindly assist me what are the steps that I need to change in this program.?
    XML Program file content.
    ======================
    <ZIPCODES>
    <mappings>
    <STATE_ABBREVIATION>CA</STATE_ABBREVIATION>
    <ZIPCODE>94301</ZIPCODE>
    <ZIP_CODE_EXTN>9277</ZIP_CODE_EXTN>
    <CITY>Palo_Alto</CITY>
    </mappings>
    <mappings>
    <STATE_ABBREVIATION>CA</STATE_ABBREVIATION>
    <ZIPCODE>95302</ZIPCODE>
    <ZIP_CODE_EXTN>9279</ZIP_CODE_EXTN>
    <CITY>LA</CITY>
    </mappings>
    <mappings>
    <STATE_ABBREVIATION>TX</STATE_ABBREVIATION>
    <ZIPCODE>75038</ZIPCODE>
    <ZIP_CODE_EXTN>7837</ZIP_CODE_EXTN>
    <CITY>DALLAS</CITY>
    </mappings>
    </ZIPCODES>
    PL/SQL Program for XML extract.
    ==========
    declare
    charString varchar2(80);
    finalStr varchar2(4000) := null;
    rowsp number;
    insCtx DBMS_XMLStore.ctxType;
    ctx dbms_xmlgen.ctxHandle;
    v_FileHandle UTL_FILE.FILE_TYPE;
    begin
    v_FileHandle := utl_file.fopen('XMLTEST','XML_NEW_CITIES.XML','r') ;
    loop
    BEGIN
    utl_file.get_line(v_FileHandle, charString);
    exception
    when no_data_found then
    utl_file.fclose(v_FileHandle);
    exit;
    END;
    dbms_output.put_line(charString);
    if finalStr is not null then
    finalStr := finalStr || charString;
    else
    finalStr := charString;
    end if;
    end loop;
    insCtx := DBMS_XMLStore.newContext('SYS.ZIPCODES');
    dbms_xmlgen.setRowsetTag(insCtx,'ZIPCODES');
    dbms_xmlgen.setRowsetTag(insCtx,'mappings');
    DBMS_XMLStore.clearUpdateColumnList(insCtx);
    DBMS_XMLStore.setUpdateColumn(insCtx,'ZIPCODE');
    DBMS_XMLStore.setUpdateColumn(insCtx,'ZIP_CODE_EXT N');
    DBMS_XMLStore.setUpdateColumn(insCtx,'STATE_ABBREV IATION');
    rowsp := dbms_xmlstore.insertXML(insCtx,finalstr);
    end;
    Thanks,
    nat

    Thanks for your reply. :)
    Its working fine in the DBMS_XMLSTORE package. Here I have given the code
    CREATE OR REPLACE TYPE typ_dummy AS  OBJECT
    ( "@ENO"   NUMBER,
      "@ENAME" VARCHAR2(100),
      eno      NUMBER,
      ename    VARCHAR2(100));
    CREATE TABLE EMP
      empno    VARCHAR2(25),
      sal      NUMBER,
      hiredate DATE,
      typ      TYP_DUMMY
    DECLARE
      insCtx DBMS_XMLStore.ctxType;
      rows NUMBER;
      xmldoc CLOB :=
        '<ROWSET>
           <ROW num="1">
             <SAL>1800</SAL>
             <EMPNO>739</EMPNO>
             <HIREDATE>27-AUG-1996</HIREDATE>
               <TYP ENO="739" ENAME="Nazurullah">
               <ENO> 1 </ENO>
               <ENAME> ALDRIN </ENAME>
               </TYP>
           </ROW>
           <ROW>
             <SAL>18000</SAL>
             <EMPNO>7369</EMPNO>
             <HIREDATE>27-AUG-1996</HIREDATE>
             <TYP ENO="7369" ENAME="PEPPIN" />
           </ROW>
           <ROW>
             <SAL>37000</SAL>
             <EMPNO>20701</EMPNO>
             <HIREDATE>27-AUG-1996</HIREDATE>
             <TYP>
               <ENO> 20701 </ENO>
               <ENAME> VENKATACHALAM </ENAME>
             </TYP>
           </ROW>
         </ROWSET>';
    BEGIN
      insCtx := DBMS_XMLStore.newContext('emp'); -- get saved context
      -- Now insert the doc.
      -- This will only insert into EMPNO, SAL and HIREDATE columns
      rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
      -- Close the context
      DBMS_XMLStore.closeContext(insCtx);
    END;
    SELECT * FROM emp;
    EMPNO        SAL HIREDATE          TYP(@ENO, @ENAME, ENO, ENAME)
    739         1800 27-AUG-96     TYP_DUMMY(739, 'Nazurullah', 1, ' ALDRIN ')
    7369       18000 27-AUG-96     TYP_DUMMY(7369, 'PEPPIN', NULL, NULL)
    20701      37000 27-AUG-96     TYP_DUMMY(NULL, NULL, 20701, ' VENKATACHALAM ')

  • Add xmlns tag to Xml file using DBMS_XMLGEN

    I am using Oracle Release 10.1.0.4.2 version .
    I want to create a xml file according to some data available in the relational database tables. For the same i created object types and then view with the object types since data is scattered in many tables.
    Then i used DBMS_XMLGEN.getxml to generate the xml with query from the object view.
    Is there an option to add xmlns attribute to the generated xml file.
    Please let me know if any additional details are needed.

    If you want to add the namespace declaration in the root element, I don't think it's possible with DBMS_XMLGEN directly.
    You can instruct DBMS_XMLGEN to treat some object fields as XML attributes by prefixing them with "@" (e.g. "@my_attribute") but you cannot control that for enclosing elements.
    A possible solution is to add it afterwards using XSLT, or insertChildXML, but apparently the latter is not available in your version.
    However...
    For the same i created object types and then view with the object types since data is scattered in many tables.Since the data comes from different tables, why not use SQL and SQL/XML functions to build the document?
    It's straightforward, simple, and doesn't need additional objects.
    select xmlelement("Departments",
             xmlattributes('http://xmlns.example.org' as "xmlns")
           , xmlagg(
               xmlelement("Department",
                 xmlattributes(d.deptno as "Id")
               , xmlelement("Name", d.dname)
               , xmlelement("Employees"
                 , xmlagg(
                     xmlelement("Employee",
                       xmlattributes(e.empno as "Id")
                     , xmlforest(
                         e.ename as "Name"
                       , e.job as "Job"
                     ) order by e.empno
               ) order by d.deptno
    from scott.dept d
         join scott.emp e on e.deptno = d.deptno
    group by d.deptno, d.dname
    ;Output :
    <Departments xmlns="http://xmlns.example.org">
      <Department Id="10">
        <Name>ACCOUNTING</Name>
        <Employees>
          <Employee Id="7782">
            <Name>CLARK</Name>
            <Job>MANAGER</Job>
          </Employee>
          <Employee Id="7839">
            <Name>KING</Name>
            <Job>PRESIDENT</Job>
          </Employee>
          <Employee Id="7934">
            <Name>MILLER</Name>
            <Job>CLERK</Job>
          </Employee>
        </Employees>
      </Department>
      <Department Id="20">
        <Name>RESEARCH</Name>
        <Employees>
          <Employee Id="7369">
            <Name>SMITH</Name>
            <Job>CLERK</Job>
          </Employee>
          <Employee Id="7566">
            <Name>JONES</Name>
            <Job>MANAGER</Job>
          </Employee>
          <Employee Id="7902">
            <Name>FORD</Name>
            <Job>ANALYST</Job>
          </Employee>
        </Employees>
      </Department>
      <Department Id="30">
        <Name>SALES</Name>
        <Employees>
          <Employee Id="7499">
            <Name>ALLEN</Name>
            <Job>SALESMAN</Job>
          </Employee>
          <Employee Id="7521">
            <Name>WARD</Name>
            <Job>SALESMAN</Job>
          </Employee>
          <Employee Id="7654">
            <Name>MARTIN</Name>
            <Job>SALESMAN</Job>
          </Employee>
          <Employee Id="7698">
            <Name>BLAKE</Name>
            <Job>MANAGER</Job>
          </Employee>
          <Employee Id="7844">
            <Name>TURNER</Name>
            <Job>SALESMAN</Job>
          </Employee>
          <Employee Id="7900">
            <Name>JAMES</Name>
            <Job>CLERK</Job>
          </Employee>
        </Employees>
      </Department>
    </Departments>

  • Using a CWM format XML as datastore; COM SDK to read the file and create Universe

    Hello everyone
    We are in the process of migrating from a metadata store to BusinessObjects Universe and the plan is to use Java/COM SDK to accomplish that. We have run into limitations with both the SDKs. Java SDK doesn't provide that facility and using COM SDK we are trying to read from a XML file (metadata in CWM format) and create the universe but so far haven't been successful. If the (Universe)Designer can read a CWM format xml file (say created from BODS) we are wondering why can't a customer made COM program do the same.
    Has anyone attempted this and been successful. Please acknowledge.
    Thanks

    I have written C#.NET code to build universes on the fly using the Designer SDK with no problems.  However, I wasn't using CWM formatted data to do this.
    I have two suggestions for you:
    1.  Since not all of the functionality in the Designer tool seems to be available through the SDK, can you parse the CWM xml file in your code and build the universe based on the data instead of trying have Designer build it?
    2.  Since you're using Java, you may get better answers by posting this question in the Java SDK Application Development space here:  http://scn.sap.com/community/bi-platform/java-sdk
    -Dell

  • How to format generated XML using XMLELEMENT() my output is coming in a single line i want it to be in a XML format

    hi I am having problem in formatting XML file which I generated with xmlelement() when I execute it gives me putput in a single line
    is there any way that I got my output as a XML file HAS......

    That is expected behavior. PRETTY print(ing) is only needed for humans. XML Parsers don't need the XML to be pretty printed. If you open the XML file in a browser like Windows Explorer or Firefox, the browser will pretty print the output for you.
    In all, the "single line" output is done because of PERFORMANCE reasons (lack of unneeded end of line and CTRL line breaks etc)
    SELECT xmlelement("Employee Name", dummy) as "XML RESULT"
    FROM DUAL;
    <Employee Name>X</Employee Name>
    SELECT xmlelement("Employee Name", xmlelement("SurName", dummy)
                                     , xmlelement("LastName", dummy)
                     ) as "XML RESULT"
    FROM DUAL;
    <Employee Name><SurName>X</SurName><LastName>X</LastName></Employee Name>
    XMLSERIALIZE can pretty print the output if needed via INDENTation
    SELECT XMLSERIALIZE(CONTENT xmlelement("Employee Name", xmlelement("SurName", dummy), xmlelement("LastName", dummy)) as CLOB indent SIZE=1 )
    FROM DUAL;
    <Employee Name>
         <SurName>X</SurName>
         <LastName>X</LastName>
    </Employee Name>

  • How do I save an excel file as XML using applescript.

    I set display alerts to false, but excel will not save.  I get error -1708.
    My code looks as such:
    set theFile to "Macintosh HD:Users:Dustin:Documents:products.xlsx"
    tell application "Microsoft Excel"
      activate
      open theFile
              set display alerts to false
              tell active sheet
      save as filename "products.xml" file format XML spreadsheet file format
              end tell
      close active workbook without saving
              set display alerts to true
    end tell
    end
    If I remove the code to set the display alerts, excel pops up an display alert to continue or cancel the save.
    I'll take anything at this point....

    Are you sure you want to do a "SAVEAS" to create the PDF?  What version of MS Office are you using?
    One of the best ways to figure out how to do something with ActiveX in Excel is to first do it in Excel by recording a Macro.  See what code Excel generates, then try to model that in LabVIEW.
    I don't see .pdf as an option you can save Excel as a filetype to (Excel 2007).  But when I go to the Excel 2007 button, Save As, then PDF or XPS while recording a macro, I get this code.
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Documents and Settings\CurrentUser\Desktop\FILENAME.pdf", Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True
       This shows me you should be usingthe ExportAsFixedFormat method on the worksheet as opposed to trying to use the SaveAs method on the workbook.  (But the workbook object as that same method as well.)

  • Using dbms_xmlgen with a CAST statement

    The following code populates a plsql collection and then attempts to select from it using dbms_xmlgen.
    the following error results --
    DECLARE
    ERROR at line 1:
    ORA-19206: Invalid value for query or REF CURSOR parameter
    ORA-06512: at "SYS.DBMS_XMLGEN", line 83
    ORA-06512: at line 56
    The query is correct as the commented out select at end of block works fine.
    Can dbms_xmlgen be used in such a way and if not is there a workaround.
    Thanks
    DECLARE
    types declared on the database
    create or replace type bus_tab_obj AS object
    ( BUSINESS_MODEL_ID NUMBER(10)
    ,BUSINESS_MODEL_VER_NO NUMBER(5)
    ,BUSINESS_MODEL_NAME VARCHAR2(30));
    create or replace TYPE bus_table AS TABLE of bus_tab_obj;
    package level variable bus_table_recs in package get_values_pkg
    myxml sys.xmltype;
    queryCtx DBMS_XMLGen.ctxhandle;
    BEGIN
    -- initialise and delete
    get_values_pkg.bus_table_recs := bus_table(NULL,NULL,NULL);
    get_values_pkg.bus_table_recs.DELETE;
    -- select some records to put in the collection
    for x in ( select BUSINESS_MODEL_ID
    ,BUSINESS_MODEL_VER_NO
    ,BUSINESS_MODEL_NAME
    from BRK_BUSINESS_MODEL )
    LOOP
    get_values_pkg.bus_table_recs.extend;
    get_values_pkg.bus_table_recs := bus_table(bus_tab_obj(x.business_model_id
    ,x.business_model_ver_no
    ,x.business_model_name));
    END LOOP;
    -- retrieve the records from the collection as xml
    queryCtx := DBMS_XMLGen.newContext('select a.business_model_name data from THE ( select cast( get_values_pkg.bus_table_recs as bus_table ) from dual ) a order by data');
    dbms_xmlgen.setMaxRows(queryCtx,1);
    myxml := DBMS_XMLGen.getXMLType(queryCtx);
    dbms_output.put_line(myxml.extract('/*').getStringVal());
    this works!
    for x in ( select a.business_model_name data
    from THE ( select cast( get_values_pkg.bus_table_recs as bus_table ) from dual ) a
    order by data )
    loop
    dbms_output.put_line( x.data );
    end loop;
    END;
    /

    891794 wrote:
    Thank you all , see I am new to this database field , I am not a pro.Not a problem. However, one of the very first things you should learn is that dynamic SQL is seldom needed and invariably just plain wrong.
    If a table name is dynamic, or a column name is dynamic - then chances are excellent that your data model is already fubar'ed (or malema'ed to put it in a za.org perspective).
    And even when you are in the very exceptional situation where dynamic SQL is needed, SQL injection is a MAJOR security concern.. and almost always ignored by implementing shoddy code to create and execute the dynamic SQL.

Maybe you are looking for