Reading Complex Text document using FileAdapter

Hello All,
Can some body help me to read the text file which have complex structure delimited with semicolon, the text file has one header and one trailer records and with multiple details lines that has no specific pattern for starting, it can start with any alphanumeric character.
File Header CRM financial Interface to ERP;Interface_id=INT02;FileSequenceNo=00001;Country=US;FileDate=20120903;ExecutionMode=TEST
P430030205641 ;001;J2;09;SEK
P430000205641 ;002;J2;09;SEK
F430004705642 ;003;J2;09;SEK
F430004705642 ;004;J2;09;SEK
F430004705642 ;005;J2;09;SEK
R430477805641 ;006;J2;09;SEK
R430477805641 ;007;J2;09;SEK
R430477805641 ;008;J2;09;SEK
File footer;NumberOfPackages=3;NumberOfLines=00000008

Hello Vladodias,
I have created schema as per the developer guide
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
xmlns:tns="http://TargetNamespace.com/InboundService"
targetNamespace="http://TargetNamespace.com/InboundService"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
nxsd:version="NXSD"
nxsd:stream="chars"
nxsd:encoding="US-ASCII"
>
<xsd:element name="Root">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Header" type="tns:HeaderType" nxsd:startsWith="File Header" />
_*<xsd:element name="Records" type="tns:RecordType" maxOccurs="unbounded" />*_
<xsd:element name="Footer" type="tns:FooterType" nxsd:startsWith="File footer" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="RecordType">
<xsd:sequence>
<xsd:element name="R1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="R2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="R3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="R4" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="R5" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FooterType">
<xsd:sequence>
<xsd:element name="F1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="F2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="F3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="HeaderType">
<xsd:sequence>
<xsd:element name="H1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="H2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="H3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="H4" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="H5" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy=";" />
<xsd:element name="H6" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
When I test above sample file with "tns:RecordType" maxOccurs="unbounded" />, schema builder is throwing me error .
Error
Error while reading native data. [Line =10, Col=32] Expected ";" for the data starting at the specified position, while trying to read the data for "element with name R3", using "style as 'terminated" and "terminatedBy` as ";", but not found. Ensure that ";", exists for the data starting at the specified position.
When I test above sample file with "tns:RecordType" maxOccurs="8" />, it is working pefectly, but it is not the idel solution.
Is there is any solution so that it will stop processing the records when it reaches the end?

Similar Messages

  • How to read a text file using Java

    Guys,
    Good day!
    Please help me how to read a text file using Java and create/convert that text file into XML.
    Thanks and God Bless.
    Regards,
    I-Talk

         public void fileRead(){
                 File aFile =new File("myFile.txt");
             BufferedReader input = null;
             try {
               input = new BufferedReader( new FileReader(aFile) );
               String line = null;
               while (( line = input.readLine()) != null){
             catch (FileNotFoundException ex) {
               ex.printStackTrace();
             catch (IOException ex){
               ex.printStackTrace();
         }This code is to read a text file. But there is no such thing that will convert your text file to xml file. You have to have a defined XML format. Then you can read your data from text files and insert them inside your xml text. Or you may like to read xml tags from text files and insert your own data. The file format of .txt and .xml is far too different.
    cheers
    Mohammed Jubaer Arif.

  • When I read a pdf document using Safari I'm unable to read more than one page of a file. A padlock icon is locked on the tab. Please help.

    When I read a pdf document using Safari on my IPad  I'm unable to read more than one page of a file. A padlock icon is locked on the tab. Please help.

    Hi snoreaustralia,
    It sounds like you just need to associate the PDF filename extension with Acrobat, rather than Preview. Please see this document from the Microsoft Help for instructions on choosing the default program for opening a particular file type (in your case, PDF): Change which programs Windows uses by default - Windows Help
    Best,
    Sara

  • How to read two text files using the Read from spreadsheet.vi and then plot it

    I need to read two text files using the read from spreadsheet function and then plot these files over time.
    The file with the .res extention is the RMS values (dt and df) and the second file contains the amplitude of a frequency spectrum.
    I really appreciate any help..thanks
    Attachments:
    RMS.txt ‏1 KB
    FREQUENCY.txt ‏1 KB

    From NI Example Finder:
    Write to Text File.vi
    Read from Text File.vi
    Jean-Marc
    LV2009 and LV2013
    Free PDF Report with iTextSharp

  • Read only text Items uses the maximum width

    Folks,
    I have a form with 3 regions and each region has 6 or more text items each with a different width (40, 30 24, 2...). I am using a Read Only Condition Type on all these items to disable them. I am setting the background color as bgcolor="#DCDCDC" in the Read Only Element Table Cell Attributes.
    All my elements are disabled (Gray color) but with the maximum width of 40 bytes. I don't want a 2 byte text item 40 bytes long and grayed out. How can I set a specific width for individual items in Read only Condition? Please help
    Thanks
    Raje.

    Try this alternative by disabling the HTML Form Item at the required process point.
    I added this JavaScript to the HTML Header of the page which will allow me to disable the required item, plus set its background and color:-
    <script language="JavaScript1.1" type="text/javascript">
        function disableFormItem(p_item, p_background, p_color){
                        disItem = document.getElementById(p_item);
                        disItem.style.background = p_background;
                        disItem.disabled = true;
                        disItem.style.color = p_color;
    </script>In the Region Footer of the Region where my items are located I added this JavaScript code:-
    <script language="JavaScript" type="text/javascript">
       ** Only disable the required Form Items if the Primary Key value is present,
       ** in this case it is P12_UEI. (Won't be present for new records as populated
       ** by on-insert db trigger and sequence.)
       if (html_GetElement('P12_UEI').value > 0)
          disableFormItem('P12_URESI', 'lightyellow', 'black');
          disableFormItem('P12_UZI', 'lightgray', 'black');
          disableFormItem('P12_UBI', 'lightgray', 'black');
    </script> The resulting page is a lot better looking than using the APEX read only text item.
    Regards,
    Phil

  • How can you detect all words and phrases in a text document using java?

    Is there some java API which would help me extract all words, multi-word phrases, punctuations in an English text document? I would also like to get the order in which they appear with sentence detection. I've been searching for this in java NLP packages, but haven't found anything yet.
    Any help would be appreciated.
    Thanks,
    Ajith

    I don't understand what you actually want, but if your on about having a file and splitting it up into sentences then i would look into either psudocode or parsing strings, theres not a java api as far as i know that does anything like you want, you would have to write it yourself or find a project someone else has made.

  • How to read any text files using file adapter as it is

    Hi,
    I need to build bpel process to read any text files as it is.I am file adapter and using opaque schema.But input file is coming as base64encoding format.But i need the input as it is.How can i do that.
    Is there any sample schema to read input text files as it is?

    in java embedding activity i need to remove all newlines from my input text file.During this process i am getting arryindexoutofbounds exception.Below is my code
    String input = (String)getVariableData("inputFileStr");
    Base64Decoder Decoder = new Base64Decoder();
    try
    String decoded = Base64Decoder.decode(input); --exception is coming at this line
    setVariableData("inputFileStr", decoded);
    decoded = decoded.replaceAll("\\n|\\r", "");
    byte[] outputBytes = decoded.getBytes();
    String reencoded = Base64Encoder.encode(outputBytes);
    setVariableData("outputFileStr", reencoded);
    catch(Exception uee)
    uee.printStackTrace();
    below is stack trace:
    09/02/26 08:10:33 java.lang.ArrayIndexOutOfBoundsException: -1
    09/02/26 08:10:33 at com.collaxa.common.util.Base64DecoderStream.decode(Base64DecoderStream.java:162)
    09/02/26 08:10:33 at com.collaxa.common.util.Base64DecoderStream.decode(Base64DecoderStream.java:143)
    09/02/26 08:10:33 at com.collaxa.common.util.Base64Decoder.decode(Base64Decoder.java:36)

  • Air App will not read local text file using openAsync/readUTFBytes on user (non-admin) mode

    I am running an Air App I did for the desktop, from the actual installed executable already deployed in the machine (Not from Flash Pro / Flex dev. environment). For some reason the app will not read a text file stored in the same application folder unless I run my app as administrator from the OS.
    When I run the app as admin, or within the development environment it works fine. Maybe this is related to some security issue? I read the adobe air documentation, and this should work...
    I am using openAsync/readUTFBytes on user as shown here:
    var continueGamesConnection:FileStream();
    var continueFile:File = new File(File.applicationDirectory.resolvePath("continueGames.txt").nativePath.toString()); 
    continueGamesConnection.addEventListener(Event.COMPLETE, openSavedGames);
    continueGamesConnection.openAsync(continueFile, FileMode.UPDATE); 
    function openSavedGames(event:Event):void
         continueGamesConnection.removeEventListener(Event.COMPLETE, openSavedGames);
         var content:URLVariables = new URLVariables();
         var loadedContent:String = new String();
         loadedContent = continueGamesConnection.readUTFBytes(continueGamesConnection.bytesAvailable);
         content.decode(loadedContent); 
         variableX = content. variableX
         //etc, etc. 
         continueGamesConnection.close();
    By the way, I have also, tried using FileMode.READ, and others, and it still gives me the same problem. Only works if ran on admin mode or from the dev. environment.
    It's very frustrating, I tried reading other posts without any luck... What solutions do people use for this kind of problem?
    I have seen that you can set the app to run as admin somehow, and I guess that could work. However, this should work just fine, since it doesn't seem to violate any of the security APIs of Air. Seems like an overkill. But even so, how do I do that?
    You help is greatly appreciated!

    Thanks kglad.com. I will try this and see if it works. Can you check my code a bit to see if it's right?
    var continueFile:File = new File(File.applicationStorageDirectory.resolvePath("savedgames/continueGames.txt").nativePath.toString());
    Does this look right to work across all desktop OS?

  • How to read a text file using adobe javascript

    Hi,
    I have a api application which adds toolbar to a adobe acrobat. i need to disable the toolbar according to expiry date, So i need to fetch the expiry datge from a text file from the specified location.
    I am using importTextData() function to get the textdata from text file using adobe javascript. When i call this function i am getting error "ReferenceError: importTextData() is not defined".
    I am using Adobe Acrobat 7.0 version.
    Can any one tell how to use the importTextData() function.
    Regards
    Shiva

    calling from javascript file which is placed in the below location.C:\\Program Files (x86)\\Adobe\\Acrobat 7.0\\Acrobat\\Javascripts
    Regards
    Shiva

  • Read-Only Text Field Using JavaScript Code

    I'd like to make a text field read-only by using JavaScript and also having IF & ELSE statements.
    I want it to be like this:
    if the answer from the dropdown menu is YES, then the text field is read only but if the answer is NO then the text field is fillable.
    Thanks in advance

    Use this code as the custom validation script of the drop-down in question:
    this.getField("Text1").readonly = (event.value=="Yes");

  • Can't read a text file using java

    Hi All
    I am trying to read a log file.
    ProgramA keeps updating the log file, while my program ProgramB reads it.
    For some readson my ProgramB is not able to read the last two lines in the log file. If I run the program in debug mode it is reading all the lines.
    This is having me frustrated.
    Please let me know if there is a way to read entire contents.
    Here is how I am reading the files ( 2ways)
         private static String readFileAsString(String filePath)
        throws java.io.IOException{
            StringBuffer fileData = new StringBuffer(1000);
            FileReader fr = new FileReader(filePath);
            BufferedReader reader = new BufferedReader(fr);
            char[] buf = new char[1024];
            int numRead=0;
            while((numRead=reader.read(buf)) != -1){
                String readData = String.valueOf(buf, 0, numRead);
                fileData.append(readData);
                buf = new char[1024];
            reader.close();
            fr.close();
            return fileData.toString();
           * Fetch the entire contents of a text file, and return it in a String.
           * This style of implementation does not throw Exceptions to the caller.
           * @param aFile is a file which already exists and can be read.
           static public String readFileAsString(String filePath) {
             //...checks on aFile are elided
             StringBuffer contents = new StringBuffer();
             //declared here only to make visible to finally clause
             BufferedReader input = null;
             try {
               //use buffering, reading one line at a time
               //FileReader always assumes default encoding is OK!
               input = new BufferedReader( new FileReader(filePath) );
               String line = null; //not declared within while loop
               * readLine is a bit quirky :
               * it returns the content of a line MINUS the newline.
               * it returns null only for the END of the stream.
               * it returns an empty String if two newlines appear in a row.
               while (( line = input.readLine()) != null){
                 contents.append(line);
                 contents.append(System.getProperty("line.separator"));
             catch (FileNotFoundException ex) {
               ex.printStackTrace();
             catch (IOException ex){
               ex.printStackTrace();
             finally {
               try {
                 if (input!= null) {
                   //flush and close both "input" and its underlying FileReader
                   input.close();
               catch (IOException ex) {
                 ex.printStackTrace();
             return contents.toString();
           }

    If you're using JDK 5 or later, you could use the Scanner class for input information. See below:
    try {
                   Scanner reader = new Scanner(new File("C:\\boot.ini"));
                   StringBuilder sb = new StringBuilder();
                   while (reader.hasNextLine()) {
                        sb.append(reader.nextLine());
                        sb.append(System.getProperty("line.separator"));
                   System.out.println(sb.toString());
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              }

  • Keep getting screen that I need to download Adobe Reader to access documents.Using IE10 + Windows7

    I already have Reader 10.1.4 installed.  I receive a 'message' indicating that I need to ' ... download Adobe Reader ... '   It is extremely important that I access a specific document from a website asap .....  but I cannot.   Please help !!!!

    It could be that IE10 does not support Adobe PDF reader plugin.  If you have pdf reader already installed then you could download the files by right-clicking on the links and saving it on your machine which can then be opened in Reader.
    Alternatively, either downgrade to IE9 (IE10 is still in beta and should not be used in production machines) or use alternative browsers like Firefox 15.
    <http://www.mozilla.org/en-US/firefox/fx/#desktop>
    Good luck.

  • Problem while reading from text file using JDeveloper 10.1.2

    Hi,
    I am using JDeveloper 10.1.2 for my application. In this, I have one requirement to read some data from a text file. For that, I created a test file and saved along with the java file folder. From there, I am trying to read this file but it says the file not found exception.
    Application is looking the file from another location. "F:\DevSuiteHome_1\jdev\system10.1.2.1.0.1913\oc4j-config"
    But, I want to read it from my home folder. How is it possible to read from that location?
    Regards,
    Joby Joseph

    HI,
    Check followings will useful
    How to read .txt file from adfLib jar at model layer using relative path
    Accessing physical/relative path from Bean

  • How to read from xml documents using either sax or dom

    dear all
    i have an xml document and i want to create a procedure to read the data from it .
    is it possible or not? thanks in advance

    Where is the xml document located?
    load it into an XMLTYPE and apply xpath as required.
    SQL> declare
      2    xml xmltype ;
      3  begin
      4    xml := xmltype('<node><value>this is text</value></node>') ;
      5    dbms_output.put_line('value='||xml.extract('/node/value/text()').getStringVal()) ;
      6  end ;
      7  /
    value=this is text
    PL/SQL procedure successfully completed.
    SQL>

  • How to read/print microsoft documents using mavericks

    have been trying bto download and read data from my bank. they use only microsoft and sage software. how can ~~I open and read from mavericks OSX?

    You need a word processing program such as Microsoft Office for Mac, OpenOffice(free), LibreOffice(free), or Pages. Unless this is an excel file or other file type. Then you would need to find something else like Numbers or Excel for Mac.

Maybe you are looking for

  • Sorting Music By (lack of) Artwork

    Is there a way to sort your library by those songs that lack artwork? I want to update the songs without artwork, and need an easy way to locate them. Thanks, Shaun

  • 1st Gen iMac Power Supply Issue

    I just got my iMac G5 back from Apple after having the power supply and logic board replaced for the second time in two years. It is apparently a fairly common problem with the first generation iMac G5s. I've basically been told it's a problem with n

  • How do I add a functional "submit button" to a pdf form in Adobe Acrobat Pro XI ? I created the pdf form in Adobe Forms Central.

    How do I add a functional "submit button" to a pdf form in Adobe Acrobat Pro XI ? I created the pdf form in Adobe Forms Central. It's for an online Diet Questionnaire. After people complete the form I'd like them to click "SUBMIT" and the completed f

  • Problem in the creation of a new toolbar

    I had offered you this problem earlier when the beta version of the browser experience, the problem is that the browser does not save the toolbar do I created after the close of the browser, where when you re-open the browser the toolbar that you cre

  • Retreiving playlists from ipod classic

    i have ipod classic from 2005 which stopped working suddenly.i couldnot save and backup my playlists.the apple store guy tells that it can't work anymore coz of the dead battery and i better throw that away..i need suggestions on how to retreive my p