Creating xml within java app

Hi,
I have reached a situation where I have to create small pieces of xml (around 8k characters) within my java app. Right now I am using stringbuffer to create the xml which does not go against a dtd. This is working for now, since I do not have to read in the xml again.
But if I wanted to use some other xml utility like xerces or jdom, is it recommended for my use of xml or would it be an overkill. Please let me know.
Thanks.
tP

I am in a similar situation. See my earlier post today . However I am yet to start the design. Can you please pass me your email and we can be in touch? My email is [email protected]
Thanks

Similar Messages

  • Creating XML in java

    hi all,
    I am trying to create xml files from java, however I receive the following errors when trying to marshall:
    02:23:24.967 [classloader] sharenotes/jaxb.properties -> null
    02:23:24.967 [classloader] META-INF/services/javax.xml.bind.JAXBContext -> null
    02:23:24.968 [classloader] com.sun.xml.internal.bind.v2.ContextFactory
    02:23:24.970 [classloader] sharenotes/jaxb.index -> null
    "sharenotes" doesnt contain ObjectFactory.class or jaxb.indexhelloworold
    My code looks like this:
    public static boolean marshallToFile(String filename, Annotation ann)
    try
    FileOutputStream stream = new FileOutputStream(filename);
    System.out.println(stream);
    JAXBContext jc = JAXBContext.newInstance( "sharenotes" );
    System.out.println(jc);
    Marshaller marshaller = jc.createMarshaller();
    //marshaller.marshal(ann, stream);
    marshaller.marshal( new JAXBElement(new QName("","Annotation"), Annotation.class, ann ), stream);
    stream.close();
    catch(Exception ex)
    System.out.println(ex.getMessage() + "helloworold");
    return false;
    return true;
    Basically, I am using javascript which calls the methods in java which create the xml files. When I run this as an application in java, everything works fine!
    Can someone please help?!?!
    Kind regards
    Chris

    Novice_Ashish wrote:
    want create an XML file for the same
    Ashishplease elaborate your needs,
    if you need to deal with xml
    then xerces

  • Add ability to create bookmarks within iOS app

    It would be great to have the ability to create bookmarks within the iOS reader app. That way I can go directly from a PDFs download via website/Dropbox and not have to first edit the document on my computer to add any bookmarks.
    Acrobat Reader for iOS

    To Demo:
    My main email address linked to the mail app in my iPad is with Yahoo.  When I add a test group on my iCloud, my iPad keeps asking for my Yahoo password repeatedly and no sync seems to have taken place.  Can't understand why.  Might have to troubleshoot a little bit more.
    I agree that it is a pain to add a group of names individually and I generally use the Gmail on the notebook for the Gmail app - much easier and faster too.
    It appears that the standard mail app is geared towards individual personal mail rather than for professional use.  Even then...it could have been better.
    Thanks guys for all your input.  Looks like there is no solution within the standard mail/contact apps in the immediate future other than using other apps to supplement.

  • Starting notepad.exe from within Java app?

    Is it possible to start notepad.exe from within a java app to display a log file (for instance)?

    search the forum for Runtime.getRuntime()

  • Creating XML from java Code

    Hello @ll,
    I need a java code to convert XML file ,which has one node to again a XML file with multiple nodes,depends on the content of source XML File....
    The source structure is something like this:
    <Name>abcd;xyzw;prs</Name>
    and the target structure is something like:
    <FirstNAme>abcd</FirstNAme>
    <MidNAme>xyzw</MidName>
    <LastName>prs</LastName>
    the length of the data is not fixed. and ";" is used as a seperator.
    I have hundred such nodes on the target side.
    How do i acheive this
    Thanks in Advance.
    With Regards,
    BVS

    DEVELOPEMENT-THRILL wrote:
    hi ,
    what i think he can convert the xml to java object by using xstream then he can do his desired work in java and again he can convert it to xml by using xstream again.
    RegardsAn enormous waste of time, though. His "desired" work doesn't need any Java at all, beyond maybe kicking off the transform. Seriously, you've given some poor advice - as we all do from time to time - just accept it rather than try to justify it in retrospect. One of the biggest mistakes you can make as a developer is to use the same tool for everything simply because you already know how to. XSLT and XPath are enormously useful tools to have kicking about, and pretty trivial to learn as well. What could take dozens of lines of Java to achieve could take a single XPath query. Which would you prefer?

  • Automatic Creation of ODBC Data Source From Within Java App

    Good Day Good People :)
    I was wondering if it were possible for a java application to automatically set up an ODBC data source for a JDBC connection in a windows environment.
    This is the method I call to initialise a connection to my database:
    public void initialiseLocalConnection ()
    url = "jdbc:odbc:ICUDB";
    try
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    icuCon = DriverManager.getConnection (url);
    catch (Exception e)
    JOptionPane.showMessageDialog (null, "Error Creating Connection to ICU Database!\n" +
    "Please set up an ODBC data source pointing\n" +
    "to the icudb.mdb file located in the data\n" +
    "folder of the ICU directory and call the\n" +
    "connection 'ICUDB'.", "Database Connection Error", JOptionPane.ERROR_MESSAGE);
    Is it possible to create the ODBC data source ICUDB if it does not exist from within my application.
    All information regarding the possibilty and the application of doing this would be greatly appreciated.
    Kind Regards
    Matt

    Thank you.
    During my search I for dsn-less connections I found the soloution:
    url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" +
    System.getProperty ("user.dir") + System.getProperty ("file.separator") +
    "data" + System.getProperty ("file.separator") + "icudb.mdb";
    try
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    icuCon = DriverManager.getConnection (url);
    This works.
    Thanks for the replies.
    Matt :)

  • Creating links within a app

    Hi,
    I want to add link to my iphone app as 'Buy Now' and on clicking this link it will directly link to our company's website where users can buy our apps.
    Is this feature possible in iphone and are there some restrictions in doing so ?.
    Thanks,
    Radhika

    Apps for the iPhone can only be sold through the iTunes Store. You are not allowed to host apps on your own site, if that's what you mean, nor could they be loaded on any customer's iPhone without the customer jailbreaking the iPhone.
    If, however, what you mean is that you want to have a link on your web site to your app in the iTunes Store, you can use the Link Maker tool that Apple provides for the purpose:
    http://itunes.apple.com/linkmaker/
    You could similarly include such a link within one of your apps to point to another of your apps, I would assume, again assuming that the app is in the iTunes Store.
    If this doesn't answer your question, please post back and clarify what it is you wish to do.
    Regards.

  • Handle SOAP req within JAVA APP.

    Hi expert,
    My self Preet, I have to built JAVA Application to handling charging over SOAP protocol.
    I have XML format, where 4-5 parameters and dynamically change and some are static.
    As now, I am using JAVA API, which calls URL (made in DOT net) with dynamic parameters code of DOT net made XML format and post this to operator and respond that status to my JAVA API.
    But I want to remove the dependency of that DOT NET's code so pls help me to making JAVA API to handle SOAP req and there response too.
    Regards,
    Preet
    91-98033-33356

    Unless you work for a Big company no one will know and
    Sun definitely will not care. I've spoken will reps at Sun about this. Gulp!
    White collar crime, including time theft, probably exceeds all other crime, at least in the US. And at least in some circumstances some employees are lead to believe by other individuals that such practices are SOP. However, even if directly order to take such action by a boss it certainly doesn't free you from criminal prosecution and at best only allows for a defense in a civil proceding.
    Professionally I won't allow nor condone practices that break criminal or civil precendents.
    Personally I refuse to follow orders or suggestions that break criminal or civil precendents. Nor will I allows others to do so in my presence. Doing so opens me up to prosecution. I certainly would never do that for a job.
    Delivering the jdk to a customer is simply a matter of convenience. At the very least doing that exposes one personally to firing for cause. After all if your boss doesn't specifically order you (in writing) to do this who do you think will get the blame? In addition all parties involved, your current employer, the customer and Sun could potentially try to sue you. Even if you win, the legal costs would be staggering. How much money are you willing to spend for convenience?
    If you are so sure about the word of the 'reps' then I would suggest that you get one of them to put it in writing (not email.) Even better get more than one.
    If you want a customer to use this then simply have the customer download the jdk. And actually I expect that the legalities would probably be fulfilled if you were acting as an agent for the customer (but that status depends on the contract with the customer.) You do have to download it for them though (not as yourself.)

  • Creating XML in Webdynpro

    Hi All,
    I'm developing a webdynpro component. On click of submit in action I want to create a xml file.
    Can anyone tell me how can we achieve this.
    Regards,
    Nilesh.

    Hi,
    I guess the following links will help you in creating XML.
    http://java.sun.com/xml/tutorial_intro.html
    http://www.cafeconleche.org/books/xmljava/
    http://www.javaworld.com/jw-03-2000/jw-03-xmlsax.html
    http://developers.sun.com/sw/building/codesamples/dom/index.html
    import org.w3c.dom.Document;
    Main class for DOM Sample
    public class DOMSample {
    File name of Order
      static String orderFileName = "Order.xml";
    @param args the command line arguments
      public static void main(String[] args) {
        Document document = null;
        Order order = null;
        out("\nConstruct document using DOM in memory, save to file, and print it");
        // Build new DOM Document
        CreateOrderDOM cDOM = new CreateOrderDOM();
        document = cDOM.getDocument();
        out("New Order created");
        // Print XML content
        DOMUtil.printDOM(document);
        // Write to a file
        DOMUtil.writeXmlToFile("newOrder.xml",document);
        out("\n\nThe New Order stored to NewOrder.xml");
        // Create Order object based on Document
        order = new Order(document);
        out("\n\nPrint the Order's summary");
        order.print();
        out("\n\nConstruct document using existing XML Order," +
                          " apply discount, insert Tax and Total info to the" +
                          " Order, save to file, and print it");
        // Read XML from file to DOM
        document = DOMUtil.parse("Order.xml");
        if (document != null){
          // Print XML content
          out("\nPrint XML from file");
          DOMUtil.printDOM(document);
          // Get Order Price
          order = new Order(document);
          out("\nPrint the Order's summary");
          order.print();
          //Calculate total Items in Order
          int count = DOMUtil.countByTagName("Item",document);
          out("\nNumber Items in Order: " + count);
          out("Check for Discount");
          // Check for Discount
          if (order.isDiscount()){
            out("Apply Discount");
            order.applyDiscount();
          out("\nResult Order");
          order.print();
          // Add Tax and Total to the Order XML
          order.AddTaxAndTotal();
          // Print XML content
          out("\nPrint XML that include Tax and Total");
          DOMUtil.printDOM(document);
          // Write to a file
          DOMUtil.writeXmlToFile("DiscountOrder.xml",document);
          out("\n\nThe Order modified and stored to DiscountOrder.xml");
    Prints to the System output a message
    @param message String
      private static void out(String message) {
        System.out.println(message);

  • Run Java app on Time

    I've created a standalone Java app that must run at certain times in the day, can anyone recommend how the best way to do this is, its going to run on a windows box!!

    i would suggest you get some scheduler to do this for you. windows comes with one of these (programs > accessories > System Tools > Scheduled Tasks)

  • Creating XML file from Java Bean

    Hi
    Are there any standard methods in Java 1.5 to create XML file from java bean,
    i can use JAXB or castor to do so,
    But i would like to know if there is any thing in java core classes,
    I have seen XMLEncoder, but this is not what i want.
    Any ideas
    Ashish

    Marshall JavaBean to an XML document with JAXB or XMLBeans.

  • Creating a custom java module for excel to xml conversion.

    Hi Gurus,
    I am creating a custom java module in sap nwds 7.3 for Excel to XML Conversion. But I am getting following error
    Classpath dependency validator message.
    Classpath entry  will not be exported or published. Runtime ClassNotFoundExceptions may result. 
    I imported the Jars from a different PI system and i am using NWDS in local PC with creating a separate folder with all JARs and also imported them using build path option.
    This issue is occuring for all the jars imported.
    I am using following code.
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.AbstractTrace;
    import java.util.HashMap;
    import jxl.Cell;
    import jxl.Workbook;
    public class JavaMappingExcelToXML implements StreamTransformation{
    private Map map = null;
    private AbstractTrace trace = null;
    public void setParameter(Map arg0) {
    map = arg0; // Store reference to the mapping parameters
    if (map == null) {
    this.map = new HashMap();
    public static void main(String args[]) { //FOR EXTERNAL STANDALONE TESTING
    try {
    FileInputStream fin = new FileInputStream ("c:/ashu.xls"); //INPUT FILE (PAYLOAD)
    FileOutputStream fout = new FileOutputStream ("C:/Users/ashutosh.a.upadhyay/My Documents/ashuXML2.xml"); //OUTPUT FILE (PAYLOAD)
    JavaMappingXLStoXML mapping = new JavaMappingXLStoXML ();
    mapping.execute(fin, fout);
    catch (Exception e1) {
    e1.printStackTrace();
    public void execute(InputStream inputstream, OutputStream outputstream) {
    String msgType = "Message Type name will come here";
    String nameSpace = "Namespace Name will come here";
    String xmldata = "";
    try {
    Workbook wb = Workbook.getWorkbook(inputstream);
    xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ "<ns0:"+msgType+" "+"xmlns:ns0=\""+nameSpace+"\n">";
    Cell[] cells ;
    Cell[] cellNames ;
    cellNames = wb.getSheet(0).getRow(0);
    for(int j=1;j<wb.getSheet(0).getRows();j++){
    xmldata = xmldata+"\n<Record>\n";
    cells = wb.getSheet(0).getRow(j);
    for(int i=0;i<wb.getSheet(0).getColumns();i++){
    xmldata = xmldata+"\t<"+cellNames[i].getContents()+">"+cells[i].getContents()+"</"+cellNames[i].getContents()+">\n";
    xmldata = xmldata+"</Record>";
    xmldata = xmldata+"\n</ns0:"+msgType+">";
    System.out.print(xmldata);
    xmldata.getBytes();
    wb.close();
    byte by[] = xmldata.getBytes();
    outputstream.write(by);
    inputstream.close();
    outputstream.close();
    System.out.println("\n"+"File processed");
    catch (Exception e) {
    e.printStackTrace();
    Request you to guide how to resolve this issue.
    Thanks  in advance

    Hi Gurus,
    I am creating a custom java module in sap nwds 7.3 for Excel to XML Conversion. But I am getting following error
    Classpath dependency validator message.
    Classpath entry  will not be exported or published. Runtime ClassNotFoundExceptions may result. 
    I imported the Jars from a different PI system and i am using NWDS in local PC with creating a separate folder with all JARs and also imported them using build path option.
    This issue is occuring for all the jars imported.
    I am using following code.
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.AbstractTrace;
    import java.util.HashMap;
    import jxl.Cell;
    import jxl.Workbook;
    public class JavaMappingExcelToXML implements StreamTransformation{
    private Map map = null;
    private AbstractTrace trace = null;
    public void setParameter(Map arg0) {
    map = arg0; // Store reference to the mapping parameters
    if (map == null) {
    this.map = new HashMap();
    public static void main(String args[]) { //FOR EXTERNAL STANDALONE TESTING
    try {
    FileInputStream fin = new FileInputStream ("c:/ashu.xls"); //INPUT FILE (PAYLOAD)
    FileOutputStream fout = new FileOutputStream ("C:/Users/ashutosh.a.upadhyay/My Documents/ashuXML2.xml"); //OUTPUT FILE (PAYLOAD)
    JavaMappingXLStoXML mapping = new JavaMappingXLStoXML ();
    mapping.execute(fin, fout);
    catch (Exception e1) {
    e1.printStackTrace();
    public void execute(InputStream inputstream, OutputStream outputstream) {
    String msgType = "Message Type name will come here";
    String nameSpace = "Namespace Name will come here";
    String xmldata = "";
    try {
    Workbook wb = Workbook.getWorkbook(inputstream);
    xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ "<ns0:"+msgType+" "+"xmlns:ns0=\""+nameSpace+"\n">";
    Cell[] cells ;
    Cell[] cellNames ;
    cellNames = wb.getSheet(0).getRow(0);
    for(int j=1;j<wb.getSheet(0).getRows();j++){
    xmldata = xmldata+"\n<Record>\n";
    cells = wb.getSheet(0).getRow(j);
    for(int i=0;i<wb.getSheet(0).getColumns();i++){
    xmldata = xmldata+"\t<"+cellNames[i].getContents()+">"+cells[i].getContents()+"</"+cellNames[i].getContents()+">\n";
    xmldata = xmldata+"</Record>";
    xmldata = xmldata+"\n</ns0:"+msgType+">";
    System.out.print(xmldata);
    xmldata.getBytes();
    wb.close();
    byte by[] = xmldata.getBytes();
    outputstream.write(by);
    inputstream.close();
    outputstream.close();
    System.out.println("\n"+"File processed");
    catch (Exception e) {
    e.printStackTrace();
    Request you to guide how to resolve this issue.
    Thanks  in advance

  • Creating XML file in Project folder thru Java Program

    hi,
    i need one help. i need to create XML file in web://<Project Folder> in xmII thru Java Program. i created one java code and i am able to access XML file that is in c drive. i created jar file for this and placed as action block in Transaction and this working fine. but problem arises when i give file path in java code as web://<folder name>/file.xml which is in Web folder of project in xMII.
    How to access the file that is inside web folder from java code.
    regards
    senthil

    Hi Senthil,
    you can address the files that inside the MII workbench are viewed as "web://..." like this:
    http://<server>:<port>/XMII/CM/<Project>/<Folder>/<Filename>
    The workbench helps you find the correct filename:
    - open the WEB tab in the workbench
    - right-click on the filename
    - select "Copy Link" from the pop up
    Now you have the correct link in your clipboard.You can use the "web://" only inside MII.
    Michael

  • How create plugins in java and access then from the app

    How can I create plugins for a Java app. And how do I need in my app to access those plugins??

    Generally speaking, any sort of plugin is simply an implementation of some defined or set of defined interfaces that is loaded at runtime and invoked based on some event, configuration or other such mechanism. Java plugins can be implemented simply as .jar or individual classes that implement the interface(s). The application loads these (perhaps using separate, specifically defined class loaders) and is responsible for knowing how and when to invoke their method(s).
    The trick, of course, is defining the interfaces to be supported by the app and implemented by the plugin and to define a set of events, etc. that would cause these to be invoked. The mechanics of loading the classes, instatiating the instances as need, etc. is fairly basic Java programming.
    Chuck

  • Can I create a java app for my palm zire 71 that uses floating point calc

    I am an eclipse user that is looking at studio creator 2 and was wondering if I could create a java app for my palm zire 71. I have read alot about no floating point support in midp... is that true for java on the palm? If so, how does one calculate with floats and doubles to do sqrt functions etc?
    Thanks in advance for your time
    Dean-O

    I looked at netbeans and it does not support floating points in midlets. Not good for palm app if no floating point ability. J2ME supports floating point but in netbeans... is uses midlets and there are no floating points. Now what does one do? Not that dreaded C++
    THanks in advance
    Dean-O

Maybe you are looking for

  • Plzz help!!6680 not connecting to my PC using data...

    I've installed PC Suite 6.7.But it says no phone is connected even after I connected both the PC and the mobile phone to the cable.When I press the get connected prompt and press button "NEXT" in the next window , then an error message says: "THERE I

  • Boolean value mapping in udb

    UDB does not support bit data types to my knowledge... what is a recommended way to map a boolean value to a udb database?

  • HT201317 Photo stream number of photos is not the same depending which device I use

    Why do I see different quantity of photos from different devices when I go to my photo stream? From my iPhone i see ~618, while from my ipad I see less than that (~570) Thanks

  • Ctrl+Alt+F1 while in X - how to get back? [SOLVED]

    Hey there! How do I get back into X after switching out with Ctrl+Alt+F1 without aborting X by Ctrl+C though? I searched the forums for "get back into x ctrl+alt+f1" without success. Thanks in advance! Solution: Press Alt +F7 Last edited by Thoht (20

  • Authorization Of Purchase Documents

    Hi Gurus, In workflow of Purchase document authorization, one system generated mail is automatically sent to the official mail box of the persons who are releasing the documents. My question is, can we make in SAP that not only mails are going to tho