Generate XML based on MySQL Query

Hello guys,
I need to create a XML file like this one(same structure) but based on MySQL query:
<chart>
   <chart_type>pie</chart_type>
   <chart_data>
      <row>
         <null/>
         <string>2007</string>
         <string>2008</string>
         <string>2009</string>
      </row>
      <row>
         <string>Region A</string>
         <number>10</number>
         <number>30</number>
         <number>63</number>
      </row>
   </chart_data>
</chart>
I found a couple of good articles but I do not know how to get the same structure, I tried this:
<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "test";
$pass = "test";
$database = "test";
$enlace = mysql_connect($host, $user, $pass) or die("Error MySQL.");
mysql_select_db($database, $enlace) or die("Error base de datos.");
$query = "SELECT AGENTE, count(*) FROM clientes group by agente";
$resultado = mysql_query($query, $enlace) or die("Sin resultados.");
$salida_xml = "<?xml version=\"1.0\"?>\n";
$salida_xml .= "<chart>\n";
$salida_xml .= "<chart_type>" . 'pie' . "</chart_type>\n";
    $salida_xml .= "<chart_data>\n";
    for($x = 0 ; $x < mysql_num_rows($resultado) ; $x++){
        $fila = mysql_fetch_assoc($resultado);
        $salida_xml .= "\t<row>\n";
        $salida_xml .= "\t\t<agente>" . $fila['AGENTE'] . "</agente>\n";
        $salida_xml .= "\t\t<cantidad>" . $fila['count(*)'] . "</cantidad>\n";
            // Corregiendo caracteres incorrectos
            $fila['texto'] = str_replace("&", "&amp;", $fila['texto']);
            $fila['texto'] = str_replace("<", "&lt;", $fila['texto']);
            $fila['texto'] = str_replace(">", "&gt;", $fila['texto']);
           // $salida_xml .= "\t\t<texto>" . $fila['texto'] . "</texto>\n";
        $salida_xml .= "\t</row>\n";
    }//segundo for
    $salida_xml .= "</chart_data>\n";
$salida_xml .= "</chart>";
echo $salida_xml;
but I'm not getting the same structure, I am getting this:
<chart>
<chart_type>pie</chart_type>

<chart_data>
<row>
    </row>

<row>
<agente>Danilo</agente>
<cantidad>8</cantidad>
</row>
<row>
    </row>

<row>
<agente>Evelyn</agente>
<cantidad>5</cantidad>
</row>
<row>
    </row>

<row>
<agente>Maribel</agente>
<cantidad>2</cantidad>
</row>
<row>
    </row>

<row>
<agente>Nestor</agente>
<cantidad>11</cantidad>
</row>
<row>
    </row>

<row>
<agente>Noemy</agente>
<cantidad>2</cantidad>
</row>
</chart_data>
</chart>
Can someone give me a hand plase?
Thanks in advance

Doing some extra research I almost get to the result that I need, I guess I am jus
t having an small problem.
Basically I need this
[PHP]
<chart>
   <chart_type>pie</chart_type>
   <chart_data>
      <row>
         <null/>
         <string>2007</string>
         <string>2008</string>
         <string>2009</string>
      </row>
      <row>
         <string>Region A</string>
         <number>10</number>
         <number>30</number>
         <number>63</number>
      </row>
   </chart_data>
</chart>
[/PHP]
Currently I have this:
[PHP]
<chart>
    <chart_type>pie</chart_type>
    <chart_data>
        <row>
            <null></null>
            <agente>Danilo</agente>
            <agente>Evelyn</agente>
            <agente>Maribel</agente>
            <agente>Nestor</agente>
            <agente>Noemy</agente>
        </row>
        <row>
            <rutas>rutas</rutas>
            <cantidad></cantidad>
            <cantidad></cantidad>
            <cantidad></cantidad>
            <cantidad></cantidad>
            <cantidad></cantidad>
        </row>
    </chart_data>
</chart>
[/PHP]
And I am using this code
[PHP]<?php
header("Content-type: text/xml");
$host = "xxx";
$user = "xxxx";
$pass = "xxxx";
$database = "xxxx";
$enlace = mysql_connect($host, $user, $pass) or die("Error MySQL.");
mysql_select_db($database, $enlace) or die("Error base de datos.");
$query = "SELECT AGENTE, count(*) FROM clientes WHERE PREVENTA LIKE 'Viernes' group by agente";
$resultado = mysql_query($query, $enlace) or die("Sin resultados.");
$salida_xml = "<?xml version=\"1.0\"?>\n";
$salida_xml .= "<chart>\n";
$salida_xml .= "\t<chart_type>" . 'pie' . "</chart_type>\n\n";
$salida_xml .= "\t<chart_data>\n";
            $salida_xml .= "\t\t<row>\n";
            $salida_xml .= "\t\t\t<null>" . $fila5['NULL']. "</null>\n";
            for($y = 0 ; $y < mysql_num_rows($resultado) ; $y++){
                $fila2 = mysql_fetch_assoc($resultado); 
                $salida_xml .= "\t\t\t<agente>" . $fila2['AGENTE'] . "</agente>\n";
                }//cierro for Y
            $salida_xml .= "\t\t</row>\n";
            $salida_xml .= "\t\t<row>\n";    
            $salida_xml .= "\t\t\t<rutas>" . 'rutas'. "</rutas>\n";
            for($z = 0 ; $z < mysql_num_rows($resultado) ; $z++){
                $valor = mysql_fetch_assoc($resultado);
                $salida_xml .= "\t\t\t<cantidad>" . $valor['count(*)'] . "</cantidad>\n";
            }//cierro for z
            $salida_xml .= "\t\t</row>\n";
    $salida_xml .= "\t</chart_data>\n";
$salida_xml .= "</chart>";
echo $salida_xml;
?>[/PHP]
The issue I am having is that it is not showing the quantity, in this case "cantidad", does someone know why?

Similar Messages

  • Need to generate XML based on Data template

    Hi,
    I'm unable to submit (the second submit) my request using the demo links (XDO 5.6.3 or XDO 5.7) provided in http://bipublisher.us.oracle.com/?tab=samples&header=dataTemplate to generate the XML based on the data template.
    Heard that these links are available for Oracle EBS internal use. I work with EBS-CRM. I need to generate XML based on a data template and use the XML in the template. Data template has two queries for a template.
    Pls help.
    Thanks,
    Impha

    Impha
    Please use the internal mailing list for your questions the forum is meant for external customers. If you do not know the ML name - drop me a mail
    Tim

  • Namespace issue while generating XML based on xsd

    Hi All,
    I am using Jdeveloper-11.1.1.6
    SOA:- 11.1.1.6
    WLS:- 11.3.6
    When i am publishing xml message i am getting name space issue.
    My process design as i am getting a message from AQ JMS and doing a transformation with out any logic and writing into a file based on the xsd.
    Here is the my target xsd structure
    <xs:schema id="RelieveIntransitSchema"
    targetNamespace="http://tempuri.org/RelieveIntransitSchema.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/RelieveIntransitSchema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="RelieveIntransits">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="RelieveIntransit" minOccurs="1" maxOccurs="unbounded">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="RelieveStore" minOccurs="1" maxOccurs="unbounded">
    <xs:complexType>
    <xs:sequence></xs:sequence>
    <xs:attribute name="StoreID" type="xs:string"/>
    <xs:attribute name="Units" type="xs:double"/>
    <xs:attribute name="RelieveAllStores" type="xs:boolean"/>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    <xs:attribute name="HeaderID" type="xs:string" use="optional"/>
    <xs:attribute name="ProductID" type="xs:string" use="required"/>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    My actual target xml should be of
    <?xml version="1.0"?>
    <RelieveIntransits xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/RelieveIntransitSchema.xsd">
    <RelieveIntransit HeaderID="DA41198901491301" ProductID="D037-63-1270S">
    <RelieveStore StoreID="D001" Units="0002092 " />
    <RelieveStore StoreID="D003" Units="0000022 " />
    </RelieveIntransit>
    </RelieveIntransits>
    But the out xml generating as below which is not accepted by target system
    <?xml version="1.0" encoding="UTF-8"?>
    <RelieveIntransits xmlns="http://tempuri.org/RelieveIntransitSchema.xsd" xmlns:ns5="http://tempuri.org/RelieveIntransitSchema.xsd"> <ns5:RelieveIntransit ProductID="6534562" HeaderID="10R7771-6534562001-109"> <ns5:RelieveStore Units="5" StoreID="118"/>
    <ns5:RelieveStore Units="5" StoreID="118"/>
    </ns5:RelieveIntransit>
    </RelieveIntransits>
    Could some one please help me how to generate actual one as shown above with out namespace prefix "ns". I tried xsl code for removing name space prefix using https://forums.oracle.com/forums/thread.jspa?threadID=1122673 but it is removing url also.
    Regards,
    Tarak
    Edited by: Tarak on Jul 26, 2012 11:39 AM

    Hi,
    Sorry for my delay response.
    Both xmls are valid and equivalent for me... should be equivalent to <ns1:a xmlns:ns1="namespace"/>...
    I agree to your point.
    What is your target system? If that makes difference for your target system I would say it is not fully XML compliant...
    Target system is an old one called as MID. Yes i agree it is not fully XML Compliant. I am publishing the message through file adapter and it is reading the file.
    But anyway... The trick in the other thread should work... What do you mean by "removing url also" ???
    Using the Namespaces remove xsl code i am getting structure as below. In this alone with prefix name space url also getting removed.
    <RelieveIntransits>
    <RelieveIntransit HeaderID="DA41198901491301" ProductID="D037-63-1270S">
    <RelieveStore StoreID="D001" Units="0002092 " />
    </RelieveIntransit>
    </RelieveIntransits>
    I am expecting like this
    <?xml version="1.0"?>
    <RelieveIntransits xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/RelieveIntransitSchema.xsd">
    <RelieveIntransit HeaderID="DA41198901491301" ProductID="D037-63-1270S">
    <RelieveStore StoreID="D001" Units="0002092 " />
    </RelieveIntransit>
    </RelieveIntransits>

  • Generate xml based on folders & files

    I was wondering if it was possible for Coldfusion to generate
    an XML file based on the folders and files within those folders?
    Basically what I would like is to create a main folder that
    contains the Coldfusion file that when the user goes to the site,
    Coldfusion would look within it's folder for all sub-folders and
    files within and create and XML file that Flash would then consume.
    Is this possible? If so, I'd really appreciate it if someone could
    let me know where I could find more information this.
    Thanks in advance,
    shayne

    Use the cfdirectory tag to get your data and the cfxml tag to
    convert it into xml.

  • Generating XML based on XSD.

    HI All,
    I have an XSD and some data (in the form of value objects)that needs to be represented as XML . is thr any way to generate my XML dynamically using by data and reading the XSD content.
    Thanks
    -vijay

    Hi,
    If u want to create XML document according to the XSD you defined then u can use the JAXB API, here you do the Marshalling which directly converts the java objects into the XML document.
    Ref this link:-
    http://java.sun.com/xml/jaxb/users-guide/jaxb-using.html#sampapp3

  • Generate VCS based on CF query?

    I have some events I would like to generate a importable
    calendar file for
    (so I can allow users to import it into Outlook, etc).
    I found on the cflib.org site a UDF "vCal", but am unsure how
    to use it for
    more than 1 result.
    Does anyone have any experience with this?
    I've attached the code if that helps:
    <cfscript>
    * Produces output used by the vCalendar standard for PIM's
    (such as Outlook).
    * There are other tags available such as (CF_AdvancedEmail)
    that will support
    multi-part mime encoding where the text of the attachment can
    be imbeded
    right into the email
    * @param stEvent Structure containg the key/value pairs
    comprising the
    vCalendar data. Keys are shown below:
    * @param stEvent.description Description for the event.
    * @param stEvent.subject Subject of the event.
    * @param stEvent.location Location for the event.
    * @param stEvent.startTime Event's start time in GMT.
    * @param stEvent.endTime Event's end time in GMT.
    * @param stEvent.priority Numeric priority for the event
    (1,2,3).
    * @return Returns a string.
    * @author Chris Wigginton ([email protected])
    * @version 1.1, April 10, 2002
    function vCal(stEvent)
    var description = "";
    var vCal = "";
    var CRLF=chr(13)&chr(10);
    if (NOT IsDefined("stEvent.startTime"))
    stEvent.startTime = DateConvert('local2Utc', Now());
    if (NOT IsDefined("stEvent.endTime"))
    stEvent.endTime = DateConvert('local2Utc', Now());
    if (NOT IsDefined("stEvent.location"))
    stEvent.location = "N/A";
    if (NOT IsDefined("stEvent.subject"))
    stEvent.subject = "Auto vCalendar Generated";
    if (NOT IsDefined("stEvent.description"))
    stEvent.description = "Autobot VCalendar Generated";
    if (NOT IsDefined("stEvent.priority"))
    stEvent.priority = "1";
    vCal = "BEGIN:VCALENDAR" & CRLF;
    vCal = vCal & "PRODID:-//Microsoft
    Corporation//OutlookMIMEDIR//EN" &
    CRLF;
    vCal = vCal & "VERSION:1.0" & CRLF;
    vCal = vCal & "BEGIN:VEVENT" & CRLF;
    vCal = vCal & "DTSTART:" &
    DateFormat(stEvent.startTime,"yyyymmdd") & "T" &
    TimeFormat(stEvent.startTime, "HHmmss") & "Z" &
    CRLF;
    vCal = vCal & "DTEND:" & DateFormat(stEvent.endTime,
    "yyyymmdd") & "T" &
    TimeFormat(stEvent.endTime, "HHmmss") & "Z" & CRLF;
    vCal = vCal & "LOCATION:" & stEvent.location &
    CRLF;
    vCal = vCal & "SUMMARY;ENCODING=QUOTED-PRINTABLE:" &
    stEvent.subject
    & CRLF;
    vCal = vCal & "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:";
    // Convert CF_CRLF (13_10) into =0D=0A with CR/LF and indent
    sequences
    description =
    REReplace(stEvent.description,"[#Chr(13)##Chr(10)#]",
    "=0D=0A=#Chr(13)##Chr(10)#
    ", "ALL");
    vCal = vCal & description & CRLF;
    vCal = vCal & "PRIORITY:" & stEvent.priority &
    CRLF;
    vCal = vCal & "END:VEVENT" & CRLF;
    vCal = vCal & "END:VCALENDAR" & CRLF;
    return vCal;
    </cfscript>

    I have some events I would like to generate a importable
    calendar file for
    (so I can allow users to import it into Outlook, etc).
    I found on the cflib.org site a UDF "vCal", but am unsure how
    to use it for
    more than 1 result.
    Does anyone have any experience with this?
    I've attached the code if that helps:
    <cfscript>
    * Produces output used by the vCalendar standard for PIM's
    (such as Outlook).
    * There are other tags available such as (CF_AdvancedEmail)
    that will support
    multi-part mime encoding where the text of the attachment can
    be imbeded
    right into the email
    * @param stEvent Structure containg the key/value pairs
    comprising the
    vCalendar data. Keys are shown below:
    * @param stEvent.description Description for the event.
    * @param stEvent.subject Subject of the event.
    * @param stEvent.location Location for the event.
    * @param stEvent.startTime Event's start time in GMT.
    * @param stEvent.endTime Event's end time in GMT.
    * @param stEvent.priority Numeric priority for the event
    (1,2,3).
    * @return Returns a string.
    * @author Chris Wigginton ([email protected])
    * @version 1.1, April 10, 2002
    function vCal(stEvent)
    var description = "";
    var vCal = "";
    var CRLF=chr(13)&chr(10);
    if (NOT IsDefined("stEvent.startTime"))
    stEvent.startTime = DateConvert('local2Utc', Now());
    if (NOT IsDefined("stEvent.endTime"))
    stEvent.endTime = DateConvert('local2Utc', Now());
    if (NOT IsDefined("stEvent.location"))
    stEvent.location = "N/A";
    if (NOT IsDefined("stEvent.subject"))
    stEvent.subject = "Auto vCalendar Generated";
    if (NOT IsDefined("stEvent.description"))
    stEvent.description = "Autobot VCalendar Generated";
    if (NOT IsDefined("stEvent.priority"))
    stEvent.priority = "1";
    vCal = "BEGIN:VCALENDAR" & CRLF;
    vCal = vCal & "PRODID:-//Microsoft
    Corporation//OutlookMIMEDIR//EN" &
    CRLF;
    vCal = vCal & "VERSION:1.0" & CRLF;
    vCal = vCal & "BEGIN:VEVENT" & CRLF;
    vCal = vCal & "DTSTART:" &
    DateFormat(stEvent.startTime,"yyyymmdd") & "T" &
    TimeFormat(stEvent.startTime, "HHmmss") & "Z" &
    CRLF;
    vCal = vCal & "DTEND:" & DateFormat(stEvent.endTime,
    "yyyymmdd") & "T" &
    TimeFormat(stEvent.endTime, "HHmmss") & "Z" & CRLF;
    vCal = vCal & "LOCATION:" & stEvent.location &
    CRLF;
    vCal = vCal & "SUMMARY;ENCODING=QUOTED-PRINTABLE:" &
    stEvent.subject
    & CRLF;
    vCal = vCal & "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:";
    // Convert CF_CRLF (13_10) into =0D=0A with CR/LF and indent
    sequences
    description =
    REReplace(stEvent.description,"[#Chr(13)##Chr(10)#]",
    "=0D=0A=#Chr(13)##Chr(10)#
    ", "ALL");
    vCal = vCal & description & CRLF;
    vCal = vCal & "PRIORITY:" & stEvent.priority &
    CRLF;
    vCal = vCal & "END:VEVENT" & CRLF;
    vCal = vCal & "END:VCALENDAR" & CRLF;
    return vCal;
    </cfscript>

  • Generating XML for query resultset

    hi,
    how to generate xml file for a query,,in sql server we use:
    select * from emp
    for auto xml do;
    it generates xml file for the result set of this query,,how to do it in oracle??
    regards
    umar

    Use dbms_xmlgen.getxml.
    Tom kyte has some good stuff at his site.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:4444542233908715904::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:16020931845088,

  • HELP in Generating XML(PLz help its urgent)

    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.

    Maybe I am wrong, but my understanding is that you have to generate the xml from your data source (usually tables) and then you validate it against your schema. I don't know if the schema has a magic that can generate the xml for you. Is that correct? Anyone please? At the beginning, I asked a .Net guy if his tool could "generate" an xml simply using the schema (I thought so). But he said they had to use many style sheets to create the xml.
    Ben

  • 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.

  • Most effecient way to generate XML output

    What is the most effecient way to generate XML output using ORACLE.
    Presently I am aware of the following:
    1)DBMS_XMLQUERY
    2)DBMS_XMLGEN
    3)SQLX functions
    We are using the first 2 in our database to generate hierarchical XML. Once the XML is generated the XML file is ftp'd to a UNIX box. Because of the file size restrictions in our UNIX bix we decided not to transform the XML output into XML Attributes.
    The attributes are assigned from an XSLT file and the raw XML file is transformed to a file which has attributes.
    My question is:
    In the Oracle Database release 9.2 is there a better efficient way to genarate the final XML file with Attributes from the database side without using the XSLT. If yes, please give an example how to do this?
    Thank You

    In general the SQL/XML publishing functions are the most efficient way..
    DBMS_XMLQUERY is a legacy technology imlimented in Java. The main advantage is that it can be run outside the database in the mid-tier is required.
    DBMS_XMLGEN is a re-implementation of DBMS_XMLQUERY in 'C' which runs inside the database. In most cases it should be much faster than DBMS_XMLQUERY. It provides some features that are still not availalble in the SQL/XML standard such as the ability to generate XML based on a cursor, and the ability to generate recursive output from a connect by query. It is hoped that future versions of the SQL/XML publishing functions will address these issues.
    Both DBMS_XMLGEN and DBMS_XMLQUERY are somewhat limited in terms of generating complex XML documents with multiple levels of nesting.
    The SQL/XML publishing functions are the preferred way of generating XML from relational data. THey provide the ability to generate extremely complex XML structures from relation data and provide full control over element / attributes names, levels of nested etc. Future development projects will focus on enhancing the performance and functionality of the SQL/XML publishing functions rather than the PL/SQL packages
    In general if you can use SQL/XML publishing functions you should do so.
    Does this help....

  • Xml output of a query

    Hi,
    I want to generate xml output of a query.
    ( suppose if i write select * from tab1 ; then i want all the rows from the table tab1 in xml form )
    how to do it.. ?
    plz guide.

    I guess what you are loooking for is this
    select xmltype(cursor(select * from dept)).getclobval() from dual;
    this will give you the outout in a txt viewable format.
    Rushi

  • 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

  • Generating report based on dynamically generated sql query

    I have to rewrite asp reports to oracle reports.
    The original application has forms in asp where reports are generated dynamically based on the options selected.
    There are many options to select.
    Some add filter criteria to where clause.
    I have no problem with this. As i can generate report using parameter form.
    whereas i don't know how to generate reports whose columns change based on the user selection.
    The front end screens are going to be in java and jsp pages. The only way i can think of is generating reports on all possible options the user may select. But, as there are more than 15 options, i think this is not the right approach.
    How can i achieve this.
    Thank you very much.
    navya.

    One method that comes to mind would be to use an after parameter form, and use lexical parameters to create dynamic statements.
    For example in your after pform:
    If :P_NAME = 'JOHN' then
    :P_SELECT = 'SELECT COL1, COL2 ';
    :P_FROM = 'FROM JOHN ';
    :P_WHERE = 'WHERE COL3 = 'JOHN';
    END IF;
    Then in your query, you could say:
    &P_SELECT
    &P_FROM
    &P_WHERE
    Something like that - If only parts of you where statement will change, you can just write that one part -
    like
    IF :P_STATE is not null then
    :P_STATE = ' and table.state = :P_STATE_IN ';
    else :P_STATE = ' and 1=1 ';
    end if;
    and in your query...
    where....
    &:P_STATE
    So IF a person enters a state, then limit the search to that state, or else do a 1=1.
    Hope this gives you a start

  • Generate xml form retrieved query...

    HI,
    To start with am working to generate xml programatically for the first time ,I'd appreciate if anybody could help me out on the following...
    I have some records in the database and am supposed to generate an xml file from the retrieved query and store the xml in a specific location.
    iam using DOM parser to write the xml file.
    Please let me know as of what is the classpath that i should set and what i need to compile my class
    How can i generate the required xml file.
    Thanks in advance...
    Great day ahead....

    hi thans for the code and after writing the folloing code am getting the erros as
    I had set my classpath to Jdom.jar and compiled and got this error...can u let me know the classpath that i have to set????
    i think it is the problem with only classpath( if am thinking right)......
    location: class com.Fortune.adminusers.AdminUsers
    Element root = new Element("top");
    ^
    src\Admin\AdminUsers.java:48: cannot resolve symbol
    symbol : class Element
    location: class com.Fortune.adminusers.AdminUsers
    Element root = new Element("top");
    ^
    src\Admin\AdminUsers.java:53: cannot resolve symbol
    symbol : class Element
    location: class com.Fortune.adminusers.AdminUsers
    Element next = new Element("next");
    ^
    src\Admin\AdminUsers.java:53: cannot resolve symbol
    symbol : class Element
    location: class com.Fortune.adminusers.AdminUsers
    Element next = new Element("next");
    ^
    src\Admin\AdminUsers.java:56: cannot resolve symbol
    symbol : variable Format
    location: class com.Fortune.adminusers.AdminUsers
    XMLOutputter writer = new XMLOutputter(Format.getPrettyFormat());
    ^
    ------------------------Code Sample-----------------------------------------------
    import java.sql.*;
    import <app packages>
    import org.jdom.Document;
    import org.jdom.JDOMException;
    import org.jdom.input.DOMBuilder;
    import org.jdom.output.XMLOutputter;
    public class <XXXXXXX>
    private DBC dbConnector = null;
    public Users getUsers(String loginid)
              Users user = null;
              ResultSet rs_users=null;
              Statement get_users=null;
              Connection conn=null;
                   try
                        String query_select_user = "";
                        query_select_user = <Database Query>
                        conn = dbConnector.getConnection();
                        get_users = conn.createStatement();
                        rs_users = get_users.executeQuery(query_select_user);
                        if((rs_users != null) && (rs_users.next()))
                             do
                                  user = new Users();
                                  user.setMainMod(rs_users.getString("MainModuleId"));
                                  user.setModDesc(rs_users.getString("ModuleDesc"));
                                  String top = user.getMainMod();
                                  Element root = new Element("top");
                                  root.setText(top);
                                  String child = user.getModDesc();
                                  System.out.println(top);
                                  System.out.println(child);
                                  Element next = new Element("next");
                                  next.setText(child);
                                  Document doc = new Document(root);
                                  XMLOutputter writer = new XMLOutputter(Format.getPrettyFormat());
                                  OutputStream out = new FileOutputStream("1.xml");
                                  writer.output(doc, out);
                                  writer.output(doc, System.out);
                             }while(rs_users.next());
                   }catch (Exception e) {e.printStackTrace();}
                        finally
                             try
                                  if ( rs_users != null)
                                  rs_users.close();
                                  if(get_users!=null)
                                  get_users.close();
                                  if(conn!=null)
                                  conn.close();
                             }catch (SQLException se){}
         return user;
    }

  • How to generate XML file based on XSD in SSIS

    please provide step by step process to create xml based on XSD in SSIS  

    Hi hemasankar,
    In SQL Server Integrated Services, we can generate XML Schema (XSD) file based on a XML file with XML Source Editor. If we want to generate XML file based on a XSD file, we can use Generate Sample XML feature in Visual Studio. For more details, please refer
    to the following steps:
    Click on "XML Schema Explorer" or 'Use the XML Schema Explorer...' to open XML Schema Explorer in Visual Studio. 
    If your Schema file is valid and you are having elements, right-click on element and click on "Generate Sample XML", this functionality generates XML file in temp folder and open ups in the XML Editor.
    The following two document about how to generate XML file based on a XSD file are for your reference:
    http://msdn.microsoft.com/en-us/library/dd489258.aspx
    http://www.codeproject.com/Articles/400016/Generate-Sample-XML-from-XSD
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for

  • When InDesign becomes .pdf,...

    ...does the document shrink on the .pdf?  (I've already asked this at the Adobe Acrobat forum and they said it was the wrong place.) I have some drawings with rulers on them in a book I'm writing, and they HAVE to come out at size.  Some time ago whe

  • Database mapping to XML

    Hi all... I have 6 tables in an Oracle DB that I want to export to XML. 4 of these tables have relationships (primary key - foreign key). As a result, I want to have all related objects mapped as child elements of their respective parent. So the resu

  • How to seperate PC SCREEN pages from MOBILE pages?

    I read in a Microsoft MSDN article recently where it is a good idea to have the main landing page as index.html and detect if the browser is using a mobile and instead load a different version just for mobiles. I was wondering how I would implement s

  • Can I use ios7 on ipad2?

    Can I load ios7 onto my ipad2?  When I click on software update I get a message that I need 2.9 GB available space but the iPad itself tells me that I have over 5 GB available. Thanks for any information.

  • How to see the all batch jobs runnning in production server

    Dear All, Can any one tell me ; where can i see the all the batch jobs that have been scheduled in production. I need to see all the batch jobs. Please help me Rgds, Rao