Query resultset to xml using java and XML schema

Hi,
I query data using JDBC and I want to store it to an XML file which has a well defined XML schema. I searched a lot in the forum but did not find an answer. Please guide me to create this program.
I have managed to use JDBC to get result set but I do not know how to export is to XML using XSD and Java.
Please help.
Regards,
Ravi

I have managed to use JDBC to get result set but I do
not know how to export is to XML using XSD and Java.Export using XSD? Schemas are for validation.
Iterate through the result set, and build up the XML stream by creating an entry for each row.
Another way to do it is to load the ResultSet into a Java object and serialize that to XML using something like XStream.
%

Similar Messages

  • Java and XML or XHTML Journey Planner Project

    Hello chaps,
    I need some help with a project I am doing.
    This project will be focusing on the area of information visualisation and the phenomena surrounding how data can be optimised in a confined space. Expanding on this, confined space can be a mobile phone screen, and personal organisers where information is shown in a limited area.
    I plan to use Java and XML. (or XHTML)
    I want to have a running application where raw data is transformed into a combination of graphics and information. To achieve this, I will be looking at route planning for mobile phones and how route instructions can be represented in a visual but a sophisticated way.
    My focus will be on the London transport.
    Here is a link to the London transport journey planner
    http://www.tfl.gov.uk/journeyplanner
    Using WAP, I surfed the website on my phone and there seems to be a lot of writing and there is a lot to process before understanding what is going on. I want to transform words into pictures e.g., the word underground or bus into a logo of a red bus or underground logo or Instead of ?walk?, a picture of a walking pedestrian. Picture are good connotations as we can easily recognise rather than processing words. I would also like to represent the time taken in a graph format, again, to easily visualise.
    The application can be on a phone or on Windows simulating a mobile phone.
    Can anyone help me with this mammoth task or at least point me out in the correct direction?
    Looking forward to your reply.

    1st, ) Raw Data e.g, journey time, journey distance
    2nd, ) I would want the system to recognise the 'raw data' mentioned before and transform this into graphical image(s).
    3rd ) a complete visualisation would look like,
    modes of transport represented by pics or logos, showing the time to get to from A to B.
    Showing various routes, eg, walking, and/or bus and/or tube

  • Read, Modify and Apply Report XML using Java Script

    Hi Guys,
    Is there any way that we can Pragmatically Read, Modify and Apply Report XML using Java Script or some other way.
    Thanks
    Kaushik
    Edited by: Kaushik K on Jun 20, 2012 8:36 PM

    Requirement ::
    Users should be able to add Column to the Report Dynamically at Runtime.
    (There are around 1000+ Users, Answers Approach is not acceptable)
    So we are planning to provide a Multi Select / Shuttle Box Option for Users to add Columns dynamically. (Only for Table View)
    What we planned to DO ::
    Create a Presentation Variable Prompt, Which reads the Metadata Table (Presentation Table.Column Name, populated using the Metadata Dictionary)
    And Create a report with One Column and the Column Fx like @{var_dynamic_columns}{'"Time"."Year","Time"."Month"'}
    With this, OBIEE is rewriting the Logical SQL Currently as "Select "Time"."Year","Time"."Month" from "A - Sample Sales" "
    But getting an error
    The number of columns returned in retrieving column metadata was invalid (expected: 1; received: 2)
    So we want to see, if we can rewrite the Advanced XML of the Report to have dynamic columns based on the Values from the Presentation Variable.
    Please help me if this is a viable solution or any other better solution.

  • Merge LiveCycle Form with XML using JAVA

    Hello.
    I am trying to find out how to merge non-interactive form with XML (using JAVA) so the users can see the final output form with the data filled in.
    What are my choices..?
    So far, I have created the interactive forms as template using LiveCycle 8 and wrote ASP.NET code to extract data and store it in SQL database when the user fill out and submit the form.
    It works great but another agency wants to access the form as well.
    They told us that they will create the XML themselves from the database, so they just need to combine the form with XML to display it (non-interactive form).
    They want to use JAVA but I am not sure how to do that...
    Any suggestion?

    Assuming that you start with XML in an org.w3c.dom.Document that stores the XML data. Before you can merge it into a form, you have to convert it to a com.adobe.idp.Document object. TO convert a org.w3c.dom.Document to a com.adobe.idp.Document object -- use the following Java code:
    private Document convertDataSource(org.w3c.dom.Document myDOM)
    byte[] mybytes = null;
    try
    //Create a Java Transformer object
    TransformerFactory transFact = TransformerFactory.newInstance();
    Transformer transForm = transFact.newTransformer();
    //Create a Java ByteArrayOutputStream object
    ByteArrayOutputStream myOutStream = new ByteArrayOutputStream();
    //Create a Java Source object
    javax.xml.transform.dom.DOMSource myInput = new DOMSource(myDOM);
    //Create a Java Result object
    javax.xml.transform.stream.StreamResult myOutput = new StreamResult(myOutStream);
    //Populate the Java ByteArrayOutputStream object
    transForm.transform(myInput,myOutput);
    // Get the size of the ByteArrayOutputStream buffer
    int myByteSize = myOutStream.size();
    //Allocate myByteSize to the byte array
    mybytes = new byte[myByteSize];
    //Copy the content to the byte array
    mybytes = myOutStream.toByteArray();
    catch (Exception e) {
    System.out.println("The following exception occurred: "+e.getMessage());
    //Create a com.adobe.idp.Document object and copy the
    //contents of the byte array
    Document myDocument = new Document(mybytes);
    return myDocument;
    THen you can merge myDocument into the Form using renderPDFFOrm:
    FormsResult formOut = formsClient.renderPDFForm(
    formName, //formQuery
    myDocument, //inDataDoc
    pdfFormRenderSpec, //PDFFormRenderSpec
    uriValues, //urlSpec
    fileAttachments //attachments
    Hope this helps!

  • Can somebody explain to me how java and xml are related?

    Hi guys
    im new to java and xml.Been reading a lot regarding java and don't seem to have a problem with it...
    the problem is the xml part...im doing a simple GUI project using swing(online store) and i have to convert it to xml
    I have absolutely NO IDEA why i must convert my java to xml and have no idea how to do that.I been reading on the net that xml is a exten~ markup language and it is better and useful.
    Can somebody explain to me in layman terms
    1)how is java and xml related in?
    2)why do ppl want to convert java to xml when they can just stick to java
    3)what is actually xml...
    4)Do i need a program to create xml like i need jcreater to create java application
    5)How do we actually convert?is there any links that you guys could tell me?
    thank you
    tomleo

    im new to java and xml.Been reading a lot regarding
    java and don't seem to have a problem with it...Okay.
    the problem is the xml part...im doing a simple GUI
    project using swing(online store) and i have to
    o convert it to xmlYou have to? So presumably somebody in a position of authority told you that?
    I have absolutely NO IDEA why i must convert my java
    to xml and have no idea how to do that.I been reading
    on the net that xml is a exten~ markup language and
    it is better and useful.I have no idea either (besides which, it doesn't make sense). But why ask us? Somebody told you to do that, ask them why.
    Sure, XML is useful. But it isn't a programming language so it can't be used as a substitute for Java.
    Can somebody explain to me in layman terms
    1)how is java and xml related in?They aren't related, except perhaps in that they are both used in computers.
    2)why do ppl want to convert java to xml when they
    can just stick to javaThey don't.
    3)what is actually xml...Start here for numerous definitions:
    http://www.google.ca/search?hl=en&lr=&oi=defmore&q=define:XML
    4)Do i need a program to create xml like i need
    jcreater to create java applicationNo, XML is just text. But then Java code is just text too.
    5)How do we actually convert?is there any links that
    you guys could tell me?You don't convert Java to XML. My guess is that because you don't know much about Java or XML, you have misinterpreted something that somebody told you.

  • Java and XML Doc

    I am new to Java and XML, I want to know the steps i should follow to work with XML document using XPATH. also the APIs and Technologies i shoud work. If possible guide me any examples or tutorials for that.

    This is the defacto site for xpath stuff for java
    http://xml.apache.org/xalan-j/

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

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

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

  • Java and xml option necessary?

    Hi,
    first when i build the repository database, i choose java and xml option, is this necessary or i waste my time.
    When i read Building a Help Desk Connector, i'm not sure, do i need the Diagnostic Pack.
    Best regards
    Thomas
    (Narri, Narro)

    This is the defacto site for xpath stuff for java
    http://xml.apache.org/xalan-j/

  • PMML Export using Java and ODM 10.2

    I'm attempting to export a model I've built in ODM using Java and the example code in dmexpimpdemo.java. I'm getting an error when trying to set an additional attribute to export the data as PMML.
    exportTask.setFormat(ImportExportFormat.PMML2_1);
    If I call this method (with any ImportExportFormat) I get the exception:
    javax.datamining.JDMUnsupportedFeatureException: Unsupported ExportTask for PMML2_1
    What is the proper way to export a model as PMML using the JAVA APIs?

    PMML Export is not supported by the ODM 10.2. Hence you see unsupported exception.
    ODM 10.2 supports only Oracle native format support for the mining model export and import. For more details about the usage refer to the demo program dmexpimpdemo.java.
    To download sample programs from OTN http://www.oracle.com/technology/products/bi/odm/samples/odm_sample_code_0805.zip
    For decision tree model you can export the model details in PMML format using the DBMS_DATA_MINING.get_model_details_xml. For example, the following query returns the PMML format decision tree model as an Oracle Database XMLType
    select dbms_data_mining.get_model_details_xml('TREE_MODEL').extract('/') AS DT_DETAILS FROM dual
    Regards
    Sunil

  • Sending udp packets using java and receiving it using c

    hi,
    Is it possible to send udp packets using java and receive the same using c??????? if yes.... plz help immediately.

    The biggest issue is data format. The JVM is big endian, with 16-bit characters. The machine running 'C' could be almost anything. A (signed!) byte array is probably the easiest unit of exchange.
    The Java program has its own techniques for storing/retrieving data to/from the byte array - and the C program has its own techniques. ASCII Strings are often the easiest to exchange - just convert the java String objects to byte array and send them.
    apaliwal1 has already given the UDP calls to send/receive the data.

  • Want To create Zip file  using java,And Unzip without Java Program

    I want to create a zip text file using java, I know Using ZipOutputStream , we can create a zip file, , But i want to open that zip file without java program. suppose i use ZipOutputStream , then zip file is created But for unZip also difftrent program require. We cant open that zip file without writing diff java program.
    Actually i have one text file of big size want to create zip file using java , and unzip simply without java program.Its Possible??
    Here is one answer But I want to open that file normal way(
    For Exp. using winzip we can create a zip file and also open simply)
    http://forum.java.sun.com/thread.jspa?threadID=5182691&tstart=0

    Thanks for your Reply,
    I m creating a zip file using this program, Zip file Created successfully But when im trying to open .zip file i m getting error like "Canot open a zip file, it does not appear to be valid Archive"
    import java.io.*;
    import java.util.zip.*;
    public class ZipFileCreation
         public static void main (String argv[])
         try {
         FileOutputStream fos = new FileOutputStream ( "c:/a.zip" );
         ZipOutputStream zip = new ZipOutputStream ( fos );
         zip.setLevel( 9 );
         zip.setMethod( ZipOutputStream.DEFLATED );
    //     get the element file we are going to add, using slashes in name.
         String elementName = "c:/kalpesh/GetSigRoleInfo092702828.txt";
         File elementFile = new File ( elementName );
    //     create the entry
         ZipEntry entry = new ZipEntry( elementName );
         entry.setTime( elementFile.lastModified() );
    //     read contents of file we are going to put in the zip
         int fileLength = (int)elementFile.length();
         System.out.println("fileLength = " +fileLength);
         FileInputStream fis = new FileInputStream ( elementFile );
         byte[] wholeFile = new byte [fileLength];
         int bytesRead = fis.read( wholeFile , 0 /* offset */ , fileLength );
    //     checking bytesRead not shown.
         fis.close();
    //     no need to setCRC, or setSize as they are computed automatically.
         zip.putNextEntry( entry );
    //     write the contents into the zip element
         zip.write( wholeFile , 0, fileLength );
         zip.closeEntry(); System.out.println("Completed");
    //     close the entire zip
         catch(Exception e) {
    e.printStackTrace();
    }

  • Difference between using Java and Non-Java in Webi.

    Hi ,
    I have one more question requesting for an answer.
    Would like to know what is the Difference between using Java and Non-Java in Webi.
    Thank You in advance.
    Appana Ganesh.

    Hi,
    check the Information in following post, the differences are discussed there:
    http://scn.sap.com/thread/3295306
    best regards,
    Victor

  • Store XML data as relational data into Oracle tables using Java and XMLType

    I want to store xml data into an Oracle 11g table as relational storage, not as CLOB or Binary storage. Then I should also be able to query and fetch this data from table into an XML file.
    Any hint on how to write java code using XMLType to achieve this?
    Any help would be appreciated.

    Thanks for the explanation. I still have few confusions. I will try to elaborate my requirement with a simple example...
    I have the following xsd and xml files. "note" would be the table in database and "to", "from", "heading" and "body" would be the columns of note table. "Tove", "Jan", "Reminder" and "Don't forget me this weekend!" would go as data in one row of note table.
    How do I create note table with the xml schema (xsd file)?
    Should the note table be of XMLType or the columns?
    How do I load the XML data into the columns of note table?
    How do I retrieve the row of note table as XML file?
    XML Schema:
    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.xxxxx.com"
    xmlns="http://www.xxxxx.com"
    elementFormDefault="qualified">
    <xs:element name="note">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="to" type="xs:string"/>
          <xs:element name="from" type="xs:string"/>
          <xs:element name="heading" type="xs:string"/>
          <xs:element name="body" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    XML Data:
    <?xml version="1.0"?>
    <note>
      <to>Tove</to>
      <from>Jan</from>
      <heading>Reminder</heading>
      <body>Don't forget me this weekend!</body>
    </note>

  • Java and XML Query

    Hi,No offence meant please for this query as this related to XML
    I am using a Java object to retreive an xml attribute
    The arttribute to retrieve is called scheme and is in an xml file with namespace
    <PaymentType scheme="UNCONFIRMED_TERMINATION_FEE" /> The Java code addresses this as:
    String xPathPaymentFee = EnvelopeCreator.GLOBAL_XML_NS_FOR_XPATH
              + "$this//cal:PaymentTypeI tried using the @ to extract the attribute value of scheme,but it doesnt work
    String xPathPaymentFee = EnvelopeCreator.GLOBAL_XML_NS_FOR_XPATH
              + "$this//cal:PaymentType@scheme;Any ideas how to extract the scheme value as cal is a namespace?
    Again no offence meant please

    Need more information about what "doesn't work" means.

  • How to write from database to XML file using JAVA and back..

    Hi....
    I am strugling for a code to write from database to xml output instead of what i have written in flat file....could anyone please help me out...to do this and again read the same back to the database using java...

    Hi,
    In java world, there is a tutorial on what you are looking for :
    http://www.javaworld.com/javaworld/jw-01-2000/jw-01-dbxml_p.html
    It uses SAX/DOM parsers to translate XML data into the appropriate fields of the database and visa-versa.
    Hope it helps.

Maybe you are looking for

  • Content Query Webpart For Slider

    I'm trying to create a simple jquery slider with the help of Content Query Webpart in sharepoint 2013. Can anyone help me on this with a simple video or example like how I can achieve this.

  • 'Send to Color' Problem

    I have just installed FinalCutStudio2 and am trying to use the File>send to color command, (on a sequence) It looks like it's working, color loads and goes to open BUT as soon as it opens it closes in the blink of an eye with no error message or cras

  • Can't import datebook or addresses from Palm

    Hi, I'm trying to migrate all my Palm addresses and datebook to iCal and Address book. When I go to export in Palm, for the datebook, my only export choices are: • tab & return • palm desktop • vCal vCard is greyed out. When I go to my new laptop and

  • Delta problem with datasource 2LIS_08TRTLP

    Hello everybody, I'm having a problem with the delta to datasource 2LIS_08TRTLP. I follow this tasks: 1 - I did a deletion of setup table data in transaction LBWG for application 08 and checked Shipment document and Shipment Costs. 2 - Transaction VT

  • What does this do - TestThis(hello)

    I was recently asked a ColdFusion question during a job interview. I was asked as to what this line of code does. <CFSET SomeVariable = TestThis(hello)> My first thought was that this creates a structure with "hello" as a key. But then I started to t