Increment values within XML document and generate new file

Good day Gurus of the Java World,
I have a XML file and would like to generate a 100 unique files of this one file.
The tags that need to be unique are UniqueID (alpha numeric field), TranAmount (numeric filed) and RefNumber (alpha numeric field).
The rest of the tags can remain as is.
How do I go about doing this? Please assist.
<Payment>
<UniqueID>48a6bd92-19c8-11e2-a2ba-000000000000</UniqueID>
<EffectiveDate>20121018</EffectiveDate>
<TranCode>1000</TranCode>
<TranAmount>000000000123456</TranAmount>
<TranDate>20121018</TranDate>
<TranTime>014532</TranTime>
<Check></Check>
<DrCrInd>CR</DrCrInd>
<Name>ABC</Name>
<BrCode>1234</BrCode>
<RefNumber>SALARYWAGE</RefNumber>
<AccNumber>123456789</AccNumber>
<BackoutCount>0</BackoutCount>
</Payment>

1. Parse the document into a DOM.
2. Modify the nodes which you said you wanted modified.
3. Serialize the DOM to a new document.
4. Repeat steps 2 and 3 as required.

Similar Messages

  • Validating a XML document and skipping new lines ??

    Hi everybody !
    I'm currently developping a new application and the configuration is done within a XML file. My problem is that I'm using IP addresses and so users have to write things like this :
    <agentIP>
    132.137.43.2
    </agentIP>
    and I have a problem with the Java SAX parser : in fact I have declared the type of agentIP in a XML Schema like this :
    <xs:simpleType name="IPAddress">
    <xs:restriction base="xs:string">
    <xs:pattern value="((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){3}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>
    </xs:restriction>
    </xs:simpleType>and the problem is that if there are some white spaces before the IP or some new lines (in fact the user can format this XML file in different manners), I have a parsing error because the parser interprets these characters too.
    Has somebody any idea how to tell the parser to skip these characters ???
    for information here is my source code :
    ErrorHandler errorHandler = new MyErrorHandler();
        content.setLength(0);
        agentTable = new AgentTable();
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(true);
        SAXParser saxParser = null;
        try {
          saxParser = factory.newSAXParser();
        catch (ParserConfigurationException ex1) {
          ex1.printStackTrace();
        catch (SAXException ex1) {
          ex1.printStackTrace();
        try {
          saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
          try {
            saxParser.setProperty(
                "http://java.sun.com/xml/jaxp/properties/schemaSource",
                new org.xml.sax.InputSource(jamap.share.Constants.networkMap));
          catch (SAXNotRecognizedException ex4) {
          catch (SAXNotSupportedException ex4) {
        catch (SAXNotSupportedException ex3) {
          ex3.printStackTrace();
        catch (SAXNotRecognizedException ex3) {
          ex3.printStackTrace();
        org.xml.sax.XMLReader xmlReader = null;
        try {
          xmlReader = saxParser.getXMLReader();
        catch (SAXException ex) {
          ex.printStackTrace();
        xmlReader.setContentHandler(this);
        xmlReader.setErrorHandler(errorHandler);
        //    xmlReader.setProperty(
        //      "http://apache.org/xml/properties/schema/external-schemaLocation",
        //    new File("http://localhost:8080/agentfile.xml"));
        //xmlReader.setErrorHandler (new (ErrorHandler()));
        try {
          xmlReader.parse(new org.xml.sax.InputSource(jamap.share.Constants.homeDir +
                                                      jamap.share.Constants.
                                                      AgentFile));
        catch (SAXException ex2) {
          ex2.printStackTrace();
          System.out.println("Please correct your XML file !");
        catch (IOException ex2) {
          ex2.printStackTrace();
          System.out.println("Error in parsing the agent.xml file");
        return agentTable;
      public void startElement(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName,
                               Attributes attributes
                               ) throws
          SAXException {
        if (qName.equals("proxy")) {
          isAgentViaProxy = true;
        content.setLength(0);
      public void characters(char[] chars, int start, int len) throws SAXException {
        content.append(chars, start, len);
      public void ignorableWhitespace(char[] ch,
                                      int start,
                                      int length) throws SAXException {
        System.out.println("Some white spaces were ignored !");
      }and here the XML Schema used:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="IPAddress">
      <xs:restriction base="xs:string">
        <xs:pattern value="((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){3}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>
      </xs:restriction>
    </xs:simpleType>
    <xs:element name='networkMap'>
      <xs:complexType>
       <xs:sequence>
         <xs:element ref='agent' minOccurs='0' maxOccurs='unbounded'/>
       </xs:sequence>
      </xs:complexType>
    </xs:element>
    <xs:element name="agent">
      <xs:complexType>
       <xs:sequence>
         <xs:element name="ipAddress" type="IPAddress" minOccurs="1" maxOccurs="1" />
         <xs:element name="proxy" type="IPAddress" minOccurs="0" maxOccurs="1" />
       </xs:sequence>
      </xs:complexType>
    </xs:element>
    </xs:schema>THANK YOU...
    PA

    Hi !
    I've found the solution finally and as nobody wrote me I'll explain it...
    Basically to ignore white spaces you need to specify it within your XML Schema : here is an example of a possible description for an IPv6 address inside an XML schema :
    <xs:simpleType name="IPv6Address">
      <xs:restriction base="xs:string">
       <xs:whiteSpace value="collapse" fixed="true"/>
       <xs:pattern value="((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){7}(1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>
      </xs:restriction>
    </xs:simpleType>as you can see <xs:whiteSpace value="collapse" fixed="true"/> is solving the problem !!
    Bye..
    PA
    http://www.doffoel.com

  • Convert flat file to XML document and store into Oracle database

    First:
    I have a flatfile and created external table to read that file in Oracle
    Now I want to create an XML document for each row and insert into Oracle database, I think that XMLtype.
    Could you please provide me some information/steps.
    Second:
    Is there performance issues, because everyday I need to check that XML document stored in the database against the in coming file.
    Thank You.

    Oracle 11g R2 Sun Solaris
    Flat file is | (pipe delimited), so I did create an EXTERNAL Table
    row1     a|1|2|3|4
    row2     b|2|3|4|5
    row3     c|6|7|8|9
    I want to store each record as XML document. So it will be easy to compare with next day's load and make insert or update.
    The reason is:
         First day the file comes with 5 columns
         after some days, the file may carry on some additional columns more than 5
         In this case I do not want to alter table to capture those values, if I use XML than I can capture any number of columns, CORRECT!. Please make me correct If I am wrong.
         This is the only reason to try to use the XMLType (XML Document)
         On Everyday load we will be matching these XML documents and update it if there is any column's value changes
    daily average load will be 10 millions and initial setup will be 60-80 millions
         Do I have anyother option to capture the new values without altering the table.
    Please advise!.

  • Use DOM to get the element value of XML document?

    I can not to use the method getNodeValue to get the element value of XML document. How can I do for it?
    For example, for element
    <address>125 Smith Avenue</address>
    how to get the value "125 Smith Avenue" by using DOM?
    Thanks

    Thanks for all of you.
    The code indicates that I need to get the node by tag name. If I do not know the distribution of the elements and want to traverse all nodes. If the node contains value, I retrieve the value. How to implement the general case.
    For example, my XML file represent a directory hierarchy and looks like
    <root>
    <usr>
    <user>user1
    <file>file1</file>
    <file>file2</file>
    </user>
    <user>user2
    <file>file1</file>
    <file>file2</file>
    <file>file3</file>
    <file>file4</file>
    </user>
    </usr>
    </root>

  • Pages 5.2 - When I try to reorder different pages it just takes all the pages within the document and turns them into a stack! Why is this happening and how can I oder pages as the update is meant to let me?

    When I try to reorder different pages it just takes all the pages within the document and turns them into a stack! Why is this happening and how can I oder pages as the update is meant to let me?
    Any Help?I know the update has only been out a while but if anyone has an idea why it is doing this, please let me know!

    But you are telling me something I already know.
    Be precise.
    It is not Pages '09 that is broken.
    I am back in Mavericks and testing Pages 5.2.
    There are improvements, we shall see how useful, but in less than a minute I have already discovered bugs.
    Peter

  • Is the transformation between XML document and 2 dimensions table important?

    To everyone:
    I am trying to write a paper on this topic.first ,i want to ask whether the transformation between XML data and table in RDBMS is important,because xml data is suitable to transfer from a point to another,but not for storage,so when the transfer begin a program(in DB2,the program is DB2 extender)should change the data format in table into a xml document.And vice versa,the destination point receive the xml document,maybe the same program would store it in table.
    so i wonder if such a program exists in the Oracle8i or later version,and the detail about how the program realizes above funciton.please tell me where can i find related paper or materials.
    thanks!

    To everyone:
    I am trying to write a paper on this topic.first ,i want to ask whether the transformation between XML data and table in RDBMS is important,because xml data is suitable to transfer from a point to another,but not for storage,so when the transfer begin a program(in DB2,the program is DB2 extender)should change the data format in table into a xml document.And vice versa,the destination point receive the xml document,maybe the same program would store it in table.
    so i wonder if such a program exists in the Oracle8i or later version,and the detail about how the program realizes above funciton.please tell me where can i find related paper or materials.
    thanks! That is all oracle XDK is for. You can transform query results to xml and xml back into RDBMS. Infact Oracle provides much more flexible way than a DB2 extender does. In DB2 you need to give a DAD before you get any XML. Oracle relies on the direct transformation of query results into XML and adds flexibility of XSL ontop of the data.
    You can get more information on XML technology section of OTN.
    Once you write the article can we get a chance to see it.

  • Is it possible to lock a layer within a document and password protect that specific layer?

    Is it possible to lock a layer within a document and password protect that specific layer?

    As stated, no way to do exactly what you want, but an option might be to turn OFF Visibility for that Layer, if you do not want it seen, and then Flatten, and do a Save_As.
    If you do want that Layer seen, but not able to be edited, then Flatten, with Visibility ON, and Save_As.
    The question is, do you want the recipient to see that Layer, or not?
    Next, Do they need to be able to edit all other Layers, but just not that one?
    Last, what type of Layer is it?
    Good luck,
    Hunt

  • Mixing two mp3 files and generating new mp3 file in java

    HI,
    I have problem, I have 2 mp3 files I have some defined times for both file. On particular time i want to mix both mp3 file sound and generate new mp3 file by mixing audio from both files.
    As i am new to mp3 in java , Please guide me from where should i start or any other good suggestion.
    Thanks & Regards
    Akhnukh

    Thanks a lot for ur reply....
    But my actual task is to mix two mp3 files and generate a new file where in i should be able to list the two mp3 files playing simultaniously......
    So can u please help me in writing the j2me code for mixing of two mp3 files.....
    Thank u very much
    Navya

  • Unable to display tree view; Error when parsing an XML document (Premature end of file.)

    Hi folks,
    I am using a cascaded mapping in my OM. I have a graphical mapping followed by the Java mapping. It is a flat file to IDOC mapping. Everything works fine in Dev but when I transport the same objects to QA, the Operation mapping though it doesn't fail in ESR testing tool, gives the following message and there is no output generated for the same payload which is successfully tested in DEV. Please advise on what could be the possible reasons.
    Unable to display tree view; Error when parsing an XML document (Premature end of file.)

    kalyan,
    There seems to be an invalid xml payload which causes this error in ESR not generating the tree view. Please find the similar error screenshot and rectify the payload.
    Mutti

  • I need a help to generate new file

    Hi Guys
    I need your help. I have two text box in my form, the first one takes the file name to read, and then when user type in another file name in the second textbox, result should be saved as a typed file name in the same path.
    What I really want to do is, when the file is exist already (for instance, I'll name it as result.txt), my program scan through the result.txt file and append the new data at the end of the file. But result.txt file doesn't exist, it has to generate new file and save the data into the new one. I think I need to implement these in the OpenFile1() function, but I dont' know how.
    Does anybody have idea to solve this?
    private void saveFile() {
    textArea.append("SAVE FILE\n---------\n");
    if (openFile1())
         try {
              outputToFile();
    catch (IOException ioException) {
              JOptionPane.showMessageDialog(this,"Error Writing to File",
                   "Error",JOptionPane.ERROR_MESSAGE);
    private boolean openFile1 ()
         // Display file dialog box
    title=textfield1.getext();
    path=fileName_in.getPath();
         File file_out = new File(path, title);
    if (fileName_out == null || fileName_out.getName().equals("")) {
         JOptionPane.showMessageDialog(this,"Invalid File name",
                   "Invalid File nmae",JOptionPane.ERROR_MESSAGE);
         return(false);
         else {
    try
    boolean created = file_out.createNewFile();
    if(true)
    fileOutput = new PrintWriter(new FileWriter(fileName_out));
    return(true);
    else
    catch (IOException exc) {
    System.err.println("# Error: " );
    private void outputToFile() throws IOException
    // Initial output
         textArea.append("File name = " + fileName_out + "\n");
         //process();
         // Test if data exists
         if (data != null)
         Date now = new Date();
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
    String s = df.format(now);
    //long nowlong=now.getTime();
    fileOutput.println(s);
    fileOutput.print(fileName_in.getName() +" of slope value:" + slope);
    textArea.append("File output complete\n\n");
         else
    textArea.append("No data\n\n");
         // End by closing file
         fileOutput.close();
    Thank you so much!

    There's a lot of unnecessary code there, and anyway it isn't formatted in a readable way so I am not going to look too closely at it. But if you want to append to the file if it already exists and create the file if it doesn't, then all you need is this: fileOutput = new PrintWriter(new FileWriter(fileName_out, true));Note the "true" parameter there which (if you look in the API documentation) says that new data will be appended at the end of the file.

  • Trying to save a document with a new file name

    I have a IMacOSX Lion
    I am very new to apple products
    How do I save an existing document with a new file name thereby having two documents the old one and the new one with changes? Once a document has been saved once opening File no longer offers the save or Save as choice. Clicking on Save a version does not work either. Please help!

    What application are you using?
    Most Apple apps have adopted a new file saving scheme for what you describe. In Pages, for instance, you go to the File menu and select Duplicate. You end up with two documents, one labeled xxx copy (if the original was xxx). Now you can save xxx copy by using Save from the File menu, and change the name to whatever you want.
    Hope this helps you. Best of luck.

  • If I'm copying text and/or vector elements from Indesign to Photoshop how come their pixel sizes change even though I opened the same sized document and my indesign file is a web file?

    If I'm copying text and/or vector elements from Indesign to Photoshop how come their pixel sizes change even though I opened the same sized document and my indesign file is a web file?

    >my indesign file is a web file
    Pardon?
    Or do you mean that, when you created a new document, you choose Web as intent maybe?

  • How does APEX create and save new files. What extension does it save in?

    Hi can someone help me with this question?
    How does APEX create and save new files. What extension does it save in?
    Cheers!
    VJ

    It's really too bad we can't see VJ's face when the concept sinks in. This is one of my favorite moments when teaching APEX classes. Most people love it, some people don't. If nothing else it really proves the power and performance of the Oracle database. Each page view can generate 40+ queries, yet on the average system this takes less than .04 seconds.
    Keep in mind there are no undocumented features or "Oracle Internals" that the APEX team uses to achieve this performance, just sound database design. With every feature they add they evaluate how it will be used and design the tables and indexes to most efficiently answer the query. Sometimes this means going against "purist" normalized principals.

  • Can I use RoboHelp to support localization and generate help files in multiple languages?

    Hi,
    Can I use RoboHelp to support localization and generate help
    files in multiple languages?
    Can I define a layout or template for RoboHelp to insert
    localized strings into the template and generate a localized help
    file?
    Thanks!

    Hi newbie_r and welcome to the RH community.
    You don't say what version of RH you have but the latest
    version (RH7) has Unicode Support that allows you to produce help
    files in most languages. The exceptions are mainly the right to
    left languages (e.g. arabic, hebrew).
    As far as the template is concerned, you can assign any text,
    image to a template and it will be applied to any topics you assign
    the template to.
    If you haven't already, I'd download the trial version and
    experiment a bit. Set up a template with what you want and then
    create a couple of simple help files containing just a few topics
    each. That will reassure you of RH7s capabilities in this
    area.

  • How to do search with multiple texts across documents and rename the file with found text?

    Hello:
    I'm trying to do the batch search across the multiple documents and rename the file (or save as) after the found word?
    In example:
    I have many unique texts and would want to search across the multiple documents.
    If a document is found with that unique text then, the document is either renamed or save as with that unique text. 
    So, I could know what unique text that file holds.
    How do I do that?
    Let me know.
    Thanks

    Welcome to the forum!
    When you want to post a block of code, you can enclose it with the mark ups { code }
    That is the key word code surrounded by curly brackets, but without the spaces
    You seem to be running a very old (and unsupported release of the database)
    7.3 has not been a current release for about 10 years.
    It's probably been that long since I've used this technique, but i think it should work.
    You should consider welcoming your system to the 21st century by upgrading to a supported release ;-)
    If you used split to chop up your export file, use cat or dd to reassemble it.
    So, something like this:
    mknod bk.dmp p
    cat xaa xab xac xad xae xaf xag xah xai > bk.dmp &
    imp SYSTEM/$PASSWD parfile=imp_bk.parfile
    rm bk.dmp
    $ cat imp_bk.parfile
    file=bk.dmp
    log=imp.log
    full=y
    buffer=1048576
    ignore=y
    commit=y let us know if still have problems.
    Good Luck!

Maybe you are looking for

  • Lost cd rom after upgrading to windows 8.1

    System information: Satellite C55-A5300 Windows 8 Problem: This computer worked fine until last month when my son let it update to windows 8.1.  The cd rom then disappeared and he has to have the cd rom for his games.  I've tried everything I could f

  • PROBLEM IN USING BAPI_PO_CREATE1

    WHILE CREATING A PO THROUGH BAPI_PO_CREATE1 WITH REFERENCE TO PURCHASE REQUISITION THEN THE ERROR MESSAGES ENCOUNTERED ARE 1.PURCHASE ORDER STILL CONTAINS FAULTY ITEMS.(ERROR MESSAGE- MEPO000) 2.In case of account assignment, please enter acc. assign

  • How to get the PLANNING SHORTAGE in the forecast tab of /sapapo/rrp3?

    Hi to all! I need your help! I'd like to take the planning shortage quantities in the forecast tab of the product view /sapapo/rrp3 and the related date and I'd like to insert that quantity on the 9AAFCST key figure in the related time bucket. Have y

  • Rework Process order

    Is there any document standard SAP process for rework order? I found PP91 order type as for production rework order. But nothing for Process Order. Can somebody describe the steps for rework and how to move from blocked stock to unrestricted stock, w

  • BI7 Upgrade Issue

    hi, We are in the process of upgrading from BI 3.1 to BI 7. During testing one of the queries through BEX ( Analyzer 7 ), we are getting the following error message whenever we try to refresh the query or change the variables : "A table name is missi