XML File Generation

How we can generate XML file using Oracle PL/SQL!!
We have oracle supplied packages for this!!! Which is preferable for printing table data into XML file!!!!
DBMS_XMLDOM
DBMS_XMLGEN
DBMS_XMLPARSER
DBMS_XMLQUERY
DBMS_XMLSAVE
DBMS_XMLSchema
DBMS_XMLStore
UTL_FILE
Thanks

There may be several alternative ways, but maybe the simplest way around is using object views and spool the data coming -
CREATE TABLE warehouse_table (
WarehouseID NUMBER,
Area NUMBER,
Docks NUMBER,
DockType VARCHAR2(100),
WaterAccess VARCHAR2(10),
RailAccess VARCHAR2(10),
Parking VARCHAR2(20),
VClearance NUMBER );
INSERT INTO warehouse_table
VALUES(5, 103000,3,’Side Load’,'false’,'true’,'Lot’,15);
CREATE VIEW warehouse_view OF XMLTYPE
– XMLSCHEMA “http://www.oracle.com/xwarehouses.xsd”
– ELEMENT “Warehouse”
WITH OBJECT ID
(extract(OBJECT_VALUE, ‘/Warehouse/Area/text()’).getnumberval())
AS SELECT XMLELEMENT(”Warehouse”,
XMLFOREST(WarehouseID as “Building”,
area as “Area”,
docks as “Docks”,
docktype as “DockType”,
wateraccess as “WaterAccess”,
railaccess as “RailAccess”,
parking as “Parking”,
VClearance as “VClearance”))
FROM warehouse_table;
SELECT VALUE(e) FROM warehouse_view e;
VALUE(E)
<Warehouse><Building>5</Building><Area>103000</Area><Docks>3</Docks><DockType>Si..
Best regards.

Similar Messages

  • Error in XML file generation :240416

    Hi All,
    I am facing problem with XML file generation.
    Steps:
    1. Source-->Query Transform and maintained Nested Stucture
    2. Generated XML fomat from query transform
    3. Created XML format file
    4. Make XML format as target and given XML generate path
    source table-->Query(nested structure)-->XML Format
    when I validate the job no errors found.
    Note: XSD file is in Local mechine and XML file will be generated in SFTP.
    Prooblems:
    1. Getting below error
    The input XML refers to file which is not part of the definition of this XML Schema format. Check your schema and XML files,
    and check that the root element in the XML file corresponds to the root element in the XML Schema
    Validate your XML Schema using external schema validators (found at w3.org)
    Thanks,
    Deepa

    Hi,
    I think issue Because in your Query Transform output the Root element is Query and XML target is having some other root element. Make the Query trasform name similar to root element and try...

  • 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/)

  • Basic doubt about XML file generation

    Hi,
    I am new to Java. I am facing some trouble designing and implementing a particular problem involving XML files.
    Problem:
    I have an XML file which contains a set of properties and their default value. What I need to do is to read another file/stream which will have name=value strings and then, for all the names that I find there, change default value to current value. These names can appear in any order. For example,
    <name1 value=default1/>
    <name2 value=default2/>
    <name3 value=default3/>
    And I will get something like "set name3=value3 name1=value1" (This data comes to me from a stream -usb device- and not from a file). Then I should change it to
    <name1 value=value1/>
    <name2 value=default2/>
    <name3 value=value3/>
    What is the best possible way to do this in Java? This has to go into an embedded system so it will be nice if it can be done with minimum memory and less processing power.
    I am currently reading J2EEtutorial (1.4). I have not read much. But I am confused if I should be using SAX, DOM or XSLT. To speak the truth, I don't even know the difference between all those. Any help will be greatly appreciated.
    Thanks & Regards,
    Suseelan

    Use a DOM parser to parse the original XML.
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
    Document document = domBuilder.parse( inputStreamToFile );Then read in the contents from your USB stream into say an array or Vector. Then go through each child node in the domBuilder class, get the nodes name and see if it's in the Vector of objects from the USB stream. If it is, then replace the "Value" attribute in the dom node with what is in the Vector.
    Make sense?
    Message was edited by:
    bryano

  • Web.xml file generation problem

    Hi,
    I am trying to create web.xml file automatically using "java weblogic.marathon.ddinit.WebInit
    " command.
    I got the following message in the command prompt:
    Found Web components. Initializing descriptors
    filters=0 servlets=0 tags=0
    Above command is creating the web.xml and weblogic.xml files but it is not including
    the servlet-mapping information. why?
    Thanks,
    Prakash

    It doesn't look like it found any servlets. You'd have to show me your
    files if I'm to understand what's going on.
    -- Rob
    Prakash wrote:
    Hi,
    I am trying to create web.xml file automatically using "java weblogic.marathon.ddinit.WebInit
    " command.
    I got the following message in the command prompt:
    Found Web components. Initializing descriptors
    filters=0 servlets=0 tags=0
    Above command is creating the web.xml and weblogic.xml files but it is not including
    the servlet-mapping information. why?
    Thanks,
    Prakash

  • Wait XML File Generation and Present in APEX

    Hi All,
    I need advice on how can I implement following -
    I will be creating Input XML file using database procedure called from APEX, which will then go and executed the call using web services and create output XML file in one of the output directory. What I need help is -
    1. Once execute the initial call, then I need to be keep looking for file under output directory. Once the file is generated then I can show it on APEX, but I would like to know how can I implement, so continuously watch the directory for the file and as soon as file generated pick that file and present on APEX and stop watching directory for file.
    2. Also APEX will be used by many users concurrently, so how can I create and direct unique file for their own sessions, so myfile should not go to another user?
    Please advice

    There are lots of thread on ingesting XML and generating XML in this forum. Have a read through some of them and you should get some ideas on where to start. In particular look for threads on rcreating elational views of XML documents and using the SQL/XML Operators

  • XML file generation in Java

    Hello,
    I'm using XML files to communicate two systems. The XML files fulfill a W3C Schema.
    I want to know if there is any Java library, API or something like this, to generate automatically XML files that fulfill a schema, giving the schema file and the data to fill the XML file.
    Thanks,
    Laura.

    Please use the code tags when posting code, as described in the formatting tips.
    http://forum.java.sun.com/help.jspa?sec=formatting

  • XML File generation and watching continuously on directory present on APEX

    Hi All,
    I need advice on how can I implement following -
    I will be creating Input XML file using database procedure called from APEX, which will then go and executed the call using web services and create output XML file in one of the output directory. What I need help is -
    1. Once execute the initial call, then I need to be keep looking for file under output directory. Once the file is generated then I can show it on APEX, but I would like to know how can I implement, so continuously watch the directory for the file and as soon as file generated pick that file and present on APEX and stop watching directory for file.
    2. Also APEX will be used by many users concurrently, so how can I create and direct unique file for their own sessions, so myfile should not go to another user?
    Please advice

    Hi Keith
    11g uses the EPG so the images are stored in the database, however are also accessible as a webfolder. This is the same as (or very similar to) XE which I've previously successfully installed this on. The files have been uploaded to the images directory as I'm able to reference /i/sample.html in the iframe successfully. I've never needed to change the .xml file and run apxldimg script, a simple copy and paste has always worked. However, I will try this just to make sure.
    Hi Denes
    I've tried putting in the absolute path of the directory, which I assume you mean the full path i.e. http://localhost:8080/images/charts_library. But this makes no difference. I know there are differences with 11g, the EPG and that you have to open http://localhost:8080/images/ as a web folder rather than http://localhost:8080/i/ to access the files in the images directory. However, the database that your example application on http://htmldb.oracle.com is running on is an 11g database. It's running 11.1.0.6.0 the same as my database, so it must be possible and by the fact you didn't know this I assume you didn't need to make any changes to make it work!
    Sara

  • Datalink sequence method (XML file generation problem using Rdf)

    Hi All
    I want to Generate XML File using RDF , Here i used 4 datablocks and i lilnked each datablock with datalink like 1 to 2, 1to 3 and 1 to 4 respectively. while executing the report it choosing only one link like 1 to 2 and writting the data in the file for the same. its not touching 3rd and 4th datablocks I need to have data for all the blocks that are available.
    One more thing i want to close each blockonce the data is written in the file.But in this case the tags get open wites data goes to the other block write the data for this block come back to the first block and closes the block.
    eg: <Start>
    <First block>
    <Second block>
    <Third Block>
    </Third block>
    </second block>
    </First block>
    </Start>
    My requirment is
    <start>
    <First block>
    </First block>
    <Second block>
    </Second block>
    <Third Block>
    </Third block>
    </Start>

    You might want to look at the SQL/XML operators XMLAGG, XMLELEMENT, XMLFOREST, XMLATTRIBUTES. They provide you with fine grained control over the XML generated.

  • Automatic xml file generation

    parsing xml file and then getting data from xml is ok but is there any api that support xml file generatoion from data itself
    help plz

    JDOM has an XMLOutputter.
    DOM Level 3 allegedly supports outputting from the DOM itself.
    However if you don't want to use JDOM, and you don't have access to DOM Level 3, there is a way to do it using transformers. I'm not sure if this is a trick or whether it's considered the standard way to do it.
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    Document dom; // this is what you want outputted
    OutputStream stream; // this is where you want it outputted
    Transformer identity = TransformerFactory.newInstance().newTransformer();
    identity.transform(new DOMSource(dom), new StreamResult(stream));Note that it's not actually much code if you keep the identity transform around for reuse. JDOM's approach is a lot simpler though. :-)

  • How to suppress ?xml version = '1.0'? in XML file generation thru PLSQL?

    Hi,
    I am using
    1. dbms_xmlgen.newContext to get the information from table.
    2. After that I am using dbms_lob.createtemporary
    3. Then I am using dbms_xmlgen.getXml
    4. Finally I am using dbms_xmlgen.closecontext
    I am using the above four steps to repatedly taking records from different tables.
    My requirement is : Each and every time I am getting the <?xml version = '1.0'?>.
    How to suppress <?xml version = '1.0'?> ?
    Regards
    Srini

    Hi,
    Use DBMS_XMLGEN.getXMLType to retrieve the XML data into an XMLType variable.
    Then, with getClobVal method, you can convert it to CLOB :
    SQL> DECLARE
      2    v_xml XMLType;
      3    v_lob CLOB;
      4  BEGIN
      5    v_xml := dbms_xmlgen.getXMLType('select * from scott.emp where rownum = 1');
      6    v_lob := v_xml.getClobVal();
      7 
      8    dbms_output.put_line(v_lob);
      9  END;
    10  /
    <ROWSET>
    <ROW>
      <EMPNO>7369</EMPNO>
      <ENAME>SMITH</ENAME>
      <JOB>CLERK</JOB>
      <MGR>7902</MGR>
      <HIREDATE>17/12/80</HIREDATE>
      <SAL>800</SAL>
      <DEPTNO>20</DEPTNO>
    </ROW>
    </ROWSET>
    PL/SQL procedure successfully completed

  • XSD schema to xml file generation using C#

    Hi fellow developers,
    I need small help with my current scenario.
    I have 2 xsd schemas one is input and other is output.
    Now my requirement is based on those xsd template or structure, i need to write a C# code that takes the 1 xsd template as input in xml format and then do some mapping and then set that values to 2 xsd template in xml format.
    Can you please guide or assist in this regards ??
    It would be helpful if we have the flexibility of configuring the schema properties.

    Hi
    Venky_Ferrari.
    Based on your description, your case related to XMLXSD, SO I will move your thread to
    Data Platform Development > XML, System.Xml, MSXML and XmlLite      
    forum for better support.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Avoid the xml file generation

    hi all,
    i installed oracle 10g r2 in my machine.
    os is windows XP.
    in E:\oracle\product\10.2.0\db_1\sysman\emd\upload location every day
    lot of files are generated and consume lot of memory.
    i want to know what is the reason for this files and how to avoid the same.
    Thanks

    reshumakur wrote:
    hi all,
    i installed oracle 10g r2 in my machine.
    os is windows XP.
    in E:\oracle\product\10.2.0\db_1\sysman\emd\upload location every day
    lot of files are generated and consume lot of memory.Files don't consume memory. They consume disk space.
    i want to know what is the reason for this files and how to avoid the same.
    ThanksThese files are used by OEM to populate the repository with run-time info. More info can be found in the appropriate documents at tahiti.oracle.com There are configurations available to ensure proper housekeeping of these files.

  • Custom Application Privs for XML file generation in 11i(11.5.7)

    We have created Custom Application Module in the Oracle Apps R11i.
    I am running the below query in my custom application module user using SQL*Plus, it gives the error:
    SQL Statment:
    DECLARE
    queryCtx DBMS_XMLQuery.ctxType;
    result CLOB;
    BEGIN
    -- set the query context.
    queryCtx := DBMS_XMLQuery.newContext('select * from per_all_people_f where
    rownum <=10');
    DBMS_XMLQuery.setRowTag(queryCtx,'EMP'); -- sets the row tag name
    DBMS_XMLQuery.setRowSetTag(queryCtx,'EMPSET'); -- sets rowset tag name
    result := DBMS_XMLQuery.getXML(queryCtx); -- get the result
    DBMS_XMLQuery.closeContext(queryCtx); -- close the query handle;
    END;
    Error:
    Error on line 0
    DECLARE
    queryCtx DBMS_XMLQuery.ctxType;
    result CLOB;
    BEGIN
    -- set t
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.NullPointerException
    ORA-06512: at "SYS.DBMS_XMLQUERY", line 206
    ORA-06512: at "SYS.DBMS_XMLQUERY", line 214
    ORA-06512: at "SYS.DBMS_XMLQUERY", line 204
    ORA-06512: at line 11
    The same query is running fine with apps user. What are the objects privileges required for the custom module user?.

    I have found resolution for this.
    1. Created the Public Synonym for the following Apps user Java Class objects:
    /109a284b_OracleXMLStaticQuery
    /12249373_OracleXMLStaticQuery
    /c33162ba_OracleXMLStaticQuery
    2. Execute privilege for Apps.DBMS_XMLQUERY to custom application user.
    Thanks.
    -Venkat

  • How do I modify invoice request xml file by adding posting date?

    Hi,
    We import customer invoice requests via xml files from an external data source. Currently the standard SAP xml file does not include the posting date, and invoices enter SAP with a blank posting date. When the invoice is released, the posting date is taken from the invoice date.
    Due to our month end processes, we have hundreds of invoice requests every month where we do not want posting date to equal the invoice date, and for each of those invoices the posting date is manually entered one invoice at a time during the release process. This is very time consuming.
    We would like to build functionality in our external system to create the posting date at the xml file generation stage. Could anyone let us know the following:
    - what is the name of the posting date field on invoice requests (invoice documents)?
    - where would we place the additional script in the xml file?
    I'm attaching one of our current xml files (which already contains one section that has been customized)
    Your suggestions would be appreciated.
    Thanks,
    Kerstin

    Kerstin,
    The closest i could find in the WSDL of the Manage Invoice Request Web Service that handles this integration is "<ProposedInvoiceDate>" or possibly even "<ProposedDeviatingPostingdate>", both of which sit directly under the <CustomerInvoiceRequest> element.
    For more information, go to the Service Explorer, find the ManageInvoiceRequestsIn Web Service, download the WSDL, and open it in SOAP-UI or something similar. This way you can see all the fields that you can write to, which is where i found these two elements.

Maybe you are looking for

  • Regarding an Apple TV and an existing Airport Express/AirTunes setup

    alright, i think i'm going to make the jump now for the new Apple TV. but i do have a few questions, particularly re: my existing Airport Express/AirTunes and wiring since i'm really maxed out in terms of open ports that i have left. —my HDMI will ha

  • How do I add an individual photo from a stack to an album?

    I'm trying to add a photo from a stack to an album. However, even if I un-stack the photos in the parent folder & copy a single photo into the album when I then re-stack the original photos they all appear in the album too. Is there a way around this

  • Error while activating 0FIGL_O02 ODS

    Hi , It showing error while activating 0FIGL_O02 ODS .I have already allowed all special character "ALL_CAPITAL,.<>?/:;"{}[]||=-)(*&^%$#@!~`"'-_,ALL_CAPITAL_PLUS_HEX",but it's still showing error in particular field  0DOC_HD_TXT . Errror:Value 'AMITB

  • My ipod classic 120GB won't sync to itunes

    I have updated itunes and un-installed and re-installed it multiple times but I've had no luck. I have deleted all the content off of my ipod but it still won't sync to itunes, any help please? I have spent hours trying to find a solution but I feel

  • HTTP to RFC synchronous scenario Issue

    Hi Folks,     Currently I'm working on a HTTP to RFC synchronous scenario.  Everything went well till i triggered the message. While triggering the message i'M GETTING IS AS BELOW Result: http-Status:  500 Internal Server Error Payload: <SAP:Error> <