Generic Populating the XML document using Java Class Generator and Reflection

I am looking for a generic source code in order to convert the data parsed from any tabular text form ( tab delimited for example that maps certain XML Schema created form Database Schema for Oracle.
I know it is possible to generate XML DTD or XSD from Oracle database table schema by XSU utility from XDK. And also it is possible to create Java source files from an XML DTD or XSD by using XML Clas Generator.
I believe there must be some generic code that parses tabular text data and converts them to XML format using above mentioned generated Java source files and may be Java reflection mechanism.
If anyone has any tool or knows any free ware that helps me, I would like to know about it, and I would really appreciate it.

1. Read the XML file into a DMO object, walk the DOM to find the list, insert your new entry as a child, write the DOM back to a file.
2. If the XML is not in a file, but in a string, then you can do the same with string input and output.

Similar Messages

  • How to append child to XML document using Java

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
         <bean name="PinnacleReportsData"
              class="com.hsbc.webapp.report.view.GenericPinnacleReportsViewData"
              singleton="false">
              <property name="headers">
                   <value>Account|Cusip|Description|SecType|Sector|Holding|Price|MarketValue|SettleDate|Yield|SprdUST|AL|CFDur|OAS|ZVolOas|OADur|PrepayDur|VolDur|DV01|DVOAS01|KRDur10Y|PrepayModelCalled|CalcError|CalculationTime</value>
              </property>     
              <property name="noOfRows">
                   <value>20</value>
              </property>     
              <property name="rowdata">
                   <list>
                        <value>AA09b|CMO|8000|8000|62052MAD0|MFPLC_4A 2A 144A||8097|99-27+|5.18|0.25|200|0.00||15||||</value>
                        <value>AA09b|CMO|10000|10000|320277AD8|HASCO 2005 F II-A-2||9958|99-13|5.69|0.13|131|0.02||154|0.000|25|0.001|9864</value>
                        <value>AA09b|CMO|8000|2363|46071LAA8|IMT_03-3G A2||2378|100-01|5.18|0.14|33|0.00||2||||</value>
                        <value>AA09b|CMO|1270|312|40430HDW5|HASCO 2006-O II-A-1||309|99-00|8.98|0.16|5|0.01||3|0.000|1|0.001|296</value>
                        <value>AA09b|CMO|5000|5000|40430HFQ6|HASCO 2006-O M-3||4583|91-15+|8.99|1.16|534|-0.58|-2|-2644|0.016|712|0.080|367625</value>
                        <value>AA74b|ABS|8000|8000|62052MAD0|MFPLC_4A 2A 144A||8097|99-27+|5.18|0.25|200|0.00||15||||</value>
                        <value>AA74b|ABS|10000|10000|320277AD8|HASCO 2005 F II-A-2||9958|99-13|5.69|0.13|131|0.02||154|0.000|25|0.001|9864</value>
                        <value>AA74b|ABS|8000|2363|46071LAA8|IMT_03-3G A2||2378|100-01|5.18|0.14|33|0.00||2||||</value>
                        <value>AA74b|ABS|1270|312|40430HDW5|HASCO 2006-O II-A-1||309|99-00|8.98|0.16|5|0.01||3|0.000|1|0.001|296</value>
                        <value>AA74b|ABS|5000|5000|40430HFQ6|HASCO 2006-O M-3||4583|91-15+|8.99|1.16|534|-0.58|-2|-2644|0.016|712|0.080|367625</value>
                   </list>
              </property>
         </bean>
    </beans>               hi there i have a XML Document above,and i need to append values to the <list> using java.
    i have string values like
         <value>AA74b|ABS|5000|5000|40430HFQ6|HASCO 2006-O M-3||4583|91-15+|8.99|1.16|534|-0.58|-2|-2644|0.016|712|0.080|367625</value>to add, but failing to navigate to the <list>
    any help?

    1. Read the XML file into a DMO object, walk the DOM to find the list, insert your new entry as a child, write the DOM back to a file.
    2. If the XML is not in a file, but in a string, then you can do the same with string input and output.

  • Get error when unzipping document using Java Class

    I am using an applet to unzip a compressed docuement. The document is compressed by a Java Rich client into a database and is going to be opened by a web application. So in order to decompress we are using an applet with the same unzip code. The rich client is working fine, but the applet is giving an error. Can anyone tell me what the following error means?? I have found no documentation on it and it is not giving me any real information.
    java.util.zip.DataFormatException: oversubscribed dynamic bit lengths tree
    I am using the Inflater class to unzip the doc.
    thanks,

    Can you be any more specifc about what you are doing?
    It may be a security issue as you are running the code in an applet.
    The other thing to look into would be the content type you are using to send the zipped data over http. When writing the zipped object into the HttpServletResponse on the server you must call
    setContentType("application/zip");
    For a quickish example see
    http://java.sun.com/developer/technicalArticles/Networking/Webserver/WebServercode.html
    This sets the content type based on the file to be returned extension.
    Hope this is helpful.

  • How to comment the xml tags using java

    Iam using a xml file i want to comment some of the tags in that file

    And your quesion is? Did you parse it into a Document and do you want to write a changed version into another file?

  • Validation of an XML document using an XMLSchema !

    Hi all,
    i have an xml document and an XmlSchema.
    Well, my mission is validate the xml document using the XmlSchema and give the message true or false to the user.
    What is the best,easier and faster way to do this ?
    Cheers.
    Stefano

    I would like to do the same thing only I would like to use JAXP. The JAXP 1.2 samples show the following code to accomplish this:
    final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
    final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
    //create and configure SAX parser factory
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    spf.setValidating(true);
    //create and configure SAX parser
    SAXParser saxParser = spf.newSAXParser();
    saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
    saxParser.setProperty(JAXP_SCHEMA_SOURCE, new File(schemaSource));
    //parse XML document
    saxParser.parse(new InputSource(xmlURI), myDefaultHandler);
    However, I would like to use the default Crimson parse that ships with J2SE 1.4. Is there a way to accomplish this using the default Crimson parser that only support JAXP 1.1?

  • Create web service using java class

    Hi,
    I created the web service using java class then i deployed this web service in to the weblogic admin server.when i tested this process it is working fine.
    when I tested The generated WSDL to this process in browser(IE). it is not working.
    I need to to invoke this webservice from another BPEL but this WSDL is not working.

    Hi,
    when i created the webservice in jdeveloper by default it is connected to integrated weblogic server and generates this wsdl.
    http://localhost:7101/helloApplication-javaexcel-context-root/MyWebService1Soap12HttpPort?WSDL
    then I deployed this webservice in to the Adminserver.it gives the following URL.
    http://192.168.56.1:7001/extracExcelToCSV-extractExcelToCSV-context-root/ExtractExcelToCSVSoap12HttpPort?wsdl
    This URL is not working but when i tested this process it is working fine.
    It is giving below error when i try to invoke from jdeveloper
    Error while reading wsdl file
    caused by:java.net.connectExcepption :Connection timed out:connect

  • Not able to validate the xml document against DTD using SAX

    Hi ,
    i am not able to validate xml document against its DTD using SAX parser even after setting setValidating = true. even if the file is not correct according to DTD , it is not throwing any exception. what could be the reason.? please help..
    kranthi
    this is the code sample i used.
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(true);
         try {
    factory.newSAXParser().parse(new File("sample.xml"), handler);
         } catch (SAXException e) {
         e.printStackTrace();                         System.exit(2);
         } catch (ParserConfigurationException e) {
    e.printStackTrace();
    }

    Hi karthik
    Thanks for your response
    Actually iam a beginner in java coding hence struggling to come up with the things
    I tried putting your code and onserver side i see it is returning 09:12:17,234 INFO [STDOUT] [root: null]
    actually the same program i wrote in java
    and the same method i was calling from the main
    and it is working fine and the xml document is getting displayed one important thing to be noted here is that the factory.newDocumentBuilder().parse(new File(filename));is returing XmlDocument
    and the printing takes place
    but the in same method public static Document parseXMLFile(String filename, boolean b) in servlet
    the line factory.newDocumentBuilder().parse(new File(filename)); is returning DeferredDocumentImpl
    and this creating problem , had it returned XmlDocument
    i would have printed the elements one one
    but as it is returning deferredimpl
    iam unable to print the elements
    could you please tell me why factory.newDocumentBuilder().parse(new File(filename)); is returning DeferredDocumentImpl
    in servlets but in plain java pogram it is returing XmlDocument
    Thanks
    Bhanu

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How to write as XML file using java 1.5

    hi all,
    i am trying to create an XML file using java 1.5. I took a XML creating java file which was working with java 1.4 and ported same file into java 1.5 with changes according to the SAX and DOM implmentation in java 1.5 and tried to compile. But while writing as a file it throws error "cannot find the symbol."
    can any body help me out to solve this issue.......
    thankx in advance
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.NamedNodeMap;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.DocumentHandler;
    import org.xml.sax.InputSource;
    import org.xml.sax.helpers.ParserFactory;
    import java.io.*;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();                   
                   dbf.setNamespaceAware(true);
    DocumentBuilder db = dbf.newDocumentBuilder();                   
    Document xmlDoc =  db.newDocument();
    // this creates the xml document ref
    // parent node reference
    Element rootnd = (Element) xmlDoc.createElement("ALL_TABLES");
    // root node
    xmlDoc.appendChild(rootnd);
    Element rownd = (Element) xmlDoc.createElement("ROW");
    rootnd.appendChild(rownd);
    Element statusnd = (Element) xmlDoc.createElement("FILE_STATUS");
    rownd.appendChild(statusnd);
    statusnd.appendChild(xmlDoc.createTextNode("Y")
    FileOutputStream outpt = new FileOutputStream(outdir + "//forbranch.xml");
    Writer outf = new OutputStreamWriter(outpt, "UTF-8");
    //error is occuring here Since write method is not available in the Document class
    xmlDoc.write(outf);
    outf.flush();

    Hi,
    when I look in the JDK1.4.2 specification I don't see any write method in the Document interface.
    However, your solution is the Transformer class. There you transform your DOM tree into any output you need. Your code sould look something like this:     TransformerFactory tf = TransformerFactory.newInstance();
         // set all necessary features for your transformer -> see OutputKeys
         Transformer t = tf.newTransformer();
         t.transform(new DOMSource(xmlDoc), new StreamResult(file));Then you have your XML file stored in the file system.
    Hope it helps.

  • String representation of the xml document

    hi, I have created the following xml document using the DOM api. I want to the "function" to return a "string" - which represents the xml document i created. How do u do that?
    As of now it doesnt return anything...
    How do u return the entire xml document as character data..? just like
    <root><elements>data</elements></root>....
    anyhelp would be great.
    import java.io.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.w3c.dom.*;
    public class test1{
    private static void function()throws IOException, DOMException{
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
    DocumentBuilder db = dbf.newDocumentBuilder ();
    Document doc = db.newDocument ();
    Element record = doc.createElement ("record");
    Element name = doc.createElement ("name");
    Element address = doc.createElement ("address");
    Element zip = doc.createElement ("zip");
    Text nameText = doc.createTextNode("bill");
    Text addressText = doc.createTextNode("128, washington");
    Text zipText = doc.createTextNode("10000");
    doc.appendChild(record);
    record.appendChild(name);
    name.appendChild(nameText);
    record.appendChild(address);
    address.appendChild(addressText);
    record.appendChild(zip);
    zip.appendChild(zipText);
    public static void main (String argv [])throws Exception {
    function();
    }

    Brent,
    Looks like you're using the Sun Java Parser. I'll show you how to do it with the Oracle XML Parser and you can extrapolate...
    Document doc = new XMLDocument();
    // Stuff here to build up the DOM Doc
    // with elements, etc.
    // Print the Document to a String
    StringWriter sw = new StringWriter();
    // Wrap the stringwriter in a printwriter
    PrintWriter pw = new PrintWriter(sw);
    // Print to the printwriter
    ((XMLDocument)doc).print(pw);
    // return the string from the stringwriter
    return sw.toString();

  • How to create XML document in Java from scratch ?

    I've downloaded the package generated for my schema.
    Now I'm trying to create a XML Document using the interfaces generated and the
    xmlbeans package. In documentation, all samples start with a call to XmlLoader.load(xmlinput).
    In my case I've no xmlinput, I've only java parameters and i need to produce an
    XML document.
    Could you provide a sample code please ?
    Thanks in advance.

    It looks like you only need to use the xmlText() method from the root of any node
    you want to print out to a file. I used a PrintStream() class and then used the
    ps.print(vpDetails.xmlText()); to save to a file.
    Hope this helps.
    Jerald
    "Eric Vasilik" <[email protected]> wrote:
    >
    To create a new, untyped document:
    XmlObject x = XmlLoader.newInstance();
    To create a new, typed document:
    Map options = new HashMap(
    XmlOptions.DOCUMENT_TYPE,
    CustomerDocument.type );
    CustomerDocument cd = (CustomerDocument) =
    XmlLoader.newInstance( options );
    I have changes pending which will alow you to do this more easily:
    CustomerDocument cd = CustomerDocument.Factory.newInstance();
    - Eric
    "Pascal Fuget" <[email protected]> wrote:
    I've downloaded the package generated for my schema.
    Now I'm trying to create a XML Document using the interfaces generated
    and the
    xmlbeans package. In documentation, all samples start with a call to
    XmlLoader.load(xmlinput).
    In my case I've no xmlinput, I've only java parameters and i need to
    produce an
    XML document.
    Could you provide a sample code please ?
    Thanks in advance.

  • User defined Metadata for XML DB using Java API

    I have been looking through and reading the documentation for Oracle XML DB. I am trying to find out if there is a way to create user define metadata using a Java API. when I look in the XML "Java API Reference (Javadoc)" setProperty(java.lang.String name, java.lang.String value, int type) it states: Sets the specified (single-value) property to the specified value. If the property does not yet exist, it is created. I have tried several ways to do this and have not been successful. I have looked for java examples in the XML DB Developer's Guide, XML Developer's Kit Programmer's Guide.
    Is there a good example out there as to how to create user-defined metadata that can be populated using the JCR API.
    Thanks in advance.

    We need to create the 2 xml schemas, one for request and the other for response of selected operation in the WSDL.
    This we need to do dynamically. There will not be any java classes generated, the xsd files need to be created on the fly.
    Please suggest xml schema creation in this sequence.

  • Getting error while running the XML file using XML Publisher Desktop

    Hi all,
    We have successfully loaded the XML file using XML Publisher Desktop. But when we preview the same using PDF format we are getting the following error.
    Font Dir: C:\Program Files\Oracle\XML Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    RTFProcessor setLocale: en-us
    FOProcessor setData: C:\Documents and Settings\smanmadh\Desktop\ProductCompensationDT.xml
    FOProcessor setLocale: en-us
    java.lang.NullPointerException
         at oracle.apps.xdo.template.fo.area.PageNumber.formatString(PageNumber.java:104)
         at oracle.apps.xdo.template.fo.IDManager.registerId(IDManager.java:44)
         at oracle.apps.xdo.template.fo.area.AreaTree.registerLastPageJoinSeq(AreaTree.java:1106)
         at oracle.apps.xdo.template.fo.area.AreaTree.incrementJoinSequenceIndex(AreaTree.java:219)
         at oracle.apps.xdo.template.fo.area.AreaTree.registerLastPageDocument(AreaTree.java:1089)
         at oracle.apps.xdo.template.fo.area.AreaTree.forceOutput(AreaTree.java:471)
         at oracle.apps.xdo.template.fo.elements.FORoot.end(FORoot.java:58)
         at oracle.apps.xdo.template.fo.FOHandler.endElement(FOHandler.java:386)
         at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:196)
         at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1212)
         at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:301)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:149)
         at oracle.apps.xdo.template.fo.FOProcessingEngine.process(FOProcessingEngine.java:279)
         at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:1022)
         at RTF2PDF.runRTFto(RTF2PDF.java:626)
         at RTF2PDF.runXDO(RTF2PDF.java:460)
         at RTF2PDF.main(RTF2PDF.java:251)
    Thanks in Advance.
    Sudeep.

    This is BI related. You will get a quicker answer from the BI Publisher forum
    BI Publisher

  • Error while running the XML file using XML Publisher Desktop

    Hi All,
    We have successfully loaded the XML file using XML Publisher Desktop.But when we try to preview it using the PDF format we are getting the following error.
    Font Dir: C:\Program Files\Oracle\XML Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    RTFProcessor setLocale: en-us
    FOProcessor setData: C:\Documents and Settings\smanmadh\Desktop\ProductCompensationDT.xml
    FOProcessor setLocale: en-us
    java.lang.NullPointerException
         at oracle.apps.xdo.template.fo.area.PageNumber.formatString(PageNumber.java:104)
         at oracle.apps.xdo.template.fo.IDManager.registerId(IDManager.java:44)
         at oracle.apps.xdo.template.fo.area.AreaTree.registerLastPageJoinSeq(AreaTree.java:1106)
         at oracle.apps.xdo.template.fo.area.AreaTree.incrementJoinSequenceIndex(AreaTree.java:219)
         at oracle.apps.xdo.template.fo.area.AreaTree.registerLastPageDocument(AreaTree.java:1089)
         at oracle.apps.xdo.template.fo.area.AreaTree.forceOutput(AreaTree.java:471)
         at oracle.apps.xdo.template.fo.elements.FORoot.end(FORoot.java:58)
         at oracle.apps.xdo.template.fo.FOHandler.endElement(FOHandler.java:386)
         at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:196)
         at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1212)
         at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:301)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:149)
         at oracle.apps.xdo.template.fo.FOProcessingEngine.process(FOProcessingEngine.java:279)
         at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:1022)
         at RTF2PDF.runRTFto(RTF2PDF.java:626)
         at RTF2PDF.runXDO(RTF2PDF.java:460)
         at RTF2PDF.main(RTF2PDF.java:251)
    Any pointers will be of great help.
    Thanks in Advance
    Sudeep.


    I had a similar error which when I searched, came up with this thread.
    My issue was resolved after I discovered that my RTF template was not really RTF. It was sill in MS Word DOC format. This was discovered by reviewing two templates in NOTEPAD. The MS-DOC files have a lot of "special" characters in them. My RTF was not really RTF.
    After doing a SAVE AS - RTF format, then the preview worked as expected.
    Just Sharing...
    --Tim                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Calculated fields in Sharepoint list view

    Hi, I have to add a calculated field with formula as if the difference between 2 date fields is 0 then i have to add todays date-modifed date. how to achieve this in sharepoint list view/column ? Aruna

  • COM error while submitting certificate request

    Hello there I have created a group and assigned Read, Issue and Manage Certtificate, Manage CA & Request Certificate permission on the CA.When any member of this group try to sign a certificate request, the following error accours. Your request faile

  • 5th Gen Ipod not charging or being seen in my computer

    I have a Dell Latitude D510. My Ipod will not show anything or be seen anywhere on the system. I replaced the battery tow days ago and hoped that might help, but it didn't. Any ideas?

  • I want to upgrade my Imac from tiger 10.4.11 to Mac OS 10.6 Snow Leopard. What is the best way to do this.

    I have just purchased an iphone 4 and it needs me to have the latest itunes on my computer.  I have not upgraded by computer for some time and thought this is probably the time to do it. My computer is an imac intel with Tiger 10.4.11. I want to upgr

  • Time Machine Back up keeps growing

    My 3TB TimeCapsule (not the newest one) reported last week that it was full. It's backing up 4 computers. The biggest chunk (well over half) is my computer with all of our music movies and photos. I tried to delete the sparse bundle for my computer a