Generating XML from dual

Hey Gurus,
I'm trying to generate the following XML from dual, however, I keep getting an error message stating my top level is not defined. Any ideas? Thanks!
<PUDOOUTPUT>
<PKG>
<SHIPMENTID>12345</SHIPMENTID>
<ERROR>'NO DATA'</ERROR>
<ERRORTEXT>'Error: Cannot find shipper alias in SPL_SHIPPER_ACCOUNTS.'</ERRORTEXT>
</PKG>
</PUDOOUTPUT>
select xmlelement("PUDOOUTPUT",xmlelement("PKG",xmlelement("SHIPMENTID",i.shipmentid),
xmlelement("ERROR",'NO DATA'),
xmlelement("ERRORTEXT",'Error: Cannot find shipper alias in SPL_SHIPPER_ACCOUNTS.')))
into p_wms_output
from dual;

Hi,I need to generate XML FIle.Since i m new to XML.
I had toregister the valid schema in my DB now i want to generate the XML file and with the refernce to this schema that xml file should be validated one against that schema.
things i hav done till now
->i hav registered the scehma
and the sample XML file provided by client
<?xml version="1.0"?>
<MEDMLDATA xmlns="PhaseForward-MedML-Inform4">
<!-- Insert Trial/Study Information -->
<STUDYVERSION UUID="id"
STUDYNAME="name"
VERSIONDESCRIPTION="text" />
<!-- Insert Site Personnel Information -->
<USER USERNAME="mmeyer"
USERTYPE = "SITE"
ACTIVESTATE = "TRUE"
DELETESTATE = "FALSE"
FIRSTNAME = "Marianne"
LASTNAME = "Meyer"
DISPLAYNAME = "Marianne Meyer"
TITLE = ""
HOMESCREENURL = "./Custom/HomeDefault.html"
PHONE = "(555) 555-1212"
FAX = "(555) 555-1212"
ALTPHONE = ""
EMAIL = "[email protected]"
ADDRESS = ""
ADDRESS2 = ""
CITY = ""
STATE = ""
ZIPCODE = ""
COUNTRY = ""
BEEPER = ""
USERMUSTRESETPASSWORD = "FALSE"
DESCRIPTION = ""
PASSWORD="changeme"/>
<USER USERNAME="john"
USERTYPE = "SITE"
ACTIVESTATE = "TRUE"
DELETESTATE = "FALSE"
FIRSTNAME = "John"
LASTNAME = "Meyer"
DISPLAYNAME = "John Meyer"
TITLE = ""
HOMESCREENURL = "./Custom/HomeDefault.html"
PHONE = "(555) 555-1212"
FAX = "(555) 555-1212"
ALTPHONE = ""
EMAIL = "[email protected]"
ADDRESS = ""
ADDRESS2 = ""
CITY = ""
STATE = ""
ZIPCODE = ""
COUNTRY = ""
BEEPER = ""
USERMUSTRESETPASSWORD = "FALSE"
DESCRIPTION = ""
PASSWORD="changeme"/>
<!-- Insert Site Information -->
<SITE NAME= "(01) Massachusetts General Hospital" MNEMONIC="01"
ADDRESS = "1 Main Street"
ADDRESS2 = ""
CITY = "Boston"
STATE = "MA"
ZIPCODE = ""
COUNTRY = "USA"
PHONE = "(555) 555-1212"
ALTPHONE = ""
FAX = ""
EMAIL = ""
TIMEZONE="(GMT-05:00) Eastern Time (US & Canada)"
SITEDATEFORMAT = "MONTH_DAY_YEAR"
STARTDATE = "April 1, 2005">
</SITE>
<SITE NAME= "(02) Boston General Hospital" MNEMONIC="01"
ADDRESS = "1 Main Street"
ADDRESS2 = ""
CITY = "Boston"
STATE = "MA"
ZIPCODE = ""
COUNTRY = "USA"
PHONE = "(555) 555-1212"
ALTPHONE = ""
FAX = ""
EMAIL = ""
TIMEZONE="(GMT-05:00) Eastern Time (US & Canada)"
SITEDATEFORMAT = "MONTH_DAY_YEAR"
STARTDATE = "April 1, 2005">
</SITE>
<!-- Insert SITE and User Mapping Information -->
<SITEGROUP SITENAME="(01) Massachusetts General Hospital">
<USERREF USERNAME="mmeyer"/>
</SITEGROUP>
<SITEGROUP SITENAME="(02) Boston General Hospital">
<USERREF USERNAME="John"/>
</SITEGROUP>
<!-- Insert User ROle Information -->
<RIGHTSGROUP GROUPNAME="CRA">
<!-- Insert Rights -->
<RIGHTREF RIGHT="Print"/>
<RIGHTREF RIGHT="Monitor"/>
<RIGHTREF RIGHT="Canned Reports"/>
<RIGHTREF RIGHT="View CRF"/>
<RIGHTREF RIGHT="View Signature History for CRF"/>
<RIGHTREF RIGHT="View Signature History for CRB"/>
<RIGHTREF RIGHT="Data Export Listings"/>
<RIGHTREF RIGHT="Freeze a CRF"/>
<RIGHTREF RIGHT="Unfreeze a CRF"/>
<RIGHTREF RIGHT="Mark and Unmark a CRF as SVed"/>
<RIGHTREF RIGHT="Freeze a CRB"/>
<RIGHTREF RIGHT="Unfreeze a CRB"/>
<RIGHTREF RIGHT="Change Query State from Candidate to Open"/>
<RIGHTREF RIGHT="Change Query State from Candidate to Deleted"/>
<RIGHTREF RIGHT="Change Query State from Answered to Closed"/>
<RIGHTREF RIGHT="Change Query State from Open to Closed"/>
<RIGHTREF RIGHT="Change Query State from Reissued Candidate to Closed"/>
<RIGHTREF RIGHT="Enter Query in Candidate State"/>
<RIGHTREF RIGHT="Enter Query in Open State"/>
<RIGHTREF RIGHT="Re-issue Query in Candidate State"/>
<RIGHTREF RIGHT="Re-issue Query in Open State"/>
<RIGHTREF RIGHT="Navigate by Visit"/>
<RIGHTREF RIGHT="Navigate by Form"/>
<RIGHTREF RIGHT="Reordering of Patients"/>
<!-- Insert Users for role -->
<USERREF USERNAME="mmeyer"/>
<USERREF USERNAME="john"/>
</RIGHTSGROUP>
</MEDMLDATA>
now i need to generate XML based on the above SAMple XML file,can anybody tell me how to generate XML file based on this..and after generating it should be validated against the registerd schema.

Similar Messages

  • How to generate XML from SQL query

    possible ways to generate XML from SQL qury.
    i want to generate XML of following query. "Select * from emp,dep wher emp.deptno=dept.deptno"

    Hello.
    Can you try:
    SQL> set pages 0
    SQL> set linesize 150
    SQL> set long 9999999
    SQL> set head off
    SQL> select dbms_xmlgen.getxml('Select * from emp,dep wher emp.deptno=dept.deptno') from dual;
    It works fine for me.
    Octavio

  • Remove spaces when generating xml from data mapped on object types

    My problem is kind of complex so I'll try to reduce it to a more manageable example:
    drop type msm force;
    drop type list_msm force;
    create type msm as object(
         nume char(20)
    create type list_msm as table of msm;
    select xmlserialize (document xmlelement("values",
         cast(multiset(
              select trim(p.den) from produse p) as list_msm
         ) as clob indent size=2
         ) as "xml"
         from dual;
    This is where it gets tricky.
    p.den is a field that contains spaces. I use trim(p.den) to remove them but because I cast this to list_msm, the values are then again mapped into msm objects, which have the "nume" field of char(20). So.. when generating the XML, the output still contains spaces.
    This is an excerpt of the result:
    <values>
    <LIST_MSM>
    <MSM>
    <NUME>Prod.1 </NUME>
    </MSM>
    <MSM>
    <NUME>Prod.2 </NUME>
    </MSM>
    <MSM>
    <NUME>Prod.3 </NUME>
    </MSM>
    <Later.. I see that the forum removes the extra spaces but I ensure you that after eg. "Prod.1" there are a lot of spaces, as the original field from the "produse" table is defined as char(20))
    So.. Is there a way to generate the XML without those extra spaces? Basically, I want to be able to trim them before I send them to the xml serializer, but the problem is that i have no control over the whole casting thing ( oracle magic happening that automatically creates all the xmlelements needed, etc.)
    Somehow, when the xml engine steps over the collection and accesses the fields, somehow, i need a trim there. Maybe some kind of accesor for the fields in the type can be declared so that the xml engine uses it instead of the field itself directly. The accesor would then return trim(field). Sorry for this mumbo jumbo gibberish but I want to be as clear as possible.
    Edited by: user9229988 on May 10, 2012 9:24 AM
    Edited by: user9229988 on May 10, 2012 9:25 AM
    Edited by: user9229988 on May 10, 2012 9:38 AM

    Hi.
    Check this:
    drop type msm force;
    drop type list_msm force;
    create type msm as object(
    nume VARchar2(20)     --VARCHAR2 NOT CHAR
    create type list_msm as table of msm;
    create table produse
    den char(20)
    INSERT INTO produse VALUES('Prod.1');
    INSERT INTO produse VALUES('Prod.2');
    INSERT INTO produse VALUES('Prod.3');
    COMMIT;
    select xmlserialize (document xmlelement("values",
    cast(multiset(
    select trim(p.den) from produse p) as list_msm
    ) as clob indent size=2
    ) as "xml"
    from dual;
    <values>
      <LIST_MSM>
        <MSM>
          <NUME>Prod.1</NUME>
        </MSM>
        <MSM>
          <NUME>Prod.2</NUME>
        </MSM>
        <MSM>
          <NUME>Prod.3</NUME>
        </MSM>
      </LIST_MSM>
    </values>Hope this helps.

  • How to generate XML from EBusiness suite ARXSGPO

    Could someone tell me how I can generate XML from the EBusiness Suite Accounts Receivable report ARXSGPO.rdf I understand this report is called by a C program. I have tried changing the concurrent request to output format to XML the result does not resemble XML. Does anyone have any suggestions how I can generate XML from the ARXSGPO report?
    Thanks,
    Mark

    Hi Mark
    the next release of XMLP will have last page only support. The problem is that at the template layer you do not know how many lines are going to fit on the page, so you never know what is going to be the last page. The only way around it for now is to specify the number of lines to a page and then check when all the lines have been rendered and then render the remit portion.
    I have a sample invoice that does the same, drop me a mail, you can work out the email from my name and the fact I work for XMLP Im sure.
    Tim

  • Generating XML from database

    I'm a total newbie in XML DB and need advice on generating XML from database.
    The situation is the following: there is a legacy web application which uses an XML document as a configuration file. This document conforms to some well-defined schema. For instance:
    <config>
         <title value="TITLE" />
         <subtitle value="SUBTITLE" />
         <style url="default.css" />
         <widgets>
              <widget id="1" opened="true" />
              <widget id="2" opened="false" />
         </widgets>
    </config>
    It contains portions of static data which are common for all users as well as dynamic personal data.
    Dynamic data comes from two sources:
    1) security considerations (for instance, not all widgets are available for some users) - thus the "master" configuration content must be filtered, but not otherwise modified;
    2) user preferences (for instance, user can set widget2 to be opened by default) - thus values of some attributes must be different for each user. When the user saves her preferences, the entire document with new values is posted back to server.
    We want to try to store user preferences, apply security and generate personalized configuration documents using XML DB.
    So we need advice on storage models and generation procedures - which should be more efficient and easy to support or extend.
    Please note, that there is no requirement to actually store data as XML.
    Thanks in advance!
    P.S.: Sorry for the incomplete initial post.
    Edited by: WxD on 27.09.2010 11:45

    Hi,
    See this link for more details
    http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10790/xdb13gen.htm

  • Generating XMLs from CSVs using DOM parser......

    Hi,
    I am trying to generate XMLs from CSV files using DOM parser. XMLs are getting generated but the problem is that i am using Encoding "ISO-8859-1" but XMLs are getting generated in UTF-8 encoding.
    Please refer to the code below and advice. (where are the code tags gone ????? )
    Source domSource = new DOMSource(document);
    ByteArrayOutputStream xmlStream = new ByteArrayOutputStream();
    Result result = new StreamResult(xmlStream);
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.transform(domSource, result);
    xmlStream.close();
    generatedXml = new String(xmlStream.toByteArray(), "*ISO-8859-1*");

    Use transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1") to specify the character set.

  • Generating XML from SQL queries and saving to an xml file?

    Hi there,
    I was wondering if somebody could help with regards to the following:
    Generating XML from SQL queries and saving to a xml file?
    We want to have a procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
    is accessed by our software on the client machine).
    Using this order number we do a couple of SQL queries.
    My first question: What would be our best option to convert the result of the
    queries to xml?
    Second Question: Once the XML has been generated, how do we save that XML to a file?
    (The XML file is going to be saved on the file system of the server that
    the database is running on.)
    Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
    Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
    the client hard drive.
    Any information would be greatly appreciated.
    Thanking you,
    Francois

    If you are using 9iR2 you do not need to do any of this..
    You can create an XML as an XMLType using the new SQL/XML operators. You can insert this XML into the XML DB repository using DBMS_XDB.createResource. You can then access the document from the resource. You can also return the XMLType containing the XML directly from the PL/SQL Procedure.

  • Generating XML from SQL queries and saving to a xml file?

    Hi there,
    I was wondering if somebody could help with regards to the following:
    Generating XML from SQL queries and saving to a xml file?
    We want to have a stored procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
    is accessed by our software on the client machine).
    Using this order number we do a couple of SQL queries.
    My first question: What would be our best option to convert the result of the
    queries to xml?
    Second Question: Once the XML has been generated, how do we save that XML to a file?
    (The XML file is going to be saved on the file system of the server that
    the database is running on.)
    Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
    Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
    the client hard drive.
    Any information would be greatly appreciated.
    Thanking you,
    Francois

    Hi
    Here is an example of some code that i am using on Oracle 817.
    The create_file procedure is the one that creates the file.
    The orher procedures are utility procedures that can be used with any XML file.
    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;

  • Hide name space of generated xml from xml bean

    Hi,
    how can i hide the namespace of the generated xml from xml bean, cause im having problems with jaxb parses.

    The targetNamespace is for webservice and not for the user defined classes.
    Sorry for the confusion
    Ajay
    "Ajay" <[email protected]> wrote in message
    news:[email protected]..
    There is a targetNamespace attribute in the autotyp ant task. But there
    was a bug in 8.1. Contact the support for a patch.
    The following mail explains that
    This looks like a bug. There is an undocument, not officially
    supported workaround: add the following java doc
    to yours source code -
    * @wlws:webservice targetNamespace="http://foo.bar"
    public class MyService {
    Details here:
    http://www.manojc.com/tutorial/sample3/source2wsdd.html
    Regards,
    -manoj
    http://manojc.com
    "Mark Fine" <[email protected]> wrote in message
    news:[email protected]..
    The attribute targetNamespace (of the autotype task) doesn't seem to putany
    information into the types file and later my deployment descriptor (viathe
    source2wsdd task) contains an invalid targetNamespace attribute with a
    http://tempuri.org:
    eg.
    <web-services>
    <web-service name="IndexService"
    targetNamespace="http://tempuri.org/"
    uri="/IndexWebService">
    I don't think this causes any problems but there should be a way tospecify
    the namespace.
    Has anyone else seen this is WLS8.1?
    "Siva" <[email protected]> wrote in message
    news:[email protected]..
    By default the autotype or the servicegen ant task seem to be creating anamespace
    from the java package name (like java:com.ventaso.external.common) for
    xml
    mapping
    of user defined java classes. Is there a way to change this to name
    space
    I want
    ? Specifying the targetnamespace doesn't seem to help.
    Thanks,
    Siva

  • Generate XML from tree

    I am trying to generate XML from a JTree. Does anyone know how I would go about it? I have been looking on google for examples but I can't find anything that would help.

    Have a method that takes a Node as its parameter. (I'm supposing you want each tree node to map to an element, but you didn't give any details.) Generate the opening tag for the element. Then for each child of the Node, pass the child to this same method recursively. Finally, generate the closing tag for the element.
    To get things started, call that method and pass it the root node of the tree.

  • How to add doctype when generating XML from an arbitrary data structure

    I was reading SUN's tutorial "Working with XML - PART IV: Using XSLT". Inside this tutorial, in 3, it talks about how to generate XML from an arbitrary data structure making use of a XMLReader and a Transformer. The example only shows adding elements. Is there a way to add DTD information in the XML generated, i.e. <!DOCTYPE ... >? What APIs can I use?
    Thanks,
    Alex

    The simplest way seems to me is to use a XSL file for that. The <xsl:output> attributes doctype-system and doctype-public generate the DTD declaration <!DOCTYPE YOUR_ROOT SYSTEM "yourDTDfile.dtd"> and <!DOCTYPE YOUR_ROOT PUBLIC "yourDTDfile.dtd">, respectively.
    When calling transformerInstance.transform() the XSLT processor performs the identity transformation - it just copies elements, attributes, content, processing instructions and comments to the result stream.
    If you're using an xsl file for your transformation already, simply add <xsl:output doctype-system="yourDTDfile.dtd"/> to your existing XSL file.
    If you're only using the identity transformation you'd need to change the line of code where you obtain the transformer instance from the TransformerFactory to:
    t_factory.newTransformer(new StreamSource("test.xsl"));
    and use this as test.xsl:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output doctype-system="yourDTDfile.dtd"/>
       <!-- this is the identity transformation -->
       <xsl:template match="*|@*|comment()|processing-instruction()|text()">
          <xsl:copy>
             <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
          </xsl:copy>
       </xsl:template>
    </xsl:stylesheet>Good luck.

  • Why it's so inefficient to generate XML from SQL queries?

    I am learning to use Oracle9i XML DB to generate XML document using SQL queries. According to the document, there are multiple ways to do it (SQLX, DBMS_XMLGEN, SYS_XMLGEN, XSU). I am using SQLX to do it, but find it's so inefficient. Could someone point out what could be the problem?
    I generate XML from TPC-H database, using the query as shown below. The indexes and primary key/foreign keys are created and specified. The system is Pentium IV 2GHz, Linux 2.4.18 with 512MB memory and 1GB swap. With database size 5MB, it spends about 300 seconds (TKPROF result) to generate the XML document. But for 10MB TPCH database, I cannot get the xml document after a long time. I find that all almost physical memory are used up by it. Therefore I stop it.
    It seems that nested-loop join is used to evaluate the query, therefore it's very inefficient. I don't know whether there is a efficient way to do it.
    Wish to get your help. Thank you very much!
    Chengkai Li
    ===================================================================================================================
    SELECT XMLELEMENT (
    "region",
    XMLATTRIBUTES ( r_regionkey AS "regionkey", r_name AS "name", r_comment AS "comment"),
    (SELECT XMLAGG(
    XMLELEMENT (
    "nation",
    XMLATTRIBUTES ( n_nationkey AS "nationkey", n_name AS "name", n_regionkey AS "regionkey", n_comment AS "comment"),
    XMLConcat ((SELECT XMLAGG(XMLELEMENT (
    "supplier",
    XMLATTRIBUTES ( s_suppkey AS "suppkey", s_name AS "name", s_address AS "address", s_nationkey AS "nationkey", s_phone AS "phone", s_acctbal AS "acctbal", s_comment AS "comment"),
    (SELECT XMLAGG(XMLELEMENT (
    "part",
    XMLATTRIBUTES ( p_partkey AS "partkey", p_name AS "name", p_mfgr AS "mfgr", p_brand AS "brand", p_type AS "type", p_size AS "size", p_container AS "container", p_retailprice AS "retailprice", p_comment AS "comment", ps_availqty AS "ps_availqty", ps_supplycost AS "ps_supplycost", ps_comment AS "ps_comment")))
    FROM PART p, PARTSUPP ps
    WHERE ps.ps_partkey = p.p_partkey
    AND ps.ps_suppkey = s.s_suppkey
         FROM SUPPLIER s
    WHERE s.s_nationkey = n.n_nationkey
    (SELECT XMLAGG(XMLELEMENT(
    "customer",
    XMLATTRIBUTES ( c_custkey AS "custkey", c_name AS "name", c_address AS "address", c_nationkey AS "nationkey", c_phone AS "phone", c_acctbal AS "acctbal", c_mktsegment AS "mktsegment", c_comment AS "comment"),
    (SELECT XMLAGG(XMLELEMENT (
    "orders",
    XMLATTRIBUTES ( o_orderkey AS "orderkey", o_custkey AS "custkey", o_orderstatus AS "orderstatus", o_totalprice AS "totalprice", o_orderdate AS "orderdate", o_orderpriority AS "orderpriority", o_clerk AS "clerk", o_shippriority AS "shippriority", o_comment AS "ps_comment"),
    (SELECT XMLAGG(XMLELEMENT (
    "lineitem",
    XMLATTRIBUTES ( l_orderkey AS "orderkey", l_partkey AS "partkey", l_suppkey AS "suppkey", l_linenumber AS "linenumber", l_quantity AS "quantity", l_extendedprice AS "extendedprice", l_discount AS "discount", l_tax AS "tax", l_returnflag AS "returnflag", l_linestatus AS "linestatus", l_shipdate AS "shipdate", l_commitdate AS "commitdate", l_receiptdate AS "receiptdate", l_shipinstruct AS "shipinstruct", l_shipmode AS "shipmode", l_comment AS "comment")
    FROM LINEITEM l
    WHERE l.l_orderkey = o.o_orderkey
    FROM ORDERS o
    WHERE o.o_custkey = c.c_custkey
         FROM CUSTOMER c
    WHERE c.c_nationkey = n.n_nationkey
    FROM NATION n
    WHERE n.n_regionkey = r.r_regionkey
    FROM REGION r;

    Tim,
    Oracle Reports was the orginal way to do this in an Oracle Apps environment. However, the XML Publisher team built a tool called data templates to do this as well. You can read several articles on how to use data templates on the XMLP blog. Here's the first arcticle in a series: http://blogs.oracle.com/xmlpublisher/2006/11/08#a127.
    Bryan

  • Generate XML from a table

    Hi all,
    I have to generate an xml as given in the below format:
    There are 5 subjects.
    Rules to frame the xml:
    1) Whether students have opted for each subjects empty tags should be present , for eg: subCodeOne
    2) If there are duplicates in studid it has to be removed for each subject code.
    3) <subCodeOneStud> -- student details about subject code 1
    <studId> --- students name without duplicates
    <subCodeOnemarks> --- student marks for subject code1
    <subCodeOnePass> -- If atleast one student has passed in that subject this has to be set to Y
    In case of scenarios like 1 it should be N
    FORMAT:
    =======
            <subCodeOneStud>
              <StudId></StudId>
         </subCodeOneStud>
         <subCodeOnemarks>
              <marks></marks>
         </subCodeOnemarks>
         <subCodeOnePass>N</subCodeOnePass>
         <subCodeTwoStud>
              <StudId>531</StudId>
         </subCodeTwoStud>
         <subCodeTwomarks>
              <marks>9414</marks>
         </subCodeTwomarks>
         <subCodeTwoPass>N</subCodeTwoPass>
         <subCodeThreeStud>
              <StudId>531</StudId>
         </subCodeThreeStud>
         <subCodeThreemarks>
              <marks>8450</marks>
              <marks>0634</marks>
         </subCodeThreemarks>
         <subCodeThreePass>N</subCodeThreePass>
         <subCodeFourStud>
              <StudId>1757</StudId>
         </subCodeFourStud>
         <subCodeFourmarks>
              <marks>0405</marks>
         </subCodeFourmarks>
         <subCodeFourPass>N</subCodeFourPass>
         <subCodeFiveStud>
              <StudId>1757</StudId>
         </subCodeFiveStud>
         <subCodeFivemarks>
              <marks>0412</marks>
         </subCodeFivemarks>
         <subCodeFivePass>N</subCodeFivePass>
    SELECT
    sub_i,/*to remove duplicate studnames */
    extract(
    deleteXML(
    xmlelement("root", xmlparse(content stud_ids))
    , '/root/studId[preceding-sibling::studId=.]'
    , '/root/studId'
    ) students,
    marks,
    pass_flag,
    ,sub_i_w
    FROM
    SELECT
    sub_i,sub_i_w,
    '<studId>'||LTRIM(MAX(sys_connect_by_path(stud_name,'</studId><studId>')),'</studId><studId>')||'</studId>' stud_ids,
    '<marks>'||LTRIM(MAX(sys_connect_by_path(marks,'</marks><marks>')),'</marks><marks>')||'</marks>' marks,
    DECODE(MAX(pass_f),1,'Y','N') pass_flag
    FROM
    (SELECT
    sub_i,sub_i_w,
    stud_name,
    marks,
    pass_f,
    ROW_NUMBER() OVER(PARTITION BY PSN_ID ORDER BY sub_i ) RN
    FROM
    SELECT
    LEVEL sub_i,
    REPLACE(REPLACE(INITCAP(to_char(to_date(LEVEL,'J'), 'JSP')),' ',''),'-','')  sub_i_w /*subject id in words for the outer most tag */
    FROM
    DUAL
    CONNECT
    LEVEL <= 5
    )A
    LEFT OUTER JOIN
    (SELECT sub_i,
    stud_name,
    marks,
    decode(result,'Y',1,0) pass_f,
    FROM
    marklist
    )B
    ON (A.sub_i=B.sub_i)
    START WITH RN = 1
    CONNECT BY PRIOR RN = RN - 1 AND PRIOR sub_i = sub_i
    GROUP BY sub_i,sub_i_w
    )Doubts:
    ========     
    1) I am using the above query to generate studId and marks tag for all the five subjects
    I am getting an error: "ORA-01854:julian date must be between 1 and 5373484"
    Can any one help me in resolving this?
    2) To get the final xml i may have to add the below select query to the above query. But this kind of concatenation to get the tag , throws an error: right parenthesis
    SELECT
    REPLACE(
    REPLACE(
    XMLAGG(
    XMLELEMENT("subCode"||sub_i||"Stud",students),
    XMLELEMENT("subCode"||sub_i||"marks",marks),
    )).getStringVal(),'&&lt;','<'),'&&gt;','>')
    FROM3) Is this way of writing a query to generate the xml is effiecient .I am using oracle 10g
    Thanks in advance
    Edited by: BluShadow on 17-Oct-2011 08:09
    added {noformat}{noformat} tags for formatting.  Please read {message:id=9360002} and learn to do this yourself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Java application expects the tags to be like this :(I see...
    Don't forget to format what you post here as BluShadow kindly did for you earlier.
    Apart from the obvious readability reasons, that's particularly important for XML or HTML code because the forum software here might interpret some tags and not render them correctly.
    Thanks for the sample data anyway.
    This should get you going :
    with subjects as (
      select level as sub_id
           , initcap(to_char(to_date(level,'J'), 'JSP')) as sub_id_sp
      from dual
      connect by level <= 5
    select xmlagg(
             xmlconcat(
               xmlelement(evalname('subCode'||sub_id_sp||'Stud'),
                 xmlagg( case when rn = 1 then xmlelement("StudId", stud_name) end )
             , xmlelement(evalname('subCode'||sub_id_sp||'marks'),
                 xmlagg( xmlelement("marks", marks) )
             , xmlelement(evalname('subCode'||sub_id_sp||'Pass'),
                 nvl(max(case when pass_f = 'Y' then pass_f end), 'N')
           ).extract('/*') -- to "pretty-print" the result (not mandatory)
           as result
    from (
      select s.sub_id
           , s.sub_id_sp
           , m.stud_name
           , m.marks
           , m.pass_f
           , row_number() over(partition by s.sub_id, m.stud_name order by null) rn
      from subjects s
           left outer join marklist m on m.sub_id = s.sub_id
    group by sub_id, sub_id_sp
    RESULT
    <subCodeOneStud>
      <StudId/>
    </subCodeOneStud>
    <subCodeOnemarks>
      <marks/>
    </subCodeOnemarks>
    <subCodeOnePass>N</subCodeOnePass>
    <subCodeTwoStud>
      <StudId>raj</StudId>
      <StudId>rosy</StudId>
    </subCodeTwoStud>
    <subCodeTwomarks>
      <marks>20</marks>
      <marks>80</marks>
    </subCodeTwomarks>
    <subCodeTwoPass>Y</subCodeTwoPass>
    <subCodeThreeStud>
      <StudId/>
    </subCodeThreeStud>
    <subCodeThreemarks>
      <marks/>
    </subCodeThreemarks>
    <subCodeThreePass>N</subCodeThreePass>
    <subCodeFourStud>
      <StudId>jaya</StudId>
      <StudId>padma</StudId>
      <StudId>rosy</StudId>
    </subCodeFourStud>
    <subCodeFourmarks>
      <marks>100</marks>
      <marks>40</marks>
      <marks>30</marks>
      <marks>80</marks>
    </subCodeFourmarks>
    <subCodeFourPass>Y</subCodeFourPass>
    <subCodeFiveStud>
      <StudId>jai</StudId>
      <StudId>padma</StudId>
    </subCodeFiveStud>
    <subCodeFivemarks>
      <marks>100</marks>
      <marks>90</marks>
    </subCodeFivemarks>
    <subCodeFivePass>Y</subCodeFivePass>

  • Generating XML from XSD

    Hi,
    I'm not sure it's possible to do what I want, but can anyone confirm / deny this:
    I have a series of XSDs that I can load into the database. I want to be able to generate XML that conforms to the XSD, by passing in a series of variables - the values that I want to substitute in the XML are not held in the database, but are all calculated in PL/SQL.
    A snippet from the XML is:
    <Name>
      <PersonDescriptives:PersonNameTitle/>
      <PersonDescriptives:PersonGivenName/>
      <PersonDescriptives:PersonFamilyName/>
    </Name>I want to be able to pass in variables to supply the values in the XML, and generate it from the XSD. Is this possible?
    My gut feeling (and initial quick analysis) says that it's not - the option I've come up with so far is simple string manipulation and then I could validate the XML against the XSD to ensure that it's valid, but then I have the issue of what to do if it isn't valid!
    Any thoughts gratefully received,
    Matt
    Edited by: Darryl Burke -- advertisement and links removed

    Thanks Mark.
    I've look at the examples etc already, but they all seem to only cater for selecting from a database table. Since all my values are in PL/SQL variables rather than being in tables, I guess I could select from DUAL the whole time, but the performance of having to do it that way rather than just concatenating text together doesn't seem to make it worthwhile.
    Think I'll just stick with using string manipulation to create the XML.
    Matt

  • Generating XML from Oracle DB

    While generating XML data from Oracle relational database, using the following SQL statement,
    SELECT XMLElement("Date", VioDate)
    FROM TableName
    WHERE VioId= 10;
    I am getting the result as :
    [][][][]<Date>2010-03-22</Date>
    There four small squares coming before the xml element.
    Can anyone let me know why I am getting this and how to correct it.
    I am using Oracle SQL Developer version 1.2.1 Build MAIN - 32.13 to run the above statement.
    Regards

    Hi,
    Probably an issue about how the client "implicitly" converts an XMLType to display its lob content.
    You may use getStringVal() or getClobVal() methods to get the content :
    SQL*Plus: Release 10.1.0.4.2 - Production on Lun. Mars 29 16:28:39 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connecté à :
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select xmlelement("TEST", 'ABC') from dual;
    XMLELEMENT("TEST",'ABC')
    SQL> select xmlelement("TEST", 'ABC').getclobval() from dual;
    XMLELEMENT("TEST",'ABC').GETCLOBVAL()
    <TEST>ABC</TEST>HTH

Maybe you are looking for