XML file generation in Java

Hello,
I'm using XML files to communicate two systems. The XML files fulfill a W3C Schema.
I want to know if there is any Java library, API or something like this, to generate automatically XML files that fulfill a schema, giving the schema file and the data to fill the XML file.
Thanks,
Laura.

Please use the code tags when posting code, as described in the formatting tips.
http://forum.java.sun.com/help.jspa?sec=formatting

Similar Messages

  • How to read the contents of XML file from my java code

    All,
    I created an rtf report for one of my EBS reports. Now I want to email this report to several people. Using Tim's blog I implemented the email part. I am sending emails to myself based on the USERID logic.
    However I want to email to different people other then me. My email addresses are in the XML file.
    From the java program which sends the email, how can I read the fields from XML file. If any one has done this, Please point me to the right examples.
    Please let me know if there are any exmaples/BLOG's which explain how to do this(basically read the contents of XML file in the Java program).
    Thank You,
    Padma

    Ike,
    Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
    Please help me.
    Thank you for your posting.
    Padma.

  • How to read an XML file into a java program?

    hi,
    i want to load the following very simple xml file in my java program.
    <root>
    <weblogic>
    <url value="t3://192.168.1.160:7001" />
    <context value="weblogic.jndi.WLInitialContextFactory" />
    </weblogic>
    </root>
    I am getting the error: " Line=1: cvc-elt.1: Cannot find the declaration of element 'root'."
    What might be the problem can anyone help me out.
    My java class code is:
    public class BIXMLReader {
    /** All output will use this encoding */
    static final String outputEncoding = "UTF-8";
    // Parses an XML file and returns a DOM document.
    // If validating is true, the contents is validated against the DTD
    // specified in the file.
    public static Document parseXmlFile(String filename, boolean validating) {
    try {
    // Create a builder factory
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setIgnoringComments(false);
    factory.setIgnoringElementContentWhitespace(false);
    factory.setCoalescing(false);
    factory.setValidating(validating);
    // Create the builder and parse the file
    System.out.println("filename = " + filename);
    DocumentBuilder db = factory.newDocumentBuilder();
    // Set an ErrorHandler before parsing
    OutputStreamWriter errorWriter = new OutputStreamWriter(System.err, outputEncoding);
    db.setErrorHandler(new MyErrorHandler(new PrintWriter(errorWriter, true)));
    Document doc = db.parse(new File(filename));
    System.out.println(doc.toString());
    return doc;
    } catch (SAXException e) {
    System.out.println("A parsing error occurred; the xml input is not valid. " + e.getMessage());
    } catch (ParserConfigurationException e) {
    System.out.println("Parser configuration exception has occured");
    } catch (IOException e) {
    System.out.println("IO Exception has occured " + e.getMessage());
    return null;
    // Error handler to report errors and warnings
    private static class MyErrorHandler implements ErrorHandler {
    /** Error handler output goes here */
    private PrintWriter out;
    MyErrorHandler(PrintWriter out) {
    this.out = out;
    * Returns a string describing parse exception details
    private String getParseExceptionInfo(SAXParseException spe) {
    String systemId = spe.getSystemId();
    if (systemId == null) {
    systemId = "null";
    String info = "URI=" + systemId +
    " Line=" + spe.getLineNumber() +
    ": " + spe.getMessage();
    return info;
    // The following methods are standard SAX ErrorHandler methods.
    // See SAX documentation for more info.
    public void warning(SAXParseException spe) throws SAXException {
    out.println("Warning: " + getParseExceptionInfo(spe));
    public void error(SAXParseException spe) throws SAXException {
    String message = "Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);
    public void fatalError(SAXParseException spe) throws SAXException {
    String message = "Fatal Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);
    }

    ok thanks, i can get the elements, but why did it not validate it?
    I want to read the child nodes of "weblogic" not by their name but by their index. Because i dont want to confine the reader so i want to read all the child nodes of weblogic (looping over them). i m doing the following but its not returning me the correct result and giving me the wrong count of child nodes.
    Element elementNode = (Element)doc.getElementsByTagName("weblogic").item(0);
    NodeList nodeList = elementNode.getChildNodes();
    int length = nodeList.getLength();
    System.out.println("length = "+ length); // the length its giving is 5 but i shuld get only 2
    for(int i=0; i < length; i++) {
    Element elmChild = (Element) nodeList.item(i);
    System.out.println(elmChild.getAttribute("value"));
    what might be the problem?

  • Error in XML file generation :240416

    Hi All,
    I am facing problem with XML file generation.
    Steps:
    1. Source-->Query Transform and maintained Nested Stucture
    2. Generated XML fomat from query transform
    3. Created XML format file
    4. Make XML format as target and given XML generate path
    source table-->Query(nested structure)-->XML Format
    when I validate the job no errors found.
    Note: XSD file is in Local mechine and XML file will be generated in SFTP.
    Prooblems:
    1. Getting below error
    The input XML refers to file which is not part of the definition of this XML Schema format. Check your schema and XML files,
    and check that the root element in the XML file corresponds to the root element in the XML Schema
    Validate your XML Schema using external schema validators (found at w3.org)
    Thanks,
    Deepa

    Hi,
    I think issue Because in your Query Transform output the Root element is Query and XML target is having some other root element. Make the Query trasform name similar to root element and try...

  • Web.xml file generation problem

    Hi,
    I am trying to create web.xml file automatically using "java weblogic.marathon.ddinit.WebInit
    " command.
    I got the following message in the command prompt:
    Found Web components. Initializing descriptors
    filters=0 servlets=0 tags=0
    Above command is creating the web.xml and weblogic.xml files but it is not including
    the servlet-mapping information. why?
    Thanks,
    Prakash

    It doesn't look like it found any servlets. You'd have to show me your
    files if I'm to understand what's going on.
    -- Rob
    Prakash wrote:
    Hi,
    I am trying to create web.xml file automatically using "java weblogic.marathon.ddinit.WebInit
    " command.
    I got the following message in the command prompt:
    Found Web components. Initializing descriptors
    filters=0 servlets=0 tags=0
    Above command is creating the web.xml and weblogic.xml files but it is not including
    the servlet-mapping information. why?
    Thanks,
    Prakash

  • Create .xml file from a java file

    I wanted to know how can we create a .xml file through java with the given data.
    For example: book saler.
    data given through java are
    1)Sl no
    2)Book name
    3Book type
    4)Book price
    i want a xml file generated through the java code
    can anyone help me out?

    i have done like this..
    but the problem with this is i want to add more than one book details. i am able to add only one book detais..
    package name:createxml
    main class:GenerateOrderXml.java
    CreateXml.java and order.java
    package createxml;
    import java.util.Vector;
    public class GenerateOrderXml {
         public static void main(String[] args) {
              try{
              Order order= new Order();
              CreateXml xml=new CreateXml();
              Vector orders=new Vector();
              order.setBookName("Java_for_beginers");
              order.setAuthorName("Balaguruswamy");
              order.setISBN("a123");
              order.setNo_of_copies("3");
              order.setprice("350");
              order.setPublisher("Deepak publishers");
              orders.add(0,order);
              order.setBookName("Java");
              order.setAuthorName("Bala");
              order.setISBN("a123");
              order.setNo_of_copies("3");
              order.setprice("350");
              order.setPublisher("Deepak ");
              orders.add(1,order);
              xml.creatxml(orders);
              catch(ArrayIndexOutOfBoundsException e)
                   e.printStackTrace();
    package createxml;
    import org.jdom.*;
    import org.jdom.output.XMLOutputter;
    import java.io.IOException;
    import java.util.Vector;
    * @author divyashree
    * To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Generation - Code and Comments
    public class CreateXml {
         public void creatxml(Vector orders)
         try
                   Element root = new Element("BookSaler");          
                   Order order= new Order();          
                   order=(Order)orders.elementAt(0);
                   Element BName = new Element("Bookname1");
                   BName.setText(order.getBookName());
                   root.addContent(BName);
                   Element AName = new Element("Authorname");
                   AName.setText(order.getAuthorName());
                   BName.addContent(AName);
                   Element isbn = new Element("ISBN");
                   isbn.setText(order.getISBN());
                   BName.addContent(isbn);
                   Element price = new Element("Price");
                   price.setText(order.getprice());
                   BName.addContent(price);
                   Element publisher= new Element("Publisher");
                   publisher.setText(order.getPublisher());
                   BName.addContent(publisher);
                   order=(Order)orders.elementAt(1);
                   Element BName1 = new Element("Bookname2");
              BName1.setText(order.getBookName());
              root.addContent(BName1);
              Element AName1 = new Element("Authorname");
              BName1.addContent(AName);
              Element isbn1 = new Element("ISBN");
              isbn.setText(order.getISBN());
              Element price1 = new Element("Price");
              BName1.addContent(price);
              Element publisher1= new Element("Publisher");
              BName1.addContent(publisher);
              Document doc = new Document(root);
              try {
                   XMLOutputter serializer = new XMLOutputter();
                   serializer.setIndent(" ");
                   serializer.setNewlines(true);
                   serializer.output(doc, System.out);
              catch (IOException e)
                   System.err.println(e);
         }catch(ClassCastException e)
              e.printStackTrace();
    package createxml;
    import java.util.Vector;
    public class Order {
         protected String ISBN="";
         protected String BookName="";
         protected String AuthorName="";
         protected String No_of_copies;
         protected String price;
         protected String Publisher="";
         public String getISBN()
              return this.ISBN;
         public String getBookName()
              return BookName;
         public String getAuthorName()
              return AuthorName;
         public String getNo_of_copies()
              return No_of_copies;
         public String getprice()
              return price;
         public String getPublisher()
              return Publisher;
         public void setISBN(String isbn)
              Vector vec_isbn= new Vector();
              ISBN=isbn;
         public void setBookName(String bookname)
              BookName=bookname;
         public void setAuthorName(String authorname)
              AuthorName=authorname;
         public void setNo_of_copies(String no_of_copies)
              No_of_copies=no_of_copies;
         public void setprice(String Price)
              price=Price;
         public void setPublisher(String publisher)
              Publisher=publisher;
    /***************************************************************************/

  • Parse of a xml file to an java object model

    Hello,
    I'm trying to do a program that receive an xml file and ought to create all the neccesary java objects according to the content of the parsed xml file.
    I've all the class created for all the objects that could be present into the xml and the idea is to go down in the tree of nodes recursively until it returns nodes more simple. Then, I create the last object and while I come back of the recursively calls, I create the objects more complex until I reached to the main object.
    Until now, I have part of this code, that is the one wich have to parse the parts of the xml.
    public static void readFile(String root){
              DocumentBuilderFactory factory = DocumentBuilderFactory
                   .newInstance();
              try {
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   Scanner scanner = new Scanner(new File(root)).useDelimiter("\\Z");
                   String contents = scanner.next();
                   scanner.close();
                   Document document = builder.parse(new ByteArrayInputStream(contents.getBytes()));
                   Node node = null;
                   NodeList nodes = null;
                   Element element = document.getDocumentElement();
                   System.out.println(element.getNodeName());
                   NodeList subNodes;
                   NamedNodeMap attributes;
                   //if (element.hasAttributes())
                   visitNodes(element);
              } catch (ParserConfigurationException e) {
                   e.printStackTrace();
              } catch (SAXException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
         private static void visitNodes (Node node){
              for(Node childNode = node.getFirstChild(); childNode!=null;){
                   if (childNode.getNodeType() == childNode.DOCUMENT_NODE){
                        System.out.println("Document node Name " + childNode.getNodeName());
                        visitNodes(childNode);
                   }else if (childNode.getNodeType() == childNode.ELEMENT_NODE){
                        System.out.println("Node Name " + childNode.getNodeName());
                        if (childNode.hasAttributes()){
                             visitAttributes(childNode.getAttributes());
                        if (childNode.hasChildNodes()){
                             visitNodes(childNode);
                   }else if (childNode.getNodeType() == childNode.TEXT_NODE && !childNode.getNodeValue().contains("\n\t")){
                        System.out.println("Node value " + childNode.getNodeValue());
                   Node nextChild = childNode.getNextSibling();
                   childNode = nextChild;
         private static void visitAttributes(NamedNodeMap attributes){
              Node node;
              for(int i = 0; i < attributes.getLength(); i++){
                   node = attributes.item(i);
                   System.out.print(node.getNodeName() + " ");
                   System.out.print(node.getNodeValue() + " ");
                  }I don't know the use of childNodeType. For example, I expected that the XML tags with childs in his structure, enter by the option NODE_DOCUMENT and the tags without childs by the ELEMENT_NODE.
    But the most important problem I've found are the nodes [#text] because after one ELEMENT_NODE I always found this node and when I ask if the node hasChilds, always returns true by this node.
    Has any option to obtain this text value, that finally I want to display without doing other recursively call when I enter into the ELEMENT_NODE option?
    When one Node is of type DOCUMENT_NODE or DOCUMENT_COMMENT? My program always enter by the ELEMENT_NODE type
    Have you any other suggestions? All the help or idea will be well received.
    Thanks for all.

    Hello again,
    My native language is Spanish and sorry by my English I attemp write as better I can, using my own knowledge and the google traductor.
    I have solved my initial problem with the xml parser.
    Firstly, I read the complete XML file, validated previously.
    The code I've used is this:
    public static String readCompleteFile (String root){
              String content = "";
              try {
                   Scanner scanner = new Scanner(new File(root)).useDelimiter("\\Z");
                   content = scanner.next();
                   scanner.close();
              } catch (IOException e) {
                   e.printStackTrace();
              return content;
         }Now, I've the file in memory and I hope I can explain me better.
    I can receive different types of XML that could be or not partly equals.
    For this purpose I've created an external jar library with all the possible objects contained in my xml files.
    Each one of this objects depend on other, until found leaf nodes.
    For example, If I receive one xml with a scheme like the next:
    <Person>
        <Name>Juliet</Name>
        <Father Age="30r">Peter</Father>
        <Mother age="29">Theresa</Mother>
        <Brother>
        </Brother>
        <Education>
            <School>
            </school>
        </education>
    </person>
    <person>
    </person>The first class, which initializes the parse, should selecting all the person tags into the file and treat them one by one. This means that for each person tag found, I must to call each subobject wich appears in the tag. using as parameter his own part of the tag and so on until you reach a node that has no more than values and or attributes. When the last node is completed I'm going to go back for completing the parent objects until I return to the original object. Then I'll have all the XML in java objects.
    The method that I must implement as constructor in every object is similar to this:
    public class Person{
      final String[] SUBOBJETOS = {"Father", "Mother", "Brothers", "Education"};
      private String name;
         private Father father;
         private Mother mother;
         private ArrayList brothers;
         private Education education;
         public Person(String xml){
           XmlUtil utilXml = new XmlUtil();          
              String xmlFather = utilXml.textBetweenXmlTags(xml, SUBOBJETOS[0]);
              String xmlMother = utilXml.textBetweenXmlTags(xml, SUBOBJETOS[1]);
              String xmlBrothers = utilXml.textBetweenMultipleXmlTags(xml, SUBOBJETOS[2]);
              String xmlEducation = utilXml.textBetweenXmlTags(xml, SUBOBJETOS[3]);
              if (!xmlFather.equals("")){
                   this.setFather(new Father(xmlFather));
              if (!xmlMother.equals("")){
                   this.setMother(new Father(xmlMother));
              if (!xmlBrothers.equals("")){
                ArrayList aux = new ArrayList();
                String xmlBrother;
                while xmlBrothers != null && !xmlBrothers.equals("")){
                  xmlBrother = utilXml.textBetweenXmlTags(xmlBrothers, SUBOBJETOS[2]);
                  aux.add(new Brother(xmlBrother);
                  xmlBrothers = utilXml.removeTagTreated(xmlBrothers, SUBOBJETOS[2]);
                this.setBrothers(aux);
              if (!xmlEducation.equals("")){
                   this.setEducation(new Father(xmlEducation));     
    }If the object is a leaf object, the constructor will be like this:
    public class Mother {
         //Elements
         private String name;
         private String age;
         public Mother(String xml){          
              XmlUtil utilXml = new XmlUtil();
              HashMap objects = utilXml.parsearString(xml);
              ArraysList objectsList = new ArrayList();
              String[] Object = new String[2];
              this.setName((String)objects.get("Mother"));
              if (objects.get("attributes")!= null){
                   objectsList = objects.get("attributes");
                   for (int i = 0; i < objectsList.size();i++){
                     Object = objectsList.get(i);
                     if (object[0].equals("age"))
                       this.setAge(object[1]);
                     else
         }Each class will have its getter and setter but I do not have implemented in the examples.
    Finally, the parser is as follows:
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.HashMap;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import org.xml.sax.SAXException;
    public class XmlUtil {
         public HashMap parsearString(String contenido){
              HashMap objet = new HashMap();
              DocumentBuilderFactory factory;
              DocumentBuilder builder;
              Document document;
              try{
                   if (content != null && !content.equals("")){
                        factory = DocumentBuilderFactory.newInstance();
                        builder = factory.newDocumentBuilder();
                        document = builder.parse(new ByteArrayInputStream(content.getBytes()));
                        object = visitNodes(document);                    
                   }else{
                        object = null;
              } catch (ParserConfigurationException e) {
                   e.printStackTrace();
                   return null;
              } catch (SAXException e) {
                   e.printStackTrace();
                   return null;
              } catch (IOException e) {
                   e.printStackTrace();
                   return null;
              return object;
         private HashMap visitNodes (Node node){
              String nodeName = "";
              String nodeValue = "";
              ArrayList attributes = new ArrayList();
              HashMap object = new HashMap();
              Node childNode = node.getFirstChild();
              if (childNode.getNodeType() == Node.ELEMENT_NODE){
                   nodeName = childNode.getNodeName();                    
                   if (childNode.hasAttributes()){
                        attributes = visitAttributes(childNode.getAttributes());
                   }else{
                        attributes = null;
                   nodeValue = getNodeValue(childNode);
                   object.put(nodeName, nodeValue);
                   object.put("attributes", attributes);
              return object;
         private static String getNodeValue (Node node){          
              if (node.hasChildNodes() && node.getFirstChild().getNodeType() == Node.TEXT_NODE && !node.getFirstChild().getNodeValue().contains("\n\t"))
                   return node.getFirstChild().getNodeValue();
              else
                   return "";
         private ArrayList visitAttributes(NamedNodeMap attributes){
              Node node;
              ArrayList ListAttributes = new ArrayList();
              String [] attribute = new String[2];
              for(int i = 0; i < attributes.getLength(); i++){
                   atribute = new String[2];
                   node = attributes.item(i);
                   if (node.getNodeType() == Node.ATTRIBUTE_NODE){
                        attribute[0] = node.getNodeName();
                        attribute[1] = node.getNodeValue();
                        ListAttributes.add(attribute);
              return ListAttributes;
    }This code functioning properly. However, as exist around 400 objects to the xml, I wanted to create a method for more easily invoking objects that are below other and that's what I can't get to do at the moment.
    The code I use is:
    import java.lang.reflect.Constructor;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    public class UtilClasses {
         public Object UtilClasses(String package, String object, String xml){
              try {
                Class class = Class.forName(package + "." + object);
                //parameter types for methods
                Class[] partypes = new Class[]{Object.class};
                //Create method object . methodname and parameter types
                Method meth = class.getMethod(object, partypes);
                //parameter types for constructor
                Class[] constrpartypes = new Class[]{String.class};
                //Create constructor object . parameter types
                Constructor constr = claseObjeto.getConstructor(constrpartypes);
                //create instance
                Object obj = constr.newInstance(new String[]{xml});
                //Arguments to be passed into method
                Object[] arglist = new Object[]{xml};
                //invoke method!!
                String output = (String) meth.invoke(dummyto, arglist);
                System.out.println(output);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
              return null;
         }This is an example obtained from the Internet that I've wanted modified to my needs. The problem is that when the class calls this method to invoke the constructor and does not fail, this does not do what I expect, because it creates an empty constructor. If not, the parent class gives a casting error.
    I hope that now have been more clear my intentions and that no one has fallen asleep reading this lengthy explanation.
    greetings.

  • Basic doubt about XML file generation

    Hi,
    I am new to Java. I am facing some trouble designing and implementing a particular problem involving XML files.
    Problem:
    I have an XML file which contains a set of properties and their default value. What I need to do is to read another file/stream which will have name=value strings and then, for all the names that I find there, change default value to current value. These names can appear in any order. For example,
    <name1 value=default1/>
    <name2 value=default2/>
    <name3 value=default3/>
    And I will get something like "set name3=value3 name1=value1" (This data comes to me from a stream -usb device- and not from a file). Then I should change it to
    <name1 value=value1/>
    <name2 value=default2/>
    <name3 value=value3/>
    What is the best possible way to do this in Java? This has to go into an embedded system so it will be nice if it can be done with minimum memory and less processing power.
    I am currently reading J2EEtutorial (1.4). I have not read much. But I am confused if I should be using SAX, DOM or XSLT. To speak the truth, I don't even know the difference between all those. Any help will be greatly appreciated.
    Thanks & Regards,
    Suseelan

    Use a DOM parser to parse the original XML.
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
    Document document = domBuilder.parse( inputStreamToFile );Then read in the contents from your USB stream into say an array or Vector. Then go through each child node in the domBuilder class, get the nodes name and see if it's in the Vector of objects from the USB stream. If it is, then replace the "Value" attribute in the dom node with what is in the Vector.
    Make sense?
    Message was edited by:
    bryano

  • Generate XML file dynamically using java

    Hi,
    I searched on this topic on the net and also in this forum but everything leads to parsing an existing file using JAXP technology. But i need to create an xml file dynamically from the data coming from a different source. I can do it manually by writting the content to a file. But i am sure there is a better way for it. I would be obliged if some one could give me and example java class which produces a simple xml file or direct me to any resource online.
    Thank you in advance.

    Yes you can create the xml file dynamically. Like this,
    BufferedWriter bw = new BufferedWriter(new FileWriter("xyz.xml"));
    bw.write(buffer.toString()); //where buffer is StringBuffer whcih contains the your xml data
    bw.close();
    Remember to close the BufferedWriter, otherwise it will create the file but don't write anything.
    Hope this will help u.
    ....yogesh

  • EXPORT.XML file used during Java export?

    Hi all !!!
    I'm doing an export of a Solution Manager 7.01 system. This system also has a CPS (redwood) installation in thev database java schema.
    What happened was that not all tables listed in the EXPORT.XML existed, so I got a failure.
    I then "undeployed" CPS, and deleted all CPS files from the database (JCS_). However, when I restarted (or started from the beginning) I got the same error. The EXPORT.XML (in the export java directory) still have all the JCS_ tables listed.
    This file is recreated during every restart, so I tested to create a script which override this file with one without the JCS_* tables all the time (more than 100 times a minute). But the export still has the JCS_* tables in the list during export.
    So is the EXPORT.XML even used during export, or does it keep the values in memory already when the file is created.
    And a second question is: From where does the input to the EXPORT.XML file come from? It's not from the database since there is not a trace of any JCS_* tables in the database however ju list information from the DB2 dictionary (DB2 9.5.2)
    So can anyone tell me how to skip these tables from the export?
    // Claes

    Hello Claes,
    is this system (CPS) a copy or migration of other system ? it happens sometimes that old schema tables remains in the system.
    regards, Javier

  • Is there any way to generate pdf from an xml file using single java class

    i m working on generating a pdf file from an xml file. i want to use only a single java class to do so. if theres any such code available please help me to find out.
    Thanks
    Gurpreet Singh

    exactly,
    here are some libraries which are open sources;
    http://java-source.net/open-source/pdf-libraries hope it's useful. :D

  • How to compare two huge xml files(50MB+) using Java Code

    I want to compare two huge xml files using java code and need to find the difference of those xml files
    is there any API for that

    You should find third party API

  • XML File Generation Issues using DBMS_XMLGEN

    Hi,
    I am using DBMS_XMLGEN package in a stored procedure to generate an XML file on Oracle 10 G R2 .But, the problem is the format in which the file is generated.
    CREATE OR REPLACE TYPE "state_info" as object (
    "@product_type" Number
    CREATE OR REPLACE TYPE prod_tab as TABLE OF "state_info";
    CREATE OR REPLACE TYPE state_t as object (
    "state_code" CHAR(2),
    "state_info" prod_tab
    CREATE OR REPLACE PROCEDURE get_xml_serviced_state (p_clob OUT clob)
    IS
    v_xmlctx DBMS_XMLGEN.ctxhandle;
    v_str VARCHAR2 (1000);
    BEGIN
    v_str := 'SELECT state_t(a.st_cd,CAST(MULTISET(select veh_type_id from svcd_st where st_cd =a.st_cd)as prod_tab)) as "state_info"
    from svcd_st a where a.st_cd in (select distinct st_cd from svcd_st) group by a.st_cd having count(*)>=1';
    v_xmlctx := DBMS_XMLGEN.newcontext (v_str);
    DBMS_XMLGEN.setrowsettag (v_xmlctx,'serviced_state');
    DBMS_XMLGEN.setrowtag (v_xmlctx,NULL);
    p_clob := DBMS_XMLGEN.getxml (v_xmlctx);
    printclobout(p_clob);
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    RAISE;
    END;
    SHOW ERRORS
    Output :
    <serviced_state>
    <state_info state_code="VA">
    <state_info>
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </state_info>
    <state_info state_code="AB">
    <state_info>
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </state_info>
    </serviced_state>
    Required it in below format:
    <serviced_state>
    <state_info state_code="VA">
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    <state_info state_code="AB">
    <state_info product_type="2"/>
    <state_info product_type="5"/>
    <state_info product_type="9"/>
    </state_info>
    </serviced_state>
    I just need to put in all the rows under one single tag.Appreciate your early responses.
    Thanks.

    Your wanted XML output is NOT VALID...(try it yourself on http://tools.decisionsoft.com/schemaValidate/)

  • Wait XML File Generation and Present in APEX

    Hi All,
    I need advice on how can I implement following -
    I will be creating Input XML file using database procedure called from APEX, which will then go and executed the call using web services and create output XML file in one of the output directory. What I need help is -
    1. Once execute the initial call, then I need to be keep looking for file under output directory. Once the file is generated then I can show it on APEX, but I would like to know how can I implement, so continuously watch the directory for the file and as soon as file generated pick that file and present on APEX and stop watching directory for file.
    2. Also APEX will be used by many users concurrently, so how can I create and direct unique file for their own sessions, so myfile should not go to another user?
    Please advice

    There are lots of thread on ingesting XML and generating XML in this forum. Have a read through some of them and you should get some ideas on where to start. In particular look for threads on rcreating elational views of XML documents and using the SQL/XML Operators

  • XML File generation and watching continuously on directory present on APEX

    Hi All,
    I need advice on how can I implement following -
    I will be creating Input XML file using database procedure called from APEX, which will then go and executed the call using web services and create output XML file in one of the output directory. What I need help is -
    1. Once execute the initial call, then I need to be keep looking for file under output directory. Once the file is generated then I can show it on APEX, but I would like to know how can I implement, so continuously watch the directory for the file and as soon as file generated pick that file and present on APEX and stop watching directory for file.
    2. Also APEX will be used by many users concurrently, so how can I create and direct unique file for their own sessions, so myfile should not go to another user?
    Please advice

    Hi Keith
    11g uses the EPG so the images are stored in the database, however are also accessible as a webfolder. This is the same as (or very similar to) XE which I've previously successfully installed this on. The files have been uploaded to the images directory as I'm able to reference /i/sample.html in the iframe successfully. I've never needed to change the .xml file and run apxldimg script, a simple copy and paste has always worked. However, I will try this just to make sure.
    Hi Denes
    I've tried putting in the absolute path of the directory, which I assume you mean the full path i.e. http://localhost:8080/images/charts_library. But this makes no difference. I know there are differences with 11g, the EPG and that you have to open http://localhost:8080/images/ as a web folder rather than http://localhost:8080/i/ to access the files in the images directory. However, the database that your example application on http://htmldb.oracle.com is running on is an 11g database. It's running 11.1.0.6.0 the same as my database, so it must be possible and by the fact you didn't know this I assume you didn't need to make any changes to make it work!
    Sara

Maybe you are looking for