Creating an XML file with CFFILE on UNIX server

I've run into a problem with creating an XML file on a UNIX
server. I don't have access to the server and I'm trying to create
an XML file so an outside agency can read it through the site URL.
On a Windows machine I use GetDirectoryFromPath and
ExpandPath to return the drive/path info, then I create the file
with this and the query result. On the Unix web server I am only
being returned a relative path, because of this I can't write the
XML file to the web server. Any idea how to get around this?

Knowing as little as I do about Unix I thought you still needed
a drive "letter" to write the XML file to. I've been told I can get
to the root but that it's root is "/bottomFolderName" (I was
expecting R:\webRootPath\yourFolder\etc\XMLFileWrittenHere).
No, that is Windows thinking. You were told right. In Linux,
a path usually begins with the forward slash /.
I had doubts about your code itself. Did you run your version
of my example on Windows? If it works, then you will only have to
replace the Windows path with something like the following. The
rest of the code remains the same.

Similar Messages

  • Creating an XML file with CF

    I need to loop through a query to create an xml file. How do
    I create a file using CF? I thought maybe cffile but I don't see an
    attribute for "new", just things like append, delete, move etc...
    Am I missing something here? I've used cfheader to send content to
    the browser but just not sure how to create a file and place in on
    the server.
    Any help would be appreciated GREATLY!!!!

    See if this helps:
    http://tutorial97.easycfm.com/
    Ken Ford
    Adobe Community Expert - Dreamweaver
    Fordwebs, LLC
    http://www.fordwebs.com
    "cfcolorado" <[email protected]> wrote in
    message news:fe3poc$cvf$[email protected]..
    >I need to loop through a query to create an xml file. How
    do I create a file
    > using CF? I thought maybe cffile but I don't see an
    attribute for "new", just
    > things like append, delete, move etc... Am I missing
    something here? I've
    > used cfheader to send content to the browser but just
    not sure how to create a
    > file and place in on the server.
    >
    > Any help would be appreciated GREATLY!!!!
    >

  • Create XML file with worksheet's dynamically assigned through XSLT

    Hi all
    I have a requirement to create a xml file with worksheets dynamically created based on a field value in the internal table .
    I have all my values in internal table,  and am calling the transformation from bsp application.
    Say the internal table has field dataxyz, for every change in value in this field dataxyz  i need to create separate worksheet and populate that sheet with some corresponding values .
    please guide me how to create worksheet dynamically.
    thanks in advance.
    Bharathy
    Edited by: elam.bharathy on May 16, 2011 6:51 AM

    Can you use a schema when we compose XML doc from Database tables?
    Actually, I'm using SQL Server (sorry, wrong forum). But, I thought a Java tool would have a solution for me.

  • Create xml file with values from context

    Hi experts!
    I am trying to implement a WD application that will have some input fields, the value of those input fields will be used to create an xml file with a certain format and then sent to a certain application.
    Apart from this i want to read an xml file back from the application and then fill some other context nodes with values from the xml file.
    Is there any standard used code to do this??
    If not how can i do this???
    Thanx in advance!!!
    P.S. Points will be rewarded to all usefull answers.
    Edited by: Armin Reichert on Jun 30, 2008 6:12 PM
    Please stop this P.S. nonsense!

    Hi,
    you need to create three util class for that:-
    XMLHandler
    XMLParser
    XMLBuilder
    for example in my XML two tag item will be there e.g. Title and Organizer,and from ur WebDynpro view you need to pass value for the XML tag.
    And u need to call buildXML()function of builder class to generate XML, in that i have passed bean object to get the values of tags. you need to set the value in bean from the view ui context.
    Code for XMLBuilder:-
    Created on Apr 4, 2006
    Author-Anish
    This class is to created for having function for to build XML
    and to get EncodedXML
      and to get formated date
    package com.idb.events.util;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import com.idb.events.Event;
    public class XMLBuilder {
    This attribute represents the XML version
         private static final double VERSION_NUMBER = 1.0;
    This attribute represents the encoding
         private static final String ENCODING_TYPE = "UTF-16";
         /*Begin of Function to buildXML
    return: String
    input: Event
         public String buildXML(Event event) {
              StringBuffer xmlBuilder = new StringBuffer("<?xml version=\"");
              xmlBuilder.append(VERSION_NUMBER);
              xmlBuilder.append("\" encoding=\"");
              xmlBuilder.append(ENCODING_TYPE);
              xmlBuilder.append("\" ?>");
              xmlBuilder.append("<event>");
              xmlBuilder.append(getEncodedXML(event.getTitle(), "title"));
              xmlBuilder.append(getEncodedXML(event.getOrganizer(), "organizer"));
              xmlBuilder.append("</event>");
              return xmlBuilder.toString();
         /End of Function to buildXML/
         /*Begin of Function to get EncodedXML
    return: String
    input: String,String
         public String getEncodedXML(String xmlString, String tag) {
              StringBuffer begin = new StringBuffer("");
              if ((tag != null) || (!tag.equalsIgnoreCase("null"))) {
                   begin.append("<").append(tag).append(">");
                   begin.append("<![CDATA[");
                   begin.append(xmlString).append("]]>").append("</").append(
                        tag).append(
                        ">");
              return begin.toString();
         /End of Function to get EncodedXML/
         /*Begin of Function to get formated date
    return: String
    input: Date
         private final String formatDate(Date inputDateStr) {
              String date;
              try {
                   SimpleDateFormat simpleDateFormat =
                        new SimpleDateFormat("yyyy-MM-dd");
                   date = simpleDateFormat.format(inputDateStr);
              } catch (Exception e) {
                   return "";
              return date;
         /End of Function to get formated date/
    Code for XMLParser:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLParser {
    Enables namespace functionality in parser
         private final boolean isNameSpaceAware = true;
    Enables validation in parser
         private final boolean isValidating = true;
    The SAX parser used to parse the xml
         private SAXParser parser;
    The XML reader used by the SAX parser
         private XMLReader reader;
    This method creates the parser to parse the user details xml.
         private void createParser()
              throws SAXException, ParserConfigurationException {
              // Create a JAXP SAXParserFactory and configure it
              SAXParserFactory saxFactory = SAXParserFactory.newInstance();
              saxFactory.setNamespaceAware(isNameSpaceAware);
              saxFactory.setValidating(isValidating);
              // Create a JAXP SAXParser
              parser = saxFactory.newSAXParser();
              // Get the encapsulated SAX XMLReader
              reader = parser.getXMLReader();
              // Set the ErrorHandler
    This method is used to collect the user details.
         public Event getEvent(
              String newsXML,
              XMLHandler xmlHandler,
              IWDMessageManager mgr)
              throws SAXException, ParserConfigurationException, IOException {
              //create the parser, if not already done
              if (parser == null) {
                   this.createParser();
              //set the parser handler to extract the
              reader.setErrorHandler(xmlHandler);
              reader.setContentHandler(xmlHandler);
              InputSource source =
                   new InputSource(new ByteArrayInputStream(newsXML.getBytes()));
              reader.parse(source);
              //return the results of the parse           
              return xmlHandler.getEvent(mgr);
    Code for XMLHandler:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    Created on Apr 12, 2006
    Author-Anish
    *This handler class is created to have constant value for variables and function for get events,
        character values for bean variable,
        parsing thr date ......etc
    package com.idb.events.util;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Locale;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.helpers.DefaultHandler;
    import java.util.*;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLHandler extends DefaultHandler {
         private static final String TITLE = "title";
         private static final String ORGANIZER = "organizer";
         IWDMessageManager manager;
         private Event events;
         private String tagName;
         public void setManager(IWDMessageManager mgr) {
              manager = mgr;
    This function is created to get events
         public Event getEvent(IWDMessageManager mgr) {
              manager = mgr;
              return this.events;
    This function is created to get character for setting values through event's bean setter method
         public void characters(char[] charArray, int startVal, int length)
              throws SAXException {
              String tagValue = new String(charArray, startVal, length);
              if (TITLE.equals(this.tagName)) {
                   this.events.setTitle(tagValue);
              if (ORGANIZER.equals(this.tagName)) {
                   String orgName = tagValue;
                   try {
                        orgName = getOrgName(orgName);
                   } catch (Exception ex) {
                   this.events.setOrganizer(orgName);
    This function is created to parse boolean.
         private final boolean parseBoolean(String inputBooleanStr) {
              boolean b;
              if (inputBooleanStr.equals("true")) {
                   b = true;
              } else {
                   b = false;
              return b;
    This function is used to call the super constructor.
         public void endElement(String uri, String localName, String qName)
              throws SAXException {
              super.endElement(uri, localName, qName);
         /* (non-Javadoc)
    @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
    This function is used to call the super constructor.
         public void fatalError(SAXParseException e) throws SAXException {
              super.fatalError(e);
    This function is created to set the elements base on the tag name.
         public void startElement(
              String uri,
              String localName,
              String qName,
              Attributes attributes)
              throws SAXException {
              this.tagName = localName;
              if (ROOT.equals(tagName)) {
                   this.events = new Event();
         public static void main(String a[]) {
              String cntry = "Nigeria";
              XMLHandler xml = new XMLHandler();
              ArrayList engList = new ArrayList();
              engList = xml.getCountries();
              ArrayList arList = xml.getArabicCountries();
              int engIndex = engList.indexOf(cntry);
              System.out.println("engIndex  :: " + engIndex);
              String arCntryName = (String) arList.get(engIndex);
              System.out.println(
                   ">>>>>>>>>>>>>>>>>>>>" + xml.getArabicCountryName(cntry));
    Hope that may help you.
    If need any help , you are most welcome.
    Regards,
    Deepak

  • What's the best way to create XML file with a schema from a database table?

    Hi,
    I want to create an XML file from a database table (which has over 600 columns) using XML schema (.xsd file). I want to know the best way to do this.
    The output XML file is NOT a direct data dump from the DB table, there�re some logic around it, such as the XML file has some hierarchy with repeating tags.
    I have done this using JAXB by creating Java classes form XML schema, but I don�t want to map 600 DB columns to these Java classes manually, and loop through the record set to create repeating tags.
    I know there are few tools around now like MapForce (Altova), how do people do these now?
    Thanks,
    Chandi

    Can you use a schema when we compose XML doc from Database tables?
    Actually, I'm using SQL Server (sorry, wrong forum). But, I thought a Java tool would have a solution for me.

  • Create XML File with codepage (not UNICODE)

    Hi all ,
    I'm using the SDIXML_DATA_TO_DOM function module to create a xml format from an internal table, finally I write the internal table in xml format to file in the application server.
    Finally I get a file in XML format in UTF-8 (UNICODE), but I have to convert the UTF-8 into other codepage because the file is send to other system which not familiar with the UNICODE.
    Does anyone knows how to convert the codepage for the xml internal table ?
    Thanks,
    Yaki

    Another option rather than converting it after the fact is to have it create the XML file in the encoding that you want to begin with.  It looks like this function module you mention will either accept a pointer to a XML document object or create one for you.  I would suggest that you go ahead and create a document yourself and pass it to the function module.
      ixml = cl_ixml=>create( ).
      document = ixml->create_document( ).
    You can then call the method SET_ENCODING of the class IF_IXML_DOCUMENT.  The encoding itself is another class of type IF_IXML_ENCODING.  You can set the character set in this object using method SET_CHARACTER_SET.

  • Create xml file with nested internla table or with header & item tables

    Hi I have a requirement like, I need to create an xml file for header and item details. For 1 header there may be multiple line items.
    I did search in forums some where I came to know that we can use XSL:IF to achieve this. but I could not able to do this.
    I tried with using nested internal tables also but now luck.
    can anybody please suggest how can we create xml for header and item detials.
    <xsl:transform version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:sap="http://www.sap.com/sapxsl"
      xmlns:asx="http://www.sap.com/abapxml"
      exclude-result-prefixes="asx"
    >
    <xsl:template match="/">
      <OrbisomRequest>
        <xsl:attribute name="Version">
          <xsl:value-of select="11.1"/>
        </xsl:attribute>
        <xsl:attribute name="IssuerID">
          <xsl:value-of select="1"/>
        </xsl:attribute>
        <xsl:for-each select="asx:abap[1]/asx:values[1]/T_FINAL[1]/*">
    <CreateApprovedPurchaseRequest
           RerquestID="{VBLNR}"
           CommonName="User1"
           Amount="{WRBTR}"
           Comment="TestComment"
           CurrencyCode="978"
           PurchaseType="All"
           SupplierName="All"
           VCardAlias="PurchaseCard"
           ValidFrom="1M"
           CurrencyType="B">
                    <CDFs>
                      <Invoice> <xsl:value-of select="BELNR"/> </Invoice>
                      <Amount> <xsl:value-of select="WRBTR"/> </Amount>
                    </CDFs>
          </CreateApprovedPurchaseRequest>
        </xsl:for-each>
      </OrbisomRequest>
    </xsl:template>
    </xsl:transform>
    here belnr and wrbtr will be my item details. for each payment document I can have multiple invoices. in CDF I need to display the invoices for that particular payment document.
    what conditions can I put there before CDFs to make the item internal table to loop based on header internal table.
    Regards,
    Ranganadh.

    Looks like you have already created the transformation "Z_ID"
    Take a look at the following thread, it answers many of the questions you have asked:
    [ABAP data to XML conv with UTF-8 encoding and custom namespace|Re: ABAP data to XML conv with UTF-8 encoding and custom namespace;
    Che

  • Creating XML files with the DME

    Hi All,
    I'm working on an integration project between my company and HSBC, they are requesting that we supply our AP payment files for foreign currency in XML format.
    I have some limited experience with the DME and know it can create XML files, however, the elements available for XML files are different to standard flat files. Also it doesnt seem like I can create files with multiple levels? e.g.
    <InitgPty>
    ......... <Id>
    ............... <OrgId>
    ...................... <BkPtyId>ABC00103003</BkPtyId>
    .............. </OrgId>
    ........ </Id>
    </InitgPty>
    Does anyone have any documentation or experience with creating XML files with DME?
    thanks
    Phil.

    Hi,
    Please ask any Implementation team in ABAB or Report painter team with your friends,
    Thanks and REgards
    N.Soma Sundaram

  • How to Create XML file with SAX parser instead of DOM parser

    HI ALL,
    I am in need of creating an XML file by SAX parser ONLY. As far as my knowledge goes, we can use DOM for such purpose(by using createElement, creatAttribute ...). Can anyone tell me, is there any way to create an XML file using SAX Parser only. I mean, I just want to know whether SAX provides any sort of api for Creatign an element, attribute etc. I know that SAX is for event based parsing. But my requirement is to create an XML file from using only SAX parser.
    Any help would be appreciated
    Thanx in advance
    Kaushik

    Hi,
    You must write a XMLWriter class yourself, and that Class extends DefaultHandle ....., the overwrite the startElement(url, localName, qName, attributeList), startDocument(), endElement().....and so on.
    in startElement write your own logic about how to create a new element and how to create a Attribute list
    in startDocument write your own logic about how to build a document and encodeType, dtd....
    By using:
    XMLWriter out = new XMLWriter()
    out.startDocument();
    Attribute attr1 = new Atribute();
    attr1.add("name", "value");
    out.startElement("","","Element1", attr1);
    Attribute attr2 = new Atribute();
    attr2.add("name", "value");
    out.startElement("","","Element2", attr2);
    out.endElement("","","Element2");
    out.endElement("","","Element1");
    out.endDocument();

  • SQL Error : missing expression - Creating XML file with ODI

    Hi,
    I saw threads about errors like this and read that maybe it can come from how I chose the staging area. I still can't see where the problem is. I'm trying to create an xml file from data stored in a Oracle database. The interface which execution fails select data from tables and create a tag in the XML file. Here are information about it :
    The staging area is diferent from the target and is an oracle database schema. (I guess it creates temporary tables in that schema ?)
    In the flow tab, the LKM is LKM SQL to SQL, the option delete temporary objects is set to yes.
    The IKM choice for the target is IKM SQL Control Append and options are as following :
    - insert : yes
    - commit : yes
    - flow contreol : no
    - recycle errors : no
    - static control : no
    - truncate : no
    - delete all : no
    - create target table : yes
    - delete temporary objects : yes
    Columns mapping in the target are the following :
    WKID        >     THEADER.WKID
    EXTID        >     THEADER.EXTID
    ORDER     >     THEADER.ORDER
    INSTFK     >     THEADER.INSTFK
    For every column in the target :
    - Run on source
    - Updating : insert, update and ud4 are checked
    no update key is defined
    In the operator, the step failing when running the interface is the loading data in the work table.
    If you need the SQL request in the execution plan, or anything else, please tell me.
    Thank you in advance for any help on this.
    Marie

    It would help if you provide error message and its stack trace.
    Please also look at the documentation (If not already done so) for creating xml file XML Files - 11g Release 1 (11.1.1)

  • Create an XML File in Application server

    Hello,
    I have a requirement to create an XML File as Local File and as server File. For the local File it works fine and i got a Local XML File.
    My problem is for the Server File.I found a solution in internet to convert in binary.But i don't get in the server File created the XML structure.
    Here is My code for the unix server File
    DATA ex_tab TYPE TABLE OF x255.
      data: wa_tab type x255.
      data: lv_line(255) type c.
    **-- carica tabella gt_file
       PERFORM CARICA_TAB_FILE.
       LOOP AT GT_FILE.
         MOVE-CORRESPONDING GT_FILE TO WA_SOURCE.
         APPEND WA_SOURCE TO GT_SOURCE.
         CLEAR WA_SOURCE.
       ENDLOOP.
    * Perform the XSLT stylesheet
       TRY.
           CALL TRANSFORMATION ZMESMO052_XML
              SOURCE MATERIAL_DATA = GT_SOURCE[]
              RESULT XML XML_RESULT .
         CATCH CX_ROOT INTO GS_RIF_EX.
           GS_VAR_TEXT = GS_RIF_EX->GET_TEXT( ).
           MESSAGE GS_VAR_TEXT TYPE 'E'.
       ENDTRY.
      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
         EXPORTING
             buffer     = XML_RESULT
           TABLES
             binary_tab = ex_tab.
       CONCATENATE P_FILE '.xml' INTO P_FILE.
       CONDENSE P_FILE.
       TRANSLATE P_FILE TO LOWER CASE.
       OPEN DATASET P_FILE FOR OUTPUT IN BINARY MODE.
       IF SY-SUBRC NE 0.
         MESSAGE E000(ZF) WITH ' Error opening File' P_FILE.
       ENDIF.
       loop at ex_tab  into wa_tab.
         move wa_tab to lv_line.
         transfer lv_line to p_file.
       endloop.
       close dataset p_file.
    And i Got a file like this
    Any solution please

    I Found the solution,
    DATA EX_TAB TYPE TABLE OF X255.
       DATA: WA_TAB TYPE X255.
       DATA: LV_LINE(255) TYPE C.
       DATA: L_CONVIN TYPE REF TO CL_ABAP_CONV_IN_CE.
       DATA: L_HTML TYPE STRING.
       DATA: L_VALUE TYPE STRING.
       DATA: L_MSGSTR TYPE STRING.
       DATA: FILENAME TYPE STRING.
    **-- carica tabella gt_file
       PERFORM CARICA_TAB_FILE.
       LOOP AT GT_FILE.
         MOVE-CORRESPONDING GT_FILE TO WA_SOURCE.
         APPEND WA_SOURCE TO GT_SOURCE.
         CLEAR WA_SOURCE.
       ENDLOOP.
    * Perform the XSLT stylesheet
       TRY.
           CALL TRANSFORMATION ZMESMO052_XML
              SOURCE MATERIAL_DATA = GT_SOURCE[]
              RESULT XML XML_RESULT .
         CATCH CX_ROOT INTO GS_RIF_EX.
           GS_VAR_TEXT = GS_RIF_EX->GET_TEXT( ).
           MESSAGE GS_VAR_TEXT TYPE 'E'.
       ENDTRY.
       TRY.
           CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
             EXPORTING
               ENCODING = 'UTF-8'
               INPUT    = XML_RESULT
             RECEIVING
               CONV     = L_CONVIN.
           CALL METHOD L_CONVIN->READ
             IMPORTING
               DATA = L_HTML.
         CATCH CX_ROOT.
           L_MSGSTR = 'Conversion error'.
       ENDTRY.
       SEARCH L_HTML FOR '><'.
       CLEAR L_VALUE.
       L_VALUE = CL_ABAP_CHAR_UTILITIES=>NEWLINE.
       CONCATENATE '>' L_VALUE '<' INTO L_VALUE.
       IF SY-SUBRC = 0.
         REPLACE ALL OCCURRENCES OF '><' IN L_HTML WITH L_VALUE IN
    CHARACTER MODE.
       ENDIF.
       CONCATENATE P_FILE '.xml' INTO P_FILE.
       CONDENSE P_FILE.
       TRANSLATE P_FILE TO LOWER CASE.
       FILENAME = P_FILE.
       OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE
    WITH UNIX LINEFEED.
       TRANSFER L_HTML TO FILENAME.
       CLOSE DATASET FILENAME.

  • Need help Take out the null values from the ResultSet and Create a XML file

    hi,
    I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
    a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
    takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
    from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
    null values to XML File. When i run the program it works alright and adds the null and not null values to
    the file. But when i pass the boolean value to take out the null values it would not take it out and adds
    the null and not null values.
    Please look at the code i am posing. I am showing step by step where its not adding the null values.
    Any help is always appreciated.
    Thanks in advance.
    ============================================================================
    Frame1 Class
    ============
    public class Frame1 extends JFrame{
    private JPanel contentPane;
    private XQuery xQuery1 = new XQuery();
    private XYLayout xYLayout1 = new XYLayout();
    public Document doc;
    private JButton jButton2 = new JButton();
    private Connection con;
    private Statement stmt;
    private ResultSetToXML rstx;
    //Construct the frame
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    xQuery1.setSql("");
    xQuery1.setUrl("jdbc:odbc:SCANODBC");
    xQuery1.setUserName("SYSDBA");
    xQuery1.setPassword("masterkey");
    xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
    jButton2.setText("Get XML from DB");
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(java.lang.ClassNotFoundException ex) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(ex.getMessage());
    try {
    con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
    stmt = con.createStatement();
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton2_actionPerformed(e);
    contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton2_actionPerformed(ActionEvent e) {
    try{
    OutputStream out;
    XMLOutputter outputter;
    Element root;
    org.jdom.Document doc;
    root = new Element("PINFO");
    String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
    ResultSet rs = stmt.executeQuery(query);
    /*===========This is where i am passing the ResultSet and boolean=======
    ===========value to either add the null or not null values in the file======*/
    rstx = new ResultSetToXML(rs,true);
    } //end of try
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    ======================================================================================
    ResultSetToXML class
    ====================
    public class ResultSetToXML {
    private OutputStream out;
    private Element root;
    private XMLOutputter outputter;
    private Document doc;
    // Constructor
    public ResultSetToXML(ResultSet rs, boolean checkifnull){
    try{
    String tagname="";
    String tagvalue="";
    root = new Element("pinfo");
    while (rs.next()){
    Element users = new Element("Record");
    for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
    tagname= rs.getMetaData().getColumnName(i);
    tagvalue=rs.getString(i);
    System.out.println(tagname);
    System.out.println(tagvalue);
    /*============if the boolean value is false it adds the null and not
    null value to the file =====================*/
    /*============else it checks if the value is null or the length is
    less than 0 and does the else clause in the if(checkifnull)===*/
    if(checkifnull){ 
    if((tagvalue == null) || tagvalue.length() < 0 ){
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    root.addContent(users);
    out=new FileOutputStream("c:/XMLFile.xml");
    doc = new Document(root);
    outputter = new XMLOutputter();
    outputter.output(doc,out);
    catch(IOException ioe){
    System.out.println(ioe);
    catch(SQLException sqle){

    Can someone please help me with this problem
    Thanks.

  • How can I save a XML file with JAXP1.1?

    Dear All.
    I write a program to create XML file with DOM model, but I can't know how to save it? My environment is JAXP1.1 and JDK1.3.1,I has been required not use other XML parser toolkits,only JAXP1.1.
    How can I do? thank you.
    Many person give me a idea the com.sun.xml.tree.XmlDocument, but I can't find the class in API document or JAXP1.1's packages. why?
    what is it? How can i use it?
    thank you very much.

    The way to save an XML Document is using a Transformer.
    To have access to a transformer use the packages :
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    Then for saving your Document Object (named dXml) get a Transformer Object with the TransformerFactory Object :
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    Now you have got your Transformer Object, to save your Document Object use the method :
    Document dXml = getMyDocument(); // this is your Document Object.
    OutputStream osSave = getMySaveStream(); // this the OutputStream you need to save your Document.
    try
    t.transform(new DomSource(dXml), new StreamResult(new OutputStreamWriter(osSave)));
    finally
    osSave.close();
    And your Document was now saved.

  • URGENT --  Perofrmance issue while creating Huge XML file

    All XML Experts Please Help....Thanks a lot in Advance
    We are trying to create a XML file for a huge table.. 5 million rows and the performance is ver very bad.. Can some body help by giving me an idea what what my best approch could be... or what am I doing wrong in in the code below
    CREATE OR REPLACE PROCEDURE Sales_1_Generate_Xml IS
    temp_clob CLOB;
    temp_buffer VARCHAR2(1);
    amount BINARY_INTEGER := 1;
    position INTEGER := 1;
    filehandle utl_file.file_type;
    error_number NUMBER;
    error_message VARCHAR2(100);
    length_count INTEGER;
    qryctx dbms_xmlgen.ctxhandle;
    BEGIN
    qryctx := dbms_xmlgen.newcontext('select /* INDEX UF_SALES(UF_SALES_IX16) */
    TRANSACTION_NUMBER     "Transaction_Number",
    TRANSACTION_TYPE_ID     "Transaction_Type_ID",
    PROCESS_FISCAL_DATE_ID     "Process_Fiscal_Date_ID",
    INVOICE_FISCAL_DATE_ID     "Invoice_Fiscal_Date_ID",
    ORDER_FISCAL_DATE_ID     "Order_Fiscal_Date_ID",
    PROCESS_CALENDAR_DATE_ID     "Process_Calendar_Date_ID",
    INVOICE_CALENDAR_DATE_ID     "Invoice_Calendar_Date_ID",
    ORDER_CALENDAR_DATE_ID     "Order_Calendar_Date_ID",
    CURRENT_TM_ID     "Current_TM_ID",
    CUSTOMER_ID     "Customer_ID",
    CUSTOMER_TYPE_ID     "Customer_Type_ID",
    CUSTOMER_LEVEL_ID     "Customer_Level_ID",
    ACCOUNT_TYPE_ID     "Account_Type_ID",
    TRADE_CLASS_ID     "Trade_Class_ID",
    DISTRIBUTOR_ID     "Distributor_ID",
    PRODUCT_ID     "Product_ID",
    ORDERED_PRODUCT_ID     "Ordered_Product_ID",
    BRAND_TYPE_ID     "Brand_Type_ID",
    LABEL_TYPE_ID     "Label_Type_ID",
    BRAND_LABEL_ID     "Brand_Label_ID",
    PRICED_BY_ID     "Priced_By_ID",
    SALES_UOM_ID     "Sales_UOM_ID",
    PURCHASING_UOM_ID     "Purchasing_UOM_ID",
    PRICING_UOM_ID     "Pricing_UOM_ID",
    NET_COST     "Net_Cost",
    NPA_S     "NPA_S",
    CMA_S     "CMA_S",
    NOT_S     "NOT_S",
    TOTAL_NATIONAL_ALLOWANCE_S     "Total_National_Allowance_S",
    LPA_S     "LPA_S",
    LMA_S     "LMA_S",
    LOT_S     "LOT_S",
    TOTAL_LOCAL_ALLOWANCE_S     "Total_Local_Allowance_S",
    TOTAL_ALLOWANCES_S     "Total_Allowances_S",
    LPC     "LPC",
    LPC_EXTENDED     "LPC_Extended",
    LPF     "LPF",
    LPF_EXTENDED     "LPF_Extended",
    TRUE_COST     "True_Cost",
    CDE     "CDE",
    LPP     "LPP",
    SURCHARGE     "Surcharge",
    COMBINED_SURCHARGE     "Combined_Surcharge",
    TOTAL_SURCHARGES     "Total_Surcharges",
    MARKET_COST     "Market_Cost",
    INSIDE_PAD     "Inside_Pad",
    SALES_REP_COST     "Sales_Rep_Cost",
    SALES_REP_MARGIN     "Sales_Rep_Margin",
    SALES_PRICE     "Sales_Price",
    SALES_TRUE_MARGIN     "Sales_True_Margin",
    NVD     "NVD",
    LVD     "LVD",
    NID     "NID",
    LID     "LID",
    TOTAL_VD     "Total_VD",
    TOTAL_ID     "Total_ID",
    TOTAL_DEVIATIONS     "Total_Deviations",
    GP1     "GP1",
    GP2     "GP2",
    DEVIATED_COST     "Deviated_Cost",
    ACTUAL_COST     "Actual_Cost",
    SALES_TAX     "Sales_Tax",
    QUANTITY_ORDERED     "Quantity_Ordered",
    QUANTITY_SHIPPED     "Quantity_Shipped",
    QUANTITY_DEVIATED     "Quantity_Deviated",
    QUANTITY_SUBBED     "Quantity_Subbed",
    UNITS_ORDERED     "Units_Ordered",
    EACHES_ORDERED     "Eaches_Ordered",
    EACH_CONVERSION_FACTOR     "Each_Conversion_Factor",
    UNITS_SHIPPED     "Units_Shipped",
    EACHES_SHIPPED     "Eaches_Shipped",
    SHIP_WEIGHT     "Ship_Weight",
    ACTUAL_GP_DLR     "Actual_GP_Dlr",
    TRUE_GP_DLR     "True_GP_Dlr",
    LANDED_GP_DLR     "Landed_GP_Dlr",
    LANDED_ACTUAL_GP_DLR     "Landed_Actual_GP_Dlr",
    INVOICE_GP_DLR     "Invoice_GP_Dlr",
    INVOICE_ACTUAL_GP_DLR     "Invoice_Actual_GP_Dlr",
    ADJUSTED_ACTUAL_GP_DLR     "Adjusted_Actual_GP_Dlr",
    EB_S     "EB_S",
    MB_S     "MB_S",
    ACTUAL_TM_ID     "Actual_TM_ID",
    ACTUAL_TM_NAME     "Actual_TM_Name",
    ACTUAL_DSM_ID     "Actual_DSM_ID",
    ACTUAL_DSM_NAME     "Actual_DSM_Name",
    INVOICE_NUMBER      "Invoice_Number ",
    CONTRACT_NUMBER     "Contract_Number",
    CUSTOMER_NUMBER     "Customer_Number",
    CUSTOMER     "Customer",
    PRODUCT_NUMBER     "Product_Number",
    MASTER_DISTRIBUTOR_ID     "Master_Distributor_ID",
    ORDERED_PRODUCT_NUMBER     "Ordered_Product_Number",
    NATIVE_PRODUCT_STATUS     "Native_Product_Status",
    NATIVE_PRICED_BY_INDICATOR     "Native_Priced_By_Indicator",
    EXTRACTION_TIME     "Extraction_Time"
    from uf_sales where distributor_id in (''5139'',
    ''5140'',
    ''5145'',
    ''5150'',
    ''5160'',
    ''5175'',
    ''5180'',
    ''5210'',
    ''5220'',
    ''5230'')
    DBMS_XMLGen.setRowTag(qryctx,'Sales_Record');
    DBMS_XMLGen.setRowSetTag(qryctx,'Sales_Set');
    temp_clob:=dbms_xmlgen.getxml(qryctx);
    length_count := dbms_lob.getlength(temp_clob);
    dbms_output.put_line('Internal LOB size is: ' || length_count);
    filehandle := utl_file.fopen('DATA_EXTRACT','Sales_1.xml','Wb',32767);
    WHILE length_count <> 0 LOOP
    dbms_lob.read (temp_clob, amount, position, temp_buffer);
    --utl_file.put (filehandle, temp_buffer);
    utl_file.put_raw(filehandle, utl_raw.cast_to_raw(temp_buffer));
    position := position + 1;
    length_count := length_count - 1;
    temp_buffer := null;
    END LOOP;
    dbms_output.put_line('Exit the loop');
    utl_file.fclose(filehandle);
    DBMS_XMLGen.closeContext(qryctx);
    dbms_output.put_line('Close the file');
    EXCEPTION
    WHEN OTHERS THEN
    BEGIN
    error_number := sqlcode;
    error_message := substr(sqlerrm ,1 ,100);
    dbms_output.put_line('Error #: ' || error_number);
    dbms_output.put_line('Error Message: ' || error_message);
    utl_file.fclose_all;
    END;
    END;
    /

    OK, so you are writing the file with UTL_FILE. How long is the whole process taking. Have you timed the time taken to generate the temp_clob with the result Vs the time to write the output to a file.

  • How do I create an XML file through a JSP?

    I want to have a JSP which allows the user to create an account with password and this is stored in an XML file. I would like to b e able to amend this XML file with future users of the JSP but I'm not sure how to do this. I can do it using a database converting that to XML and then save the user input but I don't want to use a DB this time. Can some body give me an example. It the closing XML tag I have trouble with. I could amend the file but the previuos entry would close the XML file and then the newest entry would add on in effect an new XML file to the previous. Hope you can understand what I'm saying?!
    I have a file with:
    <topic>
    <--- this is where I want to store my data!
    </topic>
    Michael

    Use JDOM ... Here's a tutorial where you create a DOM and save it to an xml file ...
    http://www.topxml.com/tutorials/main.asp?id=jdom&page=15

Maybe you are looking for

  • Crystal Report not running from Addon in the Front End.

    Dear All , There is a Crystal report , .rpt File inbuilt in the Add-on . This report runs well from the Source Code . But i am facing problem , since it is not Opening at the Front End after registration of the Add0n. Suggest what to do ? Thanks Ashi

  • Using Front Row On Duel Screen

    Hi guys, I've got a macbook at the moment and was wondering, if i were to hook it up to another screen and run it duel screen is it possible to use front row in the second screen as appose to just the main laptop screen? And then also use the remote

  • Which version is used

    Hi In m TLD file i am writing -: <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> </taglib> I am creating custom tags and not installed with JSTL, should i have to install it before making Custom Tags. I am using Tomcat 5.0 so ple

  • Can't Open FLA files

    Hello, This just started happening, not sure why. If I have an FLA on my desktop, and I double click on it to open it, I get an error that says: "Windows cannot find <directory to my file\myFile.FLA>. Make sure you typed the name correctly and then t

  • Make a servlet wait for  a resource and respond based on the resource

    Hi, In my web application, my javascript code sends a request to a servlet for an image . In the server side, my servlet checks whether the image exists in a particular path, if it exists it sends the image as a response, else will wait in an infinit