Mimic BufferedReader with XML File

I have a class (extends BufferedReader) that reads "records" 1 by 1 -
import java.io.*;
import java.util.*;
public class FileRecordReader extends BufferedReader {
  public FileRecordReader(Reader reader) throws FileNotFoundException {
    super(reader);
  public String[] readRecord() throws IOException {
    Vector fields = new Vector();
    char[] buffer  = new char[1];
    int bytesRead;
    StringBuffer newField = new StringBuffer();
    bytesRead = read(buffer);
    while (bytesRead != -1) {
      // ignore linefeed and carridge returns
      if (buffer[0] == '\n' || buffer[0] == '\r') {
        bytesRead = read(buffer);
     continue;
      if (buffer[0] == '|') {
        fields.addElement(newField.toString());
     newField = new StringBuffer();
     bytesRead = read(buffer);
     continue;
      if (buffer[0] == '~') {
        break;
      newField.append(buffer[0]);
      bytesRead = read(buffer);
    if (fields.size() == 0) return null;
    String[] returnFields = new String[fields.size()];
    fields.copyInto(returnFields);
    return returnFields;
}As you can see the fields are seperated by the '|' character and the '~' character signals the end of a record.
I now have to extend this class to handle xml files as well. In the readRecord method I check a property which tells me what file type I'm dealing with (txt file or xml) and then I call either readDelimitedRecord or readXMLRecord.
readDelimitedRecord does exactly what readRecord currently does, and readXMLRecord should do the equivalent for an xml file. I know how to read a record from the xml file, but how do I keep track of what records I've read so far?

Your solution for delimited files doesn't scale to XML files. Besides, XML files don't have "records". I would recommend that for XML files you do something completely different. Feed them to a SAX parser and get the stream of startDocument(), startElement(), characters(), endElement(), and endDocument() events. Otherwise you would find yourself writing a whole XML parser, which is more complicated than it looks.

Similar Messages

  • Connect interface with XML File in jdeveloper

    Hello;
    i want to design a webservice that take an employee ID , and return all employee's data (like his name ,departement, phone,email....)
    i want to make interface and connect it with XML file wich has all employees data
    how can i connect the interface ( input text box and output button) with XML file (taking the Id and searching inside the file and getting the data out in table as output)
    i want to deploy it to get the WSDL file and URL to deploy it at application server to use it in webcenter>>>

    up 2 find an answer
    i want the right way to do it?

  • Problem when load more swf files work with xml files into my movie

    hi ;
    I have one flash file & more of swf files which work with xml files .
    when I load one swf file into my flash file  and remove it and load anther one on the same movieclip in my flash file it load the old swf file.
    when i load one on movieclip and remove it and load anther swf  on anther movieclip the file doesn`t work  and stoped.
    when test my flash file to load and remove swf files without xml file it work fine but when repleaced the swf files with other work with xml files the problem hapend.
    thanks;

    YOu should trace the names of the files that are being targeted for loading to see if they agree with what you expect.  If you want help with the coding you will need to show the code that is relevant to your problem (not all of it)

  • Oracle reports problem in distribution with xml file

    Hi ,
    I am having problem while I am trying to distribute the file with specifing the destination details in the xml. If I am giving the destination details in url then it is working.
    Ex.
    This is Working
    http://bryxh91:8889/reports/rwservlet?report=devlopersuit/reports/test.jsp&userid=anju/[email protected]&desformat=pdf&destype=file&desname=devlopersuit/reports/output_file.pdf
    Not working :
    http://bryxh91:8889/reports/rwservlet?report=devlopersuit/reports/test.jsp&userid=anju/[email protected]&DISTRIBUTE=YES&destination=devlopersuit/reports/dis_test.xml
    xml file
    <destinations>
    <file id="test" name="output_file.pdf" format="pdf">
    <include scr="mainSection"/>
    </file>
    </destinations>
    Error : REP-34304: Distribution failed to complete; review the distribution lists
    Its been week I tried many things , but not working.
    Right now I am trying to distribute to single file but my goal is to burst and distribute on basis of account number.
    This is the first stage of the project.
    Thanks a lot for the help
    Anju

    Hello
    see answer in Oracle reports problem in distribution with xml file
    Regards

  • .tmp files genrated along with XML files

    Hi all,
    Here my Interfaces are type of RFC- XI - FTP.
    these are running successfully past long time and creating XML files in the target directory of FTP aplication system. Along with XML files this time abnormally .tmp files were generated in the Target directory of FTP application system. This was occured only one time few days back.
    The generated XML files in target FTP system as usually read by Application system and processed in the sytem.
    And tmp files generated are as XI_ftp_XI_ftp_0c200300-704c.tmp
    could you all please let me know what could be the reason for happening this like generation of .tmp files abnoramally in Target FTP application system.
    Thanks in advance...
    Regards,
    Siva

    Hi, thanks for reply.
    The Write mode is "Use temporary file"
    But we have not got these .tmp files earlier and we have not mentioned any temporary file name sceme too.
    Could any body please explain will .tmp files are generated randomly?
    If i keep 'Directly' mode, will it keeps only the XML files in target directory?
    Please advise.
    Thanks,
    Siva

  • How do i use a flash gallery with xml file

    Hi there....
    I am trying to include a flash banner template i have downloaded into my webpage using dreamweaver CS5.
    the template comes with an XML file with it in which you can reference your own images etc..
    I understand how to inclued the Flash object into my webpage by insert-swf- and then navigating to the .swf file...
    what i am having trouble with is understanding how this refereces the XML file in the download pack as i cant find any references to it in the code??
    I am just getting the grey flash box with no images appearing when i hit play etc..
    sorry if this is a really silly question!!
    mart

    If you are using DW to insert the Flash, that could be the problem.  It is not reliable resource in that respect (my opinion, but a shared one). I normally only use Flash to create the code and copy/paste it into my html page.  Did you get an fla file with the set, and do you have Flash?
    What you should do is test the swf file by itself to make sure it works.   Normally you can link directly to the swf file to check that out.  Just type in the url to the swf file and see if it plays.  There may be some other setup required that maybe an accompanying set of instructions might explain.
    Also, if you have a link to the html file you uploaded, providing it here may help in getting things resolved.

  • Creating a Link with XML Files

    Hi,
    I am trying to import a XML file in a table structure following instructions from the Adobe help file (could only find a CS3 one, I am using CS4, the link to it: http://www.adobe.com/designcenter/indesign/articles/indcs3ip_xmlrules.pdf). Now the import works fine and my table is displayed correctly. My plan for this is to have XML files created from a database so when they get overwritten it will automatically update the tables in the file. While importing it I chose the "Create Link" option and I can see it in the links panel. All that seems fine. My problem is from this point if I do any changes to this file it gets added into my template along with the original with no formatting. So normally imported it looks like:
    code
    description
    unit
    price
    10000
    Product A
    Each
    5.00
    and if I edit it it then looks like this:
    5.00
    Each
    Product A
    10001
    PRICE
    UNIT
    DESCRIPTION
    CODE
    code
    description
    unit
    price
    10000
    Product A
    Each
    5.00
    And all I edited was the code value to be 10001 on the link yet it makes all these changes. Now if I edit the original XML file again it will crash Adobe CS4 and it freezes and says encountered error and closes. Does anyone have any advice on this situation? Is there a simple way to get XML tables inserted into a document that will change in the document if I edit the original file. If I have to change the XML that is fine as I can output it from the database pretty much whichever way I want.
    Here is the code for the XML file:
    <Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:table="table" aid:trows="2" aid:tcols="4">
    <Cell aid:table="cell" aid:theader="" aid:crows="1" aid:ccols="1" aid:ccolwidth="130">CODE</Cell>
    <Cell aid:table="cell" aid:theader="" aid:crows="1" aid:ccols="1" aid:ccolwidth="59">DESCRIPTION</Cell>
    <Cell aid:table="cell" aid:theader="" aid:crows="1" aid:ccols="1" aid:ccolwidth="130">UNIT</Cell>
    <Cell aid:table="cell" aid:theader="" aid:crows="1" aid:ccols="1" aid:ccolwidth="130">PRICE</Cell>
    <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="130">10000</Cell>
    <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="130">Product A</Cell>
    <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="130">Each</Cell>
    <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="130">5.00</Cell>
    </Table>
    Any help would be appreciated.

    I wasn't using "Edit Original" before, but now that I do, I'm still unable to duplicate your result. When I edit and save, the results are just as one would expect. What application are you using to edit the XML? I am using Text Wrangler. What platform are you one? I've been testing this on a Mac, but could try it on Windows of that's what you are using. Also, out of curiosity, what does your XML structure look like? Here's mine:
    <Root>
      <Article>
        <Story>
          <Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:table="table" aid:trows="2" aid:tcols="4">
            <Cell ..... (your cell nodes here)
          </Table>
        </Story>
      </Article>
    </Root>    

  • Problem filling in a form with xml file

    I have two forms that are used to inform people in town via the web of items needed in a food bank. The first form is filled out by the caretaker and has a "print" and "submit" button at the bottom. The second form is identical to the first but does not have a submit button since it is published on the web and readers can print it out to take with them shopping. Last month I was able to fill the second form with  data from the first that was exported as a xml file and inported into the second. For some unknown reason other that my program was updated this no longer works. Is there a way for this to still function?

    There is no built-in date picker available for forms created in Acrobat. There are some third-party solutions involving JavaScript (either a large collection of fields or a custom dialog) though. Also, text fields with date formatting will use a wheel type date picker on Android/iOS devices with Adobe Reader.

  • Help on creating a ServerSession in Eclipse with XML file

    Hi,
    I am using Toplink in Eclipse with Tomcat/Apache (or at least trying to :)
    I am trying to make the following code work:
    Project myProject = XMLProjectReader.read("myproject.xml");
    Server serverSession = myProject.createServerSession();
    but I get an exception:
    {color:#ff0000} +"7099", "The deployment project xml resource {0} was not found on the resource path. Check that the resource name/path and classloader passed to the XMLProjectReader are correct. The project xml should be included in the root of the application's deployed jar, if the project xml is deployed in a sub-directory in the application's jar ensure that the correct resource path using \"/\" not \"\\" is used."+ {color}
    - I think the project cannot find the xml file in my project - but I was never sure where this should go in any case - I put it in the META-INF folder but made no difference. Where should I put these xml files?
    Any help much appreciated

    Simon,
    Hi, I assume you are deploying a WAR to Tomcat. The following tutorial on running TopLink using the org.eclipse.persistence.jpa.PersistenceProvider is pure JPA but deals with the same deployment issues.
    In particular note that there are two META-INF directories - we want to use only the one off of src.
    "Make sure that your persistence.xml (and optionaly orm.xml) file is placed off of the src/META-INF directory and not the default WebContent/META-INF dir so that it gets picked up by the servlet classloader from the classes directory."
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#persistence.xml
    thank you
    /michael
    http://www.eclipselink.org

  • InsertHTML won't work with XML files

    I am trying to create a command that writes text to an open
    XML file. The command I've created works fine under some
    circumstances but not others.
    It works if I open an XML file and apply the command without
    editing the file. If I make any edits to the file manually and then
    apply the command, it doesn't insert anything.
    It works fine with HTML files in design view, but in code
    view, if I make any edits and then run the command, nothing
    happens. If I switch to design view and back again, the command
    then works fine.
    I tested the built-in Dreamweaver command "Flash Text" on an
    XML file (after editing it so it could be used with an XML file),
    and the same problem occurs with this command when using it on an
    XML file. The problem didn't occur with HTML in code view, though.
    Below is the .JS file for my command. The corresponding HTML
    file contains only an empty form.
    function canAcceptCommand() {
    return(true);
    function isDOMRequired() {
    return false;
    function commandButtons()
    return new Array( MM.BTN_OK, "cmdOK(); "
    , MM.BTN_Cancel, "cmdCancel();");
    function cmdOK()
    var theDOM = dw.getDocumentDOM('document');
    theDOM.insertHTML("test", true);
    window.close();
    function cmdCancel()
    window.close();

    I need a function, though, that will insert text at the
    cursor location in an open file.
    I'm also discovering that the command I created above
    functions erratically even when it does deign to insert the text in
    an XML file. The text is usually inserted somewher other than where
    the cursor is located.

  • Populating PDF Form with XML File.

    Hi,
    I need my PDF form to be populated with the data in XML file.I've created a data connction to the file and binded the values to my fields.When I've opened the form in Reader/Acrobat i'm not able to see any date on the form.
    Currently,I'm using "xfa.host.importData()" to import an XML file on a button click.It is working fine.But I need to load the data on Form Load itself.
    I'm relatively new to PDF technologies.Any help would br gratly appreciated.
    Thanks in Advance.

    The binding feature in designer just allows you to describe how to map fields to data elements, not to actually populate them autotmatically. You would need to have a server component to merge data / pre-populate or a script on your reader-enabled form to load the data. You can use xfa.host.importData() in DocReady event if you want it to prompt on loading the pdf. Earlier events in the chain wont work until the form has been properly loaded.

  • Skin Setting not working with XML file

    I am trying to use the Adobe Flash Playback with a flashvars skin setting.  I am pointing this setting to an xml file where I am trying to overide the playButtonOverlay image.  Below is my code.  I am using MVC, so you will see a couple Html Helpers.  The helpers are working just fine.  It is only the skin setting I can't seem to get to work.  Any help would be appreciated.  Thanks, Michael.
    Html File
    <object width="384" height="288" >
         <param name="movie" value="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" />
         <param name="flashvars" value="src=<%: Model.VideoFilePath %>&poster=<%: Model.PosterFilePath %>&skin=/Skin/FlashPlayerSkin.xml" />
         <param name="allowFullScreen" value="false" />
         <param name="allowscriptaccess" value="always" />
         <param name="quality" value="high" />
         <param name="wmode" value="transparent" />
         <embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" type="application/x-shockwave-flash"
              allowscriptaccess="always" allowfullscreen="false" width="384" height="288"
              flashvars="src=<%: Model.VideoFilePath %>&poster=<%: Model.PosterFilePath %>&skin=/Skin/FlashPlayerSkin.xml"
              quality="high" wmode="transparent" />
    </object>
    XML File
    <?xml version="1.0" encoding="utf-8" ?>
    <skin>
      <elements basePath="/Content/MFBImages/FlashPlayer/">
        <element id="playButtonOverlayNormal" src="playButtonOverlay.png"/>
        <element id="playButtonOverlayDown" src="playButtonOverlay_down.png"/>
        <element id="playButtonOverlayOver" src="playButtonOverlay_over.png"/>
      </elements>
    </skin>

    Thank you both for replying so quickly.  I still don't seem be having too much luck.  The first thing I did was watched fiddler, and it did show an error with crossdomain.xml.  So I added the below elements to a crossdomain.xml file in my root folder.  I also changed all my paths to be absolute for both the skin flashvar and xml, but still no luck.
    crossdomain.xml
    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
      <allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
    </cross-domain-policy>
    Since I am having trouble with the xml, I decided to try and just put the skin element into the html page where the flash player is located.  I then removed the flashvar skin element out of the player.  Below is my code for the skin element and flashplayer with absolute paths.  The player still seems to use the default overlay play button.  Any other suggestions would help out greatly.
    <skin>
    <elements basePath="http://localhost:1852/Content/MFBImages/FlashPlayer/">
      <element id="playButtonOverlayNormal" src="playButtonOverlay.png"/>
      <element id="playButtonOverlayDown" src="playButtonOverlay_down.png"/>
      <element id="playButtonOverlayOver" src="playButtonOverlay_over.png"/>
    </elements>
    </skin>
    <object width="384" height="288" >
    <param name="movie" value="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" />
    <param name="flashvars" value="src=http://localhost:1852/VideoLibrary/Agents/test video.flv&poster=http://localhost:1852/Content/MFBImages/AgentImage/Poster.jpg" />
    <param name="allowFullScreen" value="false" />
    <param name="allowscriptaccess" value="always" />
    <param name="quality" value="high" />
    <param name="wmode" value="transparent" />
    <embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" type="application/x-shockwave-flash"
        allowscriptaccess="always" allowfullscreen="false" width="384" height="288"
        flashvars="src=http://localhost:1852/VideoLibrary/Agents/test video.flv&poster=http://localhost:1852/Content/MFBImages/AgentImage/Poster.jpg"
        quality="high" wmode="transparent" />
    </object>

  • How to work with .XML files with FINAL CUT PRO HD

    Ok so I am a newby, kind of. We filmed a feature using the SONY XDCAM 350. uses the optical 23.3GB disc. I used the camera to copy all the HD files ( .XML ) to an 1TB external drive. Now the drive is readable, everything looks fine, when I select a .XML file. Final Cut Pro HD opens, but then asks to choose a TRANSLATION file. Where do I go from here. I do not understand that command of action it is asking. Newby here, so pity me for awhile.
    Thanks

    my instinct is "No" but thats no (because the app is expecting th efiles to be located on an mounted XDCAM disc that is formated as such) ... but in your situation I'd be inclined to download the XDCAM Transfer app and try for myself
    what you may need to do though is get hold of the discs and a deck and import using the method above
    failing that you have the option of using Flip4Mac's MXF quicktime components ... not cheap.
    this will allow you to select the local XDCAM source media that you've alreday transfered in the native MXF format, and rewrap as Quicktime for editing in FCP
    (a trial version is available for download)
    ... and if thats out of budget, or for whatever reason not an option, you can sit it out and see if the next FCP revision helps you out any with its direct Log and Transfer support for XDCAM. may have the same restrictions though (ie need a properly attached formatted device)
    ... and other than that, you're looking at switching to an NLE with native MXF support (Avid, Edius, Vegas etc)

  • Having difficulties with XML Files and Final Cut Pro

    Hi help community!
    I am having a problem transfering / viewing / importing XML files from a hard drive onto Final Cut Pro.
    I have tried importing and it says:
    please choose a translation document file
    followed by
    ERROR:
    No translation templates matching the selected XML were found. Unable to import this file.
    I have also tried to convert using 'log and transfer' but in this instance I can see the XML file but its shaded & I am unable to click on it or drag it into the viewing window.
    Any suggestions will be hugely appreciated! Thanks

    Where did this XML come from? FCP only recognizes XML in the format it works with. It most likely willn not work with FCP in its current form.

  • HTTP POST Request with XML file in

    Hi @ all,
    I would like to send an HTTP Request with an XML File in the body to an SAP System
    I have the target URL and the a XML File.
    Now the question is. Is it possible to use something like the HTTP_POST FuBa to send an url post request with an xml file?
    If yes can anybody give me a hint?
    I have a php script which exactly do this coding. But to integrate it all in one system it is necessary to transform it into ABAP and call it there.
    // compose url and request and call send function
    function test($productID, $categoryID) {
         // create url
         $PIhost = "XXX.wdf.sap.corp";
         $PIport = "50080";
         $PIurl = "/sap/xi/adapter_plain";
         $PIurl .= "?sap-client=800";
         $PIurl .= "&service=XXX";
         $PIurl .= "&namespace=XXX";
         $PIurl .= "&interface=Frontend_Interface";
         $PIurl .= "&qos=EO";
         $PIurl .= "&sap-user=XXX";
         $PIurl .= "&sap-password=XXX";
         // create xml
         $request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
         $request .="<n1:FrontendInbound_MessageType xmlns:n1=\"http://crmpiebay.com\">\n";
         $request .= "\t<FrontendInbound>\n";
         $request .= "\t\t<ProductName/>\n";
         $request .= "\t\t<ProductCategory>".$categoryID."</ProductCategory>\n";
         $request .= "\t\t<ProductID>".$productID."</ProductID>\n";
         $request .= "\t\t<MessageID/>\n";
         $request .= "\t</FrontendInbound>\n";
         $request .= "</n1:FrontendInbound_MessageType>";
         // send http request
         postToHost($PIhost, $PIport, $PIurl, $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]."/".$_SERVER["PHP_SELF"], $request);
    // send post request to PI server
    function postToHost($host, $port, $path, $referer, $data_to_send) {
      $fp = fsockopen($host, $port);
      if($fp) {
           $res="";
           fputs($fp, "POST $path HTTP/1.1\r\n");
           fputs($fp, "Host: $host\r\n");
           fputs($fp, "Referer: $referer\r\n");
           fputs($fp, "Content-type: text/plain\r\n");
           fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
           fputs($fp, "Connection: close\r\n\r\n");
           fputs($fp, $data_to_send);
           while(!feof($fp)) {
               $res .= fgets($fp, 128);
           fclose($fp);
           return $res;
    Would be great if anybody could give me a hint how to solve such a HTTP Post request with XML body data.
    Thanks in advance.
    Chris
    Edited by: Christian Kuehne on Feb 26, 2009 4:32 PM

    hi friend could you please share your solution regarding this query if u got it already?

Maybe you are looking for

  • How to Change the return value for the parameters

    Hi, Can anyone help me with my problem? I have a parameter called "P1_Projects" defined in the HTMLDB page, on the report region, there are 2 buttons, one is "Go" button to submit the report on the screen, so user can preview the report, then another

  • My MacBook Pro starts to boot up, then...

    I have a Late 2008 MacBook Pro (Intel), which I'm convinced is a lemon.  The amount of service it's needed in the last 3 years is staggering (logic board, display, etc.). I definitely made a mistake upgrading to Mavericks as it seems to be running wo

  • Icloud does not work on the pc

    took photo but does not come to pc. went through setup, outlook went through a backup then showed some old reminders. not sure where those came from. but still no photos

  • MacBook Pro restarts randomly after installing OS X Mavericks

    I just installed the OS X Mavericks and after it was done installing, obviously it had to restart like any other update. It restarted regularly the first time until I signed into my user and it just shut off and restarted randomly. This time when it

  • How create User ID in ECC 6 IDES

    Hi Guys, I am new to Portal and want to explore. Can somebody give the steps to create a User ID in Portal. I have access to SAP IDES ECC6 and in the browser it is asking Userid and Password. I dont have the userid and password. Can somebody give me