Java PI7.1 mapping and standalone NWDS debugging using local XML files

>>which can be debugged in standalone NWDS using local files.
yes its possible...u just have to add static void main (as sugested in the blog) ..
Note: i dont have a system as of now..so i guess there can be some sysntax errors. Please check.
create input xml file with name "input.xml" and place it under "D" drive (it can be any location)
package prasad.NewAPI;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
* @author Prasad Nemalikanti
public class NewAPIJavaMapping extends AbstractTransformation {
public static void main(String[] args) {
          try{
               NewAPIJavaMapping javaMapping =new NewAPIJavaMapping();
               FileInputStream in=new FileInputStream("D:\\input.xml");
               FileOutputStream out=new FileOutputStream("D:\\output.xml");
               javaMapping.execute(in,out);
               catch(Exception e)
               e.printStackTrace();
   String result="";
  /* The transform method which must be implemented */
  public void transform(TransformationInput in,TransformationOutput out) throws StreamTransformationException
    InputStream instream = in.getInputPayload().getInputStream();
  // String for constructing target message structure
    String fresult="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    fresult = fresult.concat("<ns0:MT_Customer xmlns:ns0=\"urn:newapi-javamapping\">");
    try{
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.parse(instream);
        traversingXML(doc);
     catch(Exception e){}
fresult = fresult.concat(result);
fresult = fresult.concat("</ns0:MT_Customer>");
try{
  out.getOutputPayload().getOutputStream().write(fresult.getBytes());
  /* assigning the created target message to "TransformationOutput"*/
   catch(IOException e1){}
/*DOM Parser */
public void traversingXML(Node node)
   NodeList children = node.getChildNodes();
   for(int i=0;i<children.getLength();i++)
     Node child = children.item(i);
     short childType = child.getNodeType();
     if(childType==Node.ELEMENT_NODE)
              String nodeName=child.getNodeName();
              String targetNodeName=null;
              if(nodeName.equals("Users"))
               targetNodeName="Customers";
              else if(nodeName.equals("ID"))
               targetNodeName="CustomerID";
              else if(nodeName.equals("UserName"))
               targetNodeName="Name";
              else if(nodeName.equals("City"))
                targetNodeName="City";
              else if(nodeName.equals("State"))
                targetNodeName="State";
              else if(nodeName.equals("Country"))
                targetNodeName="Country";
             if(targetNodeName!=null)
              result=result.concat("<"+targetNodeName+">");
   traversingXML(child);
   if(targetNodeName!=null)
   result=result.concat("</"+targetNodeName+">");
     else if(childType==Node.TEXT_NODE)
       String nodeValue = child.getNodeValue();
       result = result.concat(nodeValue);

I have tested this and it is working..please chk the same
package com.test;
import java.io.IOException;
import java.io.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class JavaMapping extends AbstractTransformation {
       /* The transform method which must be implemented */
       public void transform(TransformationInput in,TransformationOutput out) throws StreamTransformationException
            this.execute(in.getInputPayload().getInputStream(),
                      out.getOutputPayload().getOutputStream());
       String result="";
       public void execute(InputStream in1, OutputStream out1)
      throws StreamTransformationException {
       // String for constructing target message structure
         String fresult="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
         fresult = fresult.concat("<ns0:MT_Customer xmlns:ns0=\"urn:newapi-javamapping\">");
         try{
             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             DocumentBuilder builder = factory.newDocumentBuilder();
             Document doc = builder.parse(in1);
             traversingXML(doc);
          catch(Exception e){}
      fresult = fresult.concat(result);
      fresult = fresult.concat("</ns0:MT_Customer>");
      try{
       out1.write(fresult.getBytes());
       /* assigning the created target message to "TransformationOutput"*/
        catch(IOException e1){}
      /*DOM Parser */
      public void traversingXML(Node node)
        NodeList children = node.getChildNodes();
        for(int i=0;i<children.getLength();i++)
          Node child = children.item(i);
          short childType = child.getNodeType();
          if(childType==Node.ELEMENT_NODE)
                   String nodeName=child.getNodeName();
                   String targetNodeName=null;
                   if(nodeName.equals("Users"))
                    targetNodeName="Customers";
                   else if(nodeName.equals("ID"))
                    targetNodeName="CustomerID";
                   else if(nodeName.equals("UserName"))
                    targetNodeName="Name";
                   else if(nodeName.equals("City"))
                     targetNodeName="City";
                   else if(nodeName.equals("State"))
                     targetNodeName="State";
                   else if(nodeName.equals("Country"))
                     targetNodeName="Country";
                   if(targetNodeName!=null)
                       result=result.concat("<"+targetNodeName+">");
        traversingXML(child);
        if(targetNodeName!=null)
             result=result.concat("</"+targetNodeName+">");
          else if(childType==Node.TEXT_NODE)
            String nodeValue = child.getNodeValue();
            result = result.concat(nodeValue);
      public static void main(String[] args) {
               try{
                    JavaMapping javaMapping =new JavaMapping();
                    FileInputStream in=new FileInputStream("D:\\Input.xml");
                    FileOutputStream out=new FileOutputStream("D:\\output.xml");
                    javaMapping.execute(in,out);
                    catch(Exception e)
                    e.printStackTrace();
AM

Similar Messages

  • Java.util.Map and  java.util.HashMap samples

    Hi.
    Please, I need some code samples of java.util.Map and java.util.HashMap interfaces. I have problems to retreive objects in the map.
    Cheers,
    Cata

    Try the tutorial:
    http://java.sun.com/docs/books/tutorial/collections/index.html

  • WHERE AND HOW  IS DEBUGGING USED ?

    WHERE AND HOW  IS DEBUGGING USED ? PLEASE GUIDE ME WITH EXAMPLES.
    REWARD POITS GUARENTEED !!

    Hi,
    check these...
    ABAP DEBUGGING
    http://help.sap.com/saphelp_webas620/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9cbb7716-0a01-0010-58b1-a2ddd8361ac0
    Debug Program scheduled Background
    Re: Debugging Report which is scheduled in background
    3 types update,normal and system debugging
    check this for update debugging
    If you set "Update Debbugging" you can debug the codes which works in update tusk.
    SAP std often runs the routine (function or form) to update the database in update tusk mode, these routine start as soon as a commit work is done.
    The commit is called at the end of the program, so you can't debug them by "normal debbugging" because it ends as soon as the program ends
    or----
    All the database updates are performed by the update work processes by calling the functions/subroutines in update tasks.
    These tasks are executed after a commit work is reached in the application. By default you cannot debug these functions.
    TO debug these u need to explicitly activate update debugging.
    for system debugging check the below link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/5f0640555ae369e10000000a155106/content.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/frameset.htm
    For debugging tutorial:
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/5a/4ed93f130f9215e10000000a155106/frameset.htm
    http://www.sapdevelopment.co.uk/tips/debug/debughome.htm
    http://www.sap-basis-abap.com/sapab002.htm
    System Debugging
    If you set this option, the Debugger is also activated for system programs (programs with status S in their program attributes). When you save breakpoints, the System Debugging setting is also saved.
    Update Debugging
    Update function modules do not run in the same user session as the program that is currently running in the ABAP Debugger. These function modules are therefore not included in debugging. Only if you select the Update Debugging option can you display and debug them after the COMMIT WORK.
    Normal Debugging
    Normal debugging is the one we do it by the normal dynamic break points or by /H or by using stattic break points.
    You can switch to diffferent debuggin modes while processing.
    BREAKPOINT
    In the source code we set the Break-point there by clicking the stop button, the system will stop there when you execute the program.
    Watchpoint
    For watchpoints, we need to give some condition and when this condition is satisfied, program will stop
    example : if you want to debug only
    for matnr value 100 than set watch point
    matnr = 100. when value reaches 100 than
    program stops at that point.
    more at
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/617cdce68c11d2b2ab080009b43351/content.htm
    check these documents as well
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/abap-runtime-tools/the%20new%20abap%20debugger%20-%20an%20introduction.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/media/uuid/f720ea47-0801-0010-f7a3-bd37d44fee8d
    here r some links for debugging...
    Go through these threads for more information on debugging,
    1) debugging
    2) debugging
    3) Debugging
    4) Debugging
    some more links .....
    Introduction: http://www.saplinks.net/index.php?option=com_content&task=view&id=24&Itemid=34
    A PDF file to know knowledge about Debugging
    Some more links:
    http://www.sap-basis-abap.com/sapab002.htm
    Debug Background Programs: http://www.sapdevelopment.co.uk/tips/debug/debug_backjob.htm
    Debugger: http://help.sap.com/saphelp_nw2004s/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
    Cheers
    VJ

  • Can I Use a XML file as Managed Resource?

    Hi,
    I have a XML file which has all employee details.
    Can I use that XML file as a Resource in IDM?
    If so please let me know the steps to do.
    Please help me in this regard.
    Thanks
    RMS

    No.
    Since the XML file you have has custom tags, there is not a way for IDM to understand it's contents.
    IDM does offer a "Simulated" resource, which is an XML based resource, but it has a defined structure. You might be able to alter your XML to match what the Simulated Resource expects, or better yet, get it into a database and use the database table adapter.

  • Using an XML file for server URL instead of hard coding

    I can't find a good example.
    Could someone give me an example of using a local XML file to set a server url variable so i don't have to hard code url's?
    This works and i can trace the xml file but how do i access the individual xml data nodes?
    protected function initApp():void
         var loader:URLLoader = new URLLoader(new URLRequest("config.xml"));
         loader.addEventListener(Event.COMPLETE,configLoadComplete);
    private function configLoadComplete(event:Event):void
         trace(event.target.data);

    Hi,
    <a href="foobar.xml">right click and select save as from the context menu</a>
    or
    write your xml data or a copy of it with a different extension (text) so that it is not parsed as application/xml-xhtml
    or
    Use AJAX to retrieve the xml file and display it as the textContent of a <textarea>
    window.open wraps the xml markup in html tags for display purposes.
    Rob^_^

  • Can you use an XML file to make Subclips for you?

    Hi everyone,
    I know this is a bit of a long-shot, but I am wondering if I can use an XML file(made after logging a few tapes, but before capture) to make subclips for me?
    Basically I have a painful project with 2 tapes i had to capture separately as 1 long individual clip each due to time-code breaks, but as i did first Log & Capture as usual (only to later find it wouldn't batch capture) i didn't want my hard work to go to waste!
    Hope I explained that clearly enough,
    Adam
    Message was edited by: Chocboy

    I'm assuming you captured using the non-controllable device setting and have the clip including TC breaks and blank areas etc.
    Try this:
    Load the clip into the Viewer and play it. Press M to set markers wherever you want them.
    If you want to give the marker a more decriptive name, press M a second time whilst the playhead is positioned on the marker. A dialog will open with text input fields. Or, click the marker in the Browser, then click the marker’s name to select it. You can now change the name.
    Drag in the Browser to select all the markers or click the first one, then shift click the last one.
    Choose Modify > Make Subclip. This will make all the subclips in one go and if you gave your markers new names, your subclips will use them.
    The subclips appear in addition to the original clip with the markers. You can rename the subclips, if you want. You can review the subclips, deleting any clips you might not need. If you do remove unused clips, you can use the Media Manager to remove your unused footage from disk, leaving the media for your remaining subclips alone.

  • Using a local XML file for parsing - iPhone

    Good afternoon everyone. I am trying to create an application for the iPhone that will use an XML file for it's data source. I have been attempting to convert the SeismicXML application from the dev center to use a locally stored file, but to no avail. I have it building and running fine, but no data is appearing. Is there anyone that can give me an example of parsing with a locally stored file? Thanks!

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myFile" ofType:@"xml"];
    NSData *myData = [NSData dataWithContentsOfFile:filePath];
    if ( myData ) {
    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:myData];
    [parser setDelegate:myObject];
    [parser setShouldProcessNamespaces:NO];
    [parser setShouldReportNamespacePrefixes:NO];
    [parser setShouldResolveExternalEntities:NO];
    [parser parse];
    NSError *parseError = [parser parserError];
    if ( parseError && error) {
    *error = parseError;
    // Do post load activity

  • ScanNGo - Using localbackup.xml file

    Hi All, Wondering if someone would be able to help us out, we have hundards of CN51's and CN50's through AUS and NZ and have been looking into this ScanNGo barcode system. AUS have successuflly used the .XML file from the localbackup via SOTI Mobicontrol deployment system, but am trying to make it as easy as possible as with SOTI we still need to setup an APN connection before being able to connect to the device, so hence why am looking at the ScanNGo to atleast setup the APN. Searching the forums and I see people have had success in using the ScanNGo creator by using the localback.xml from the SmartSystems folder. Unfortunately this does not seem to work for me, it will scan all 9/9 barcodes from the ScanNGo system but then returns an error "Error reading scanned data into xml" Attached is the localback.xml file from which I can apparently use this file with the ScanNGo barcode creator ? Could someone please correct me if i'm wrong on this. Thanks, Much appreciated.

    Hello AdamD
    first, it is no good idea to apply a full backup xml to a device. You should only change the settings different from factory default. See other posts here about how to create a configuration xml with only changed settings.
    secondly, a backup xml does not contain security data like passwords. So the backup xml does not have the WWAN password(s):
    <Subsystem Name="WWAN Radio">
    <Field Name="ARD Enabled">
    0</Field>
    <Field Name="RadioType">
    2</Field>
    <Field Name="Restore Connection Entry Defaults">
    0</Field>
    <Field Name="Radio Power State">
    1</Field>
    <Field Name="Carrier">
    Worldwide UMTS</Field>
    <Field Name="Carrier Settings Auto Config">
    Enabled</Field>
    <Group Name="Carrier Settings">
    <Field Name="Restore Connection Entry Defaults">
    0</Field>
    <Group Name="Connection Info" Instance="Verizon">
    <Field Name="Connection Name">
    Verizon</Field>
    <Field Name="Phone">
    #777</Field>
    <Field Name="APN"/>
    <Field Name="Username"/>
    <Field Name="Password"/>
    <Field Name="AlwaysOn">
    0</Field>
    </Group>
    <Group Name="Connection Info" Instance="ATT">
    <Field Name="Connection Name">
    ATT</Field>
    <Field Name="Phone"/>
    <Field Name="APN">
    wap.cingular</Field>
    <Field Name="Username"/>
    <Field Name="Password"/>
    <Field Name="AlwaysOn">
    0</Field>
    </Group>
    <Group Name="Connection Info" Instance="Sprint">
    <Field Name="Connection Name">
    Sprint</Field>
    <Field Name="Phone">
    #777</Field>
    <Field Name="APN"/>
    <Field Name="Username"/>
    <Field Name="Password"/>
    <Field Name="AlwaysOn">
    0</Field>
    </Group>
    <Group Name="Connection Info" Instance="Worldwide UMTS">
    <Field Name="Connection Name">
    Worldwide UMTS</Field>
    <Field Name="Phone"/>
    <Field Name="APN">
    Spark</Field>
    <Field Name="Username"/>
    <Field Name="Password"/>
    <Field Name="AlwaysOn">
    1</Field>
    </Group>
    </Group>
    <Group Name="WWAN Information">
    <Field Name="Phone Number">
    Not Available</Field>
    <Field Name="Firmware Revision">
    REVISION 03.001</Field>
    <Field Name="ESN">
    990004190136592</Field>
    <Field Name="IMEI">
    990004190136592</Field>
    <Field Name="IMSI">
    505013475281816</Field>
    <Field Name="Network">
    Telstra Mobile</Field>
    <Field Name="Model">
    PXS8</Field>
    <Field Name="Manufacturer">
    Cinterion</Field>
    </Group>
    </Subsystem>
    As you can see, the "WWAN Information" is nothing to be used for a configiration xml. And you see that there are no passwords.
    AFAIS the only WWAN settings you need to setup the connection is:
    <Group Name="Connection Info" Instance="ATT">
    <Field Name="Connection Name">ATT</Field>
    <Field Name="Phone"/>
    <Field Name="APN">wap.cingular</Field>
    <Field Name="Username"/>
    <Field Name="Password"/>
    <Field Name="AlwaysOn">
    0</Field>
    </Group>
    But keep in mind that you have to maintain the xml structure around this.
    ~josef

  • I have to print two labels using single XML file.Error:Only one top level e

    Hi,
    I have to print two labels using single XML file. But its giving error:
    [Error] Error -1072896683 - Line: 38 Pos: 2 Error: Only one top level element is allowed in an XML document.
    Below is my XMl file:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE labels SYSTEM "label.dtd">
    <labels FORMAT="lib://FRD/PurchasedDoor.btw"  PRINTERNAME="IBM 6700-R80 (300 dpi)" _QUANTITY="1">
    <label>
    <variable name= "Color">AUTUMN</variable>
    <variable name= "Special_Message_Attribute">MSG*</variable>
    <variable name= "Special_Message">This is special Message Label</variable>
    <variable name= "Model"></variable>
    <variable name= "Build_Date">09-APR-12</variable>
    <variable name= "Assy_Cart"></variable>
    <variable name= "Assy_Slot"></variable>
    <variable name= "Finish_Cart"></variable>
    <variable name= "Finish_Slot"></variable>
    <variable name= "Serial_Number">1945.1.1.2-1</variable>
    <variable name= "Serial_Number_Barcode">1945.1.1.2-1</variable>
    <variable name= "Specie">BIRCH</variable>
    <variable name= "Truck_Group"></variable>
    <variable name= "Label_Sequence_No">1</variable>
    <variable name= "WIP_Cart"></variable>
    <variable name= "WIP_Slot"></variable>
    <variable name= "Cabinet_Sequence_No">110</variable>
    <variable name= "JC"></variable>
    <variable name= "Thickness"> </variable>
    <variable name= "Width"> </variable>
    <variable name= "Length"> </variable>
    <variable name= "Overlay"></variable>
    <variable name= "Options">B30</variable>
    <variable name= "Profile_No"></variable>
    <variable name= "Door_Style">NEWBERRY</variable>
    <variable name= "Glaze"></variable>
    <variable name= "Shape"></variable>
    <variable name= "Glass"></variable>
    <variable name= "Hinge_Side"></variable>
    <variable name= "Hinge_Type"></variable>
    <variable name= "EGE"></variable>
    </label>
    <labels FORMAT="lib://FRD/SpecialMessage.btw"  PRINTERNAME="IBM 6700-R80 (300 dpi)" _QUANTITY="1">
    <label>
    <variable name= "Serial_Number">1945.1.1.2-1</variable>
    <variable name= "Special_Message">This is special Message Label</variable>
    <variable name= "Cabinet_Sequence_No">110</variable>
    </label>
    </labels>
    Please suggest.

    >
    XML can only have one root element per file.
    >
    from XML Document: The Root Element

  • Java.util.Map and null key

    Hi,
    For information, according to the implementation, it is possible to put and get a null key when using a map.
    The null key can be added and retrieved when using a HashMap, an exception is thrown for a TreeMap.

    The documentation for java.util.Map states:
    Some map implementations have restrictions on the keys and values they may contain. For example, some implementations prohibit null keys and values, and some have restrictions on the types of their keys. Attempting to insert an ineligible key or value throws an unchecked exception, typically NullPointerException or ClassCastException.The documentation for java.util.TreeMap.put() states:
    Throws:
    NullPointerException - if the specified key is null and this map uses natural ordering, or its comparator does not permit null keysSo a Map generally may or may not support null keys and/or values and the decision is up to the concrete implementation. TreeMap states that it doesn't support null keys, unless a Comparator is used that permits null keys.

  • Using Java, How can I Update, Add, Delete nodes in XML Files.

    Hi,
    I want to store the student record (like Name, Age, school name, total mark etc.,) as nodes in the XMLfile. Also I should able to Update, Add, Delete any nodes (student record) in the XML file. How can I achieve this...using Java
    I am able to read the content of the xml file using xml-parser. But my problem is
    updating the xml file.
    pls suggest some solutions or links with " example source code"
    Thanks :-)

    There are 2 kinds of XML parsers : SAX and DOM. DOM seems to suit your need. You can use JAXP APIs to add, delete or change nodes or attributes.
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/TOC.html provides contents that would satisfy most of the needs.
    To save a DOM modified XML file use java IO APIs to write to the same file from which it was read using a Document object ( doc.getNodeValue() ).

  • Help, how to install jvm and set the classpath using a batch file

    hello,
    i have created my java application and now have to create an installable / batch file which will install the JVM on the users machine and also the java packages such as javamail and the class files that i have created . it also has to set the classpath.
    i would like to know if anyone can tell me how to go about iti.e. how can i install the JVM using a batch file and then place the javamial packages etc in the apropriate directory .
    or is it advisable to explain it to the user how to go about it in tht user manual.
    and would also like to know that if i install the JVM will the path for the java.exe be set
    or will i have to set the path explicitly from the "batch file" so that the user can run the application without and problem just by running the java command followed by filename from the command prompt.

    hi,
    I have windows and I use it.
    The only problem with the free edition is that you can only create 1 launcher and that during the installation you get 1 popup showing that the installer was created with an unregistered version.
    Stijn

  • Reading an XML file and write the contents to another xml file in java

    Hi,
    I am new to xml parsing.My requirement is that I am getting a message (xml) using ibm MQ in the ByteArrayInputStream format.I have to read this xml message and write to another file.
    I am creating a POC for this.
    First I used simple reading and writing concept but the output is "java.io.FileInputStream@3e25a5 "
    Sample xml file
    - <Client>
    <ClientId>1234</ClientId>
    <ClientName>STechnology</ClientName>
    <DTU_ID>567</DTU_ID>
    <ClientStatus>ACTIVE</ClientStatus>
    - <LEAccount>
    <ClientLE>678989</ClientLE>
    <LEId>56743</LEId>
    - <Account>
    <AccountNumber>9876543678</AccountNumber>
    </Account>
    </LEAccount>
    - <Service>
    <Cindicator>Y2Y</Cindicator>
    <PrefCode>980</PrefCode>
    <BSCode>876</BSCode>
    <MandatoryContent>MSP</MandatoryContent>
    </Service>
    </Client>
    code:
    import java.io.ByteArrayInputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class ByteArrayInputStreamToXml {
         public static void main(String srg[]) throws IOException{
              InputStream inputStream= new FileInputStream("C:\\soft\\test2\\sample1.xml");
              byte currentXMLBytes[] = inputStream.toString().getBytes();
              ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLBytes);
              OutputStream out = new FileOutputStream("C:\\soft\\test\\data.xml");
              int read=0;
              byte[] bytes = new byte[1024];
              while((read = byteArrayInputStream.read(bytes))!= -1){
              out.write(bytes, 0, read);
              out.write( '\n' );
              inputStream.close();
              out.flush();
              out.close();
              System.out.println("New file created!");
    Please suggest me how can I use DOM/SAX parser ,I can see several code on net for reading xml file using SAX/DOM parser but writing an xml file after reading it using ByteArrayInputStream I am not getting .A help through some example Link will also be helpful for me.
    Thanks
    Sumit
    Edited by: user8687839 on Apr 30, 2012 2:37 AM
    Edited by: user8687839 on Apr 30, 2012 2:43 AM

    Thanks I got the result.
    package com.sumit.collections;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class ByteArrayInputStreamToXml {
         public static void main(String srg[]) throws IOException{
              InputStream inputStream= new FileInputStream("C:\\soft\\test2\\sample1.xml");
              ByteArrayOutputStream buffer = new ByteArrayOutputStream();
              int nRead; byte[] data = new byte[1024];
              while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
              buffer.write(data, 0, nRead); } buffer.flush();
              byte currentXMLBytes[]= buffer.toByteArray();
              /* byte currentXMLBytes[] = inputStream.toString().getBytes();*/
              ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLBytes);
              OutputStream out = new FileOutputStream("C:\\soft\\test\\data.xml");
              int read=0;
              byte[] bytes = new byte[1024];
              while((read = byteArrayInputStream.read(bytes))!= -1){
              out.write(bytes, 0, read);
              out.write( '\n' );
              inputStream.close();
              out.flush();
              out.close();
              System.out.println("New file created!");
    }

  • Re:using an XML file in Web Dynpro for java

    Hi all,
    I have pasted an xml file in Mimes->Components and my file name is Doc_List.xml after that i have done some manipulations using that file like this
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              DocumentBuilder db = dbf.newDocumentBuilder();
                                   Document doc = db.parse("//Doc_List.xml");
              String name = "description";
              NodeList nlst = doc.getElementsByTagName("name");
              Node node= nlst.item(0).getFirstChild();
              //node.setNodeValue(name);
                         String a = node.getNodeValue();
                                    wdComponentAPI.getMessageManager().reportSuccess(a);
    the exception iam getting is java.io.FileNotFoundException: /Doc_List.xml (No such file or directory)

    Hi,
       Place your xml file under the path src/mimes/Components/<your component name>. Then use the following code to read it:
    String xmlUrl = WDURLGenerator.getResourcePath
                                   (wdComponentAPI.getComponent().getDeployableObjectPart(),
                                    "FileName.xml"
    if(xmlUrl != null){
       Document doc = DocumentBuilderFactory.newInstance()
                                            .newDocumentBuilder()
                                            .parse(new File(xmlUrl));
       doc.getDocumentElement ().normalize ();
       // do further processing...
    Regards,
    Satyajit

  • How can I disable windows firewall and install cluster software and its service using unattended.xml file?

    platform: 2008r2
    services which need install: MSDTC Service, Windows Cluster Service, SQL Cluster

    Hi,
    I am not quiet understanding your question, could you clarify your question, as far as I know, an answer file is an XML-based file that contains setting definitions and values
    to use during Windows Setup. In an answer file, you specify various setup options, including how to partition disks, the location of the Windows image to install, and the product key to apply. You can also specify values that apply to the Windows installation,
    such as names of user accounts, display settings, and Internet Explorer favorites. The answer file for Setup is typically called Unattend.xml.
    The related KB:
    Building an Answer File
    http://technet.microsoft.com/en-us/library/cc748874(v=ws.10).aspx
    Hope this helps.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

Maybe you are looking for

  • How do I install CS5 on new iMac without a disc drive, if remote installation isn't working?

    I purchased CS5 for my laptop (Macbook Pro 2007 I believe) and now have the newest iMac without a disc drive.  I have tried remote installation, but it did not work.  I attempted to copy the installation files onto a USB and then transfer them, howev

  • Why is the Address Book app slow to update my contacts?

    When I try to import my Google contacts into my Mac Address Book via vCard (.vcf) format, Address Book app takes an eternity to finish updating (like a half hour or more), during which I cannot do anything else in the Address Book. The last time I tr

  • Allow users to Download documents from server

    Hello Everybody, I am working on an Flex application where I have to allow the users to Open/Save documents such as Word document, Excel sheet, PDFs, Jpeg, Media files (any digital format document) when a user clicks on a link present in a Flex appli

  • How do i get messenger mac to work?

    How do i get messenger mac to work?  I have amcbook 10.5 os x and it has never worked for me.

  • LrKeyword getAttributes not returning all data

    Hi, I've been trying to use LrKeyword.getAttributes() to get the keyword flags as detailed in the SDK, but the only value returned is "includeOnExport". There also seems to be no way to get the values for "Export Containing Keywords" and "Export Syno