Tree Parsing

Hi,
I am having a Treeset with the following structure
key is a string and value is an object
0 linkObj
00 linkObj1
01 linkObja
1 linkObj2
10 linkObj3
11 linkObj4
110 linkObj5
111 linkObj6.
Tree structure is as follows
0 and 1 are parents
0 -> childs 00, 01 ,02 , 03 ....
1 -> childs 10, 11 ,12 ...
11 -> childs 110, 111, 112 and so on
I would request to parse this structure and fetch me the required object based on the node i pass.
Thanks in advance
ramki.

theParent is the DefaultMutableTreeNode from you want to search.
Use this piece of code recursively:
Enumeration nodes = theParent.depthFirstEnumeration();
for (; nodes.hasMoreElements() ;) {
Object obj = nodes.nextElement();
DefaultMutableTreeNode objNode=(DefaultMutableTreeNode)obj;
Object userObj = objNode.getUserObject();
userObj is the object contained in the Tree node. So you ask it what you want (eventually make a cast to your object).
Bye, Anteo.

Similar Messages

  • XML Tree Parsing problems

    I am trying to make a program that will read the tree of an xml file and later store the data in a different format...
    At the moment it reads part of the tree. but then a null pointer exception occurs on the line marked (***) in the .java file attached.
    It starts at the base element ('servers' in this case) then finds if it has child nodes, if so it stores them, again and again untill it finds text, it will then print the text to screen, and remove the child from the previous node. If a node no longer has any children it is removed from the list and then the next node is found...
    The problem being is that is isnt correctly working, as some of the nodes in the pastNodes arraylist are being replaced by one of their child nodes....so when it comes to the point where the list gets shorter and the next node needs to be found it has an incorrect tree list in pastNodes and dies on me.
    The reason for doing it like this is so that i can list the values in a tree like format in an array (eventually) such as 'servers.server.ComputerName' has value 'Bobs_PC' etc. as the program that wrote this leaves multiple smae named variables with different types of value...e.g. like 100 'Name' tags but some refer to a drive name and others to services names.
    Any ideas?
    Cheers for any help.
    Here is my code...sorry that its so long :(
    public void read(String xmlToRead){
              System.out.print("\n* Reading '"+xmlToRead+"'...");
              try {
         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
         Document doc = docBuilder.parse(new File(xmlToRead));
         // normalize text representation
         doc.getDocumentElement ().normalize ();
         NodeList listOfNodes = doc.getElementsByTagName("servers");
         ArrayList pastNodes= new ArrayList();
         pastNodes.add(listOfNodes.item(0));
         while(((Node) pastNodes.get(pastNodes.size()-1)).hasChildNodes()){
              System.out.println("\n------");
              //stores all new nodes with children
              if(((Node) pastNodes.get(pastNodes.size()-1)).getFirstChild().getNodeName() != "#text"){
                   pastNodes.add(((Node) pastNodes.get(pastNodes.size()-1)).getFirstChild());
                   System.out.println("NODE ADDED");
              System.out.println("pastNodes Path:");
              int x=0;
              while(x<pastNodes.size()){
                   System.out.println(x+": "+((Node) pastNodes.get(x)).getNodeName());
                   x++;
                   //print the text value
              Node child = ((Node) pastNodes.get(pastNodes.size()-1)).getFirstChild();
              //*** NULL POINTER HERE
              //System.out.println(child.getNodeName()+" / "+child.getNodeType());
              if(child != null && child.getNodeName()=="#text"){System.out.println("Value: "+child.getNodeValue());}
              //remove child node from parent once read
              if(((Node) pastNodes.get(pastNodes.size()-1)).hasChildNodes()){
                   Node newNode = ((Node) pastNodes.get(pastNodes.size()-1)).removeChild(child);
                   pastNodes.remove(pastNodes.size()-1);
                   System.out.println("Child Removed: "+child.getNodeName());
                   pastNodes.add(newNode);
                   //deletes a node from list if it does not have any more children.
                   if(!((Node) pastNodes.get(pastNodes.size()-1)).hasChildNodes()){
                        System.out.println("Removed Past Node : "+(pastNodes.size()-1)+"/"+((Node) pastNodes.get(pastNodes.size()-1)).getNodeName());
                        pastNodes.remove(pastNodes.size()-1);
         System.out.println(((Node) pastNodes.get(pastNodes.size()-1)).hasChildNodes());
         }catch (SAXParseException err) {
         System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
         System.out.println(" " + err.getMessage ());
         }catch (SAXException e) {
         Exception x = e.getException ();
         ((x == null) ? e : x).printStackTrace ();
         }catch (Throwable t) {
         t.printStackTrace ();
              System.out.print("Done\n");
    ** And a snippet of the output at the console

    Here is my code...sorry that its so long :(There is no problem if the code is long. But atleast it should be formatted to help us read it.
    Node child = ((Node) pastNodes.get(pastNodes.size()-
    1)).getFirstChild();
              //*** NULL POINTER HERE
    //System.out.println(child.getNodeName()+"
    deName()+" / "+child.getNodeType());I think you get the NullPointerException when you call a method on the child node. The getFirstChild() method could return null if there is no child node. It is always good to check for nulls.

  • Tagged text from standford parser

    Hello all!
    I am using the nlp(Natural language processing).
    I am using the standford parser.
    My target is to get tagged text from standford parser,
    Example from here:
    http://nlp.stanford.edu:8080/parser/
    like :
    the screen is samsung is good
    output:
    the/DT screen/NN is/VBZ samsung/JJ is/VBZ good/JJ
    my code is:
       LexicalizedParser lp = new LexicalizedParser("C:\\englishPCFG.ser");
        lp.setOptionFlags(new String[]{"-maxLength", "80", "-retainTmpSubcategories"});
        String sent ="sound on samsung galaxy is the best.";
        Tree parse = (Tree) lp.apply(Arrays.asList(sent));
    //  parse.pennPrint();
        System.out.println();
        TreebankLanguagePack tlp = new PennTreebankLanguagePack();
        GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
        GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
        Collection tdl = gs.typedDependenciesCollapsed();
        TreeGraphNode sentence = new TreeGraph(parse).root();the api of this is here:
    http://tides.umiacs.umd.edu/webtrec/stanfordParser/javadoc/
    but I didnt find it.
    thanks for helping

    I am presuming that your question is that you don't know where to get the info from.
    So experiment.
    For example use Tree.pennPrint().
    And tdl is a collection. So iterate through that collection, get each item and print the properties of each

  • How to count number of lines inside methods() using the Doclet API

    Wrote a custom doclet using the [Doclet API|http://java.sun.com/j2se/1.3/docs/tooldocs/javadoc/doclet/index.html ] .
    The purpose for the doclet is to load Java source files and create stubs (which are identical Java source files but do not contain any method implementation details).
    Instead, the method implementation details need to be replaced with blank lines...
    public class MyDoclet {
         private static String TAB = "\t";
         public static boolean start(RootDoc root) {
              ClassDoc[] classes = root.classes();
              // Parse through class or interface
              for (ClassDoc clazz : classes) {
                   Type superClass = clazz.superclassType();     
                   // Print Methods
                   MethodDoc[] methods = clazz.methods();
                   for (MethodDoc method : methods) {
                        Parameter[] parameters = method.parameters();
                        println();
                        if (!method.isPrivate()) {
                             print(TAB + method.modifiers() + " "
                                                    + method.returnType().simpleTypeName() + " " + method.name());
                             print("(");
                             for (int i=0; i < parameters.length; i++) {
                                  Parameter parameter = (Parameter) parameters;
                                  print(parameter.type().simpleTypeName() + " " + parameter.name());
                                  if (i != parameters.length - 1) {
                                       print(", ");
                             print(")");
                             println(" {");
                             println("\n");
                             println(TAB + "}");
              return true;
    As one can see, I am just creating the method and placing the opening and closing curly braces (along with a new \n line escape sequence, in between).
    Am not really that familiar with the Doclet API...
    Question(s):
    (1) What is the best way to figure out how many lines of code are inside each method and then use a for loop to insert the exact same number of blank lines inside the methods?
    (2) Is there a way to do it using the com.sun.javadoc.SourcePosition.line() method?
    Would really appreciate it if someone could help me because this is an important requirement (hence the 10 Duke Stars).
    Happy coding to all,
    Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    This is not possible using the Doclet API, because JavaDoc does not store any information regarding implementation detail. Although MethodDoc#position will give you the line where the method is declared, there is no way to determine where the method body starts and ends.
    If you need that much information, maybe you would be better of using a tool such as Eclipse's Abstract Syntax Tree parser. AST will provide you with line numbers for each code expression, hence it is relatively easy to compute the first and last line in a method body.

  • XML data into itab

    Hi Experts,
    I have a XML file on my desk top.
    How to upload data from XML file into ITAB?
    Regards

    check this code
    this mat be useful to u
    REPORT  Z_NTVI_XML_TO_ABAP                      .
    Load iXML Lib.
    type-pools: ixml.
    class cl_ixml definition load.
    data: G_IXML type ref to if_ixml.
    data: STREAMFACTORY type ref to if_ixml_stream_factory.
    data: ISTREAM type ref to if_ixml_istream.
    data: DOCUMENT type ref to if_ixml_document.
    data: PARSER type ref to if_ixml_parser.
    data: LV_FILE_URL type rlgrap-filename.
    You should provide the parameter for file name
    LV_FILE_URL = 'C:input_xml.xml'.
    types: begin of XML_LINE,
            DATA(256) type x,
          end of XML_LINE.
    types: begin of TY_HEADER,
             CUST_NAME(20)     type c,
             CARD_NO(20)       type c,
             TAX_AMOUNT(10)    type c,
             TOTAL_AMOUNT(10)  type c,
           end of TY_HEADER.
    types: begin of TY_ITEM,
             ITEM_NO(4)      type n,
             ITEM_ID(20)     type c,
             ITEM_TITLE(50)  type c,
             ITEM_QTY(10)    type c,
             ITEM_UPRICE(10) type c,
           end of TY_ITEM.
    data: GV_HEADER type TY_HEADER.
    data: GT_ITEM   type standard table of TY_ITEM   with header line.
    data: XML_TABLE      type table of XML_LINE,
          XML_TABLE_SIZE type i.
    The next step is creating the main factory for the iXML library:
    G_IXML = cl_ixml=>create( ).
    Now Create Stream Factory
    STREAMFACTORY = G_IXML->create_stream_factory( ).
    upload a file from the client's workstation
    call function 'WS_UPLOAD'
         exporting
              filename   = LV_FILE_URL
              filetype   = 'BIN'
         importing
              filelength = XML_TABLE_SIZE
         tables
              data_tab   = XML_TABLE
         exceptions
              others     = 11.
    wrap the table containing the file into a stream
    ISTREAM = STREAMFACTORY->create_istream_itable( table = XML_TABLE
                                                    size  = XML_TABLE_SIZE )
    Get the file data as Stream
    *istream = streamfactory->create_istream_uri( public_id = lv_file_url
                                                system_id = lv_file_url ).
    Create XML Document instance
    DOCUMENT = G_IXML->create_document( ).
    Create parser Object
    PARSER = G_IXML->create_parser( stream_factory = STREAMFACTORY
                                    ISTREAM = istream
                                    DOCUMENT = document ).
    Parse an XML document into a DOM tree
    *parser->parse( ).
    Parsing Error Processing
    if PARSER->parse( ) ne 0.
      if PARSER->num_errors( ) ne 0.
        data: PARSEERROR type ref to if_ixml_parse_error,
              STR        type STRING,
              I          type i,
              COUNT      type I,
              INDEX      type i.
        COUNT = PARSER->num_errors( ).
        write: COUNT, ' parse errors have occured:'.
        INDEX = 0.
        while INDEX < COUNT.
          PARSEERROR = PARSER->get_error( INDEX = index ).
          I = PARSEERROR->get_line( ).
          write: 'line: ', i.
          I = PARSEERROR->get_column( ).
          write: 'column: ', i.
          STR = PARSEERROR->get_reason( ).
          write: STR.
          INDEX = index + 1.
        endwhile.
      endif.
    endif.
    Close the stream since it �s not needed anymore
    call method ISTREAM->close( ).
    clear ISTREAM.
    Now try to make it look good
    data : lv_size     type sytabix,
            lv_ret_code type sysubrc.
    data: lo_xml_document type ref to cl_xml_document.
    field-symbols: <fs_xml_data> type any table.
    lo_xml_document = document.
    call method lo_xml_document->get_as_table
       importing
         table   = <fs_xml_data>
         size    = lv_size
         retcode = lv_ret_code
    *data: items type ref to if_ixml_node_collection.
    *items = document->get_elements_by_tag_name( name = 'Item' ).
    *data: iterator type ref to if_ixml_node_iterator,
         node     type ref to if_ixml_node.
    *iterator = document->create_iterator( ).
    *node = iterator->get_next( ).
    *while not node is initial.
    do something with the node
    node = iterator->get_next( ).
    *endwhile.
    DATA : GV_NODE type ref to if_ixml_node.
    DATA : GV_NODETEXT type STRING.
    data:  GV_FIRST_TIME.
    GV_FIRST_TIME = 'X'.
    GV_NODE = DOCUMENT.
    GT_ITEM-item_no = 1.
    perform GET_DATA tables     GT_ITEM
                     using      GV_NODE
                     changing   GV_HEADER.
    Last item is still not added.
      append GT_ITEM.
    write  : GV_HEADER-cust_name,
             GV_HEADER-card_no,
             GV_HEADER-tax_amount,
             GV_HEADER-total_amount.
    loop at GT_ITEM.
      write  /:.
      write  : GT_ITEM-item_no,
               GT_ITEM-item_id,
               GT_ITEM-item_title,
               GT_ITEM-item_qty,
               GT_ITEM-item_uprice.
    endloop.
          FORM Get_data                                                 *
    form get_data tables   YT_ITEM    structure GT_ITEM
                  using value(x_node) type ref to if_ixml_node
                  changing Y_HEADER   type TY_HEADER.
      data: INDENT      type i.
      data: PTEXT       type ref to if_ixml_text.
      data: STRING      type string.
      data: TEMP_STRING(100).
      case X_NODE->get_type( ).
        when if_ixml_node=>co_node_element.
          STRING = X_NODE->get_name( ).
          GV_NODETEXT = STRING.
        when if_ixml_node=>co_node_text.
          PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
          if PTEXT->ws_only( ) is initial.
            STRING = X_NODE->get_value( ).
            case GV_NODETEXT.
              when 'Customer'.
                clear GV_HEADER.
              when 'Name'.
                move STRING to GV_HEADER-cust_name.
              when 'Cardnum'.
                move STRING to GV_HEADER-card_no.
              when 'Tax'.
                move STRING to GV_HEADER-tax_amount.
              when 'Total'.
                move STRING to GV_HEADER-total_amount.
            Iteam details
              when 'ID'.
                move STRING to GT_ITEM-item_id.
              when 'Title'.
                move STRING to TEMP_STRING.
                move TEMP_STRING to GT_ITEM-item_title.
              when 'Quantity'.
                move STRING to GT_ITEM-item_qty.
              when 'UnitPrice'.
                move STRING to GT_ITEM-item_uprice.
            endcase.
          endif.
      endcase.
      if GV_NODETEXT = 'Customer'.
        clear GV_HEADER.
      elseif GV_NODETEXT = 'Item'.
        if GV_FIRST_TIME ne 'X'.
           append GT_ITEM.
         clear : gt_item.
           GT_ITEM-item_no = gt_item-item_no + 1.
        endif.
        GV_FIRST_TIME = ' '.
      endif.
    Get the next child
      X_NODE = x_node->get_first_child( ).
    Recurse
      while not X_NODE is initial.
        perform GET_DATA tables     GT_ITEM
                         using      X_NODE
                         changing   GV_HEADER.
        X_NODE = x_node->get_next( ).
      endwhile.
    endform.
    *sample xml file
    <Name>Satya Mandiga</Name>
    <Cardnum>234 234 234 234</Cardnum>
    </Customer>
    <ID>209</ID>
    <Title>Duke: A Biography of the SAP Java Guru</Title>
    <Quantity>1</Quantity>
    <UnitPrice>Rs10.75</UnitPrice>
    </Item>
    <ID>208</ID>
    <Title>100% Pure: Making Cross Platform Deployment a Reality</Title>
    <Quantity>1</Quantity>
    <UnitPrice>Rs10.75</UnitPrice>
    </Item>
    <ID>204</ID>
    <Title>Making the Transition from C++ to the Java(tm)
    *Language</Title>
    <Quantity>1</Quantity>
    <UnitPrice>Rs10.75</UnitPrice>
    </Item>
    <ID>202</ID>
    <Title>Web Servers for Fun and Profit</Title>
    <Quantity>1</Quantity>
    <UnitPrice>Rs10.75</UnitPrice>
    </Item>
    <ID>210</ID>
    <Title>I Think Not: Dukes Likeness to the Federation Insignia</Title>
    <Quantity>1</Quantity>
    <UnitPrice>Rs10.75</UnitPrice>
    </Item>
    </Manifest>
    <Subtotal>Rs53.75</Subtotal>
    <Tax>Rs4.43</Tax>
    <Total>Rs58.18</Total>
    </Receipt>
    </Order>
    reward the points

  • XML data into sap

    Hi guys,
    How to upload a XML file into sap?
    is there any function module?
    can anybody give me an example program for converting or uploading XML data into sap.
    regards,
    vinoth.

    Hi all,
    The XML code and XML file given is running fine for me, but when i am using it, my XML file and code, the tables GV_header and GT_item are filling in the perform but outside perform it's empty.  Please find the code and XML file , PLease give the answer its urgent, points will be given for sure.
    My function module code is:-
    FUNCTION Z_MMI_XML_EXTRACT_COPY.
    ""Local interface:
    *"       IMPORTING
    *"             REFERENCE(DOCTYPE) LIKE  DRAW-DOKAR
    *"             REFERENCE(DOCNUM) LIKE  DRAW-DOKNR
    *"             REFERENCE(DOCVER) LIKE  DRAW-DOKVR
    *"             REFERENCE(DOCPART) LIKE  DRAW-DOKTL
    *"       TABLES
    *"              T_HEADER STRUCTURE  ZFI_HEADER
    *"              T_ITEMS STRUCTURE  ZFI_ITEMS
    Load iXML Lib.
    type-pools: ixml.
    class cl_ixml definition load.
    data: G_IXML type ref to if_ixml.
    data: STREAMFACTORY type ref to if_ixml_stream_factory.
    data: ISTREAM type ref to if_ixml_istream.
    data: DOCUMENT type ref to if_ixml_document.
    data: PARSER type ref to if_ixml_parser.
    You should provide the parameter for file name
    *LV_FILE_URL = 'C:input_xml.xml'.
    types: begin of XML_LINE,
            DATA(256) type x,
          end of XML_LINE.
    ***types: begin of TY_HEADER,
            CUST_NAME(20)     type c,
            CARD_NO(20)       type c,
            TAX_AMOUNT(10)    type c,
            TOTAL_AMOUNT(10)  type c,
          end of TY_HEADER.
    ***types: begin of TY_ITEM,
            ITEM_NO(4)      type n,
            ITEM_ID(20)     type c,
            ITEM_TITLE(50)  type c,
            ITEM_QTY(10)    type c,
            ITEM_UPRICE(10) type c,
          end of TY_ITEM.
    *data: GV_HEADER type TY_HEADER.
    *data: GV_HEADER like zfi_header occurs 0 with header line.
    data : GV_HEADER LIKE ZFI_HEADER.
    *data: GT_ITEM   type standard table of TY_ITEM   with header line.
    *data: GT_ITEM type standard table of zfi_items with header line.
    data: GT_ITEM type standard table of zfi_items with header line.
    data: XML_TABLE      type table of XML_LINE,
          XML_TABLE_SIZE type i.
    data: LV_FILE_URL type rlgrap-filename.
      DATA : BEGIN OF itab OCCURS 0,
      a(100) TYPE c,
      END OF itab.
      DATA: xml_out TYPE string .
      DATA : BEGIN OF upl OCCURS 0,
      f(255) TYPE c,
      END OF upl.
      DATA: xmlupl TYPE string .
      DATA : BEGIN OF wa_draw OCCURS 0,
             dokar LIKE draw-dokar,
             doknr LIKE draw-doknr,
             dokvr LIKE draw-dokvr,
             doktl LIKE draw-doktl,
             END OF wa_draw.
      DATA : g_documenttype LIKE bapi_doc_aux-doctype,
             g_documentnumber LIKE bapi_doc_aux-docnumber,
             g_documentpart LIKE bapi_doc_aux-docpart,
             g_documentversion LIKE bapi_doc_aux-docversion.
    *" Itab required in IMPORTING parameter of BAPI
      DATA : t_documentfile LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.
    DATA : t_documentstructure LIKE bapi_doc_structure OCCURS 0 WITH HEADER
    LINE,
    itab required in TABLES parameters of BAPI
           t_documentfiles LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,
           t_components LIKE bapi_doc_comp OCCURS 0 WITH HEADER LINE,
           t_return LIKE bapiret2.
      DATA : l_docfile TYPE string.
    ***FILL THE TYPE OF ATTACHMENT in IMPORTING itab**
      t_documentfile-wsapplication = 'XML'.
      APPEND t_documentfile.
      wa_draw-dokar = DOCTYPE.
      wa_draw-doknr = DOCNUM.
      wa_draw-doktl = DOCPART.
      wa_draw-dokvr = DOCVER.
      CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTVIEW2'
        EXPORTING
          documenttype              = wa_draw-dokar
          documentnumber            = wa_draw-doknr
          documentpart              = wa_draw-doktl
          documentversion           = wa_draw-dokvr
          documentfile              = t_documentfile "IMPORTING itab of BAPI
         getstructure              = '1'
         getcomponents             = 'X'
      ORIGINALPATH              = ' '
      HOSTNAME                  = ' '
         getheader                 = 'X'
      DOCBOMCHANGENUMBER        =
      DOCBOMVALIDFROM           =
      DOCBOMREVISIONLEVEL       =
       IMPORTING
         return                    = t_return
       TABLES
         documentstructure         = t_documentstructure
         documentfiles             = t_documentfiles "TABLES itab of BAPI
         components                = t_components
      LOOP AT t_documentfiles .
      ENDLOOP.
      l_docfile = t_documentfiles-docfile.
    The next step is creating the main factory for the iXML library:
    G_IXML = cl_ixml=>create( ).
    Now Create Stream Factory
    STREAMFACTORY = G_IXML->create_stream_factory( ).
      CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
    *filename = 'C:DMS_SPA.XML'
      filename = l_docfile
      filetype = 'BIN'
      IMPORTING
       FILELENGTH = XML_TABLE_SIZE
      TABLES
      data_tab = XML_TABLE.
    ISTREAM = STREAMFACTORY->create_istream_itable( table = XML_TABLE
                                                    size  = XML_TABLE_SIZE )
    Create XML Document instance
    DOCUMENT = G_IXML->create_document( ).
    Create parser Object
    PARSER = G_IXML->create_parser( stream_factory = STREAMFACTORY
                                    ISTREAM = istream
                                    DOCUMENT = document ).
    Parse an XML document into a DOM tree
    *parser->parse( ).
    Parsing Error Processing
    if PARSER->parse( ) ne 0.
      if PARSER->num_errors( ) ne 0.
        data: PARSEERROR type ref to if_ixml_parse_error,
              STR        type STRING,
              I          type i,
              COUNT      type I,
              INDEX      type i.
        COUNT = PARSER->num_errors( ).
        write: COUNT, ' parse errors have occured:'.
        INDEX = 0.
        while INDEX < COUNT.
          PARSEERROR = PARSER->get_error( INDEX = index ).
          I = PARSEERROR->get_line( ).
          write: 'line: ', i.
          I = PARSEERROR->get_column( ).
          write: 'column: ', i.
          STR = PARSEERROR->get_reason( ).
          write: STR.
          INDEX = index + 1.
        endwhile.
      endif.
    endif.
    Close the stream since it �s not needed anymore
    call method ISTREAM->close( ).
    clear ISTREAM.
    DATA : GV_NODE type ref to if_ixml_node.
    DATA : GV_NODETEXT type STRING.
    data:  GV_FIRST_TIME.
    GV_FIRST_TIME = 'X'.
    GV_NODE = DOCUMENT.
    *GT_ITEM-item_no = 1.
    GT_ITEM-itemno_acc = 1.
    perform GET_DATA tables     GT_ITEM
                     using      GV_NODE
                     changing   GV_HEADER.
    Last item is still not added.
      append GT_ITEM.
    APPEND GV_HEADER.
    *T_HEADER[] = gv_header[].
    t_items[] = gt_item[].
    **write  : GV_HEADER-cust_name,
            GV_HEADER-card_no,
            GV_HEADER-tax_amount,
            GV_HEADER-total_amount.
    **loop at GT_ITEM.
    write  /:.
    write  : GT_ITEM-item_no,
              GT_ITEM-item_id,
              GT_ITEM-item_title,
              GT_ITEM-item_qty,
              GT_ITEM-item_uprice.
    **endloop.
    ENDFUNCTION.
          FORM Get_data                                                 *
    ***form get_data tables   YT_ITEM    structure gt_ITEM
                 using value(x_node) type ref to if_ixml_node
                 changing Y_HEADER   type TY_HEADER.
    form get_data1 tables   YT_ITEM    structure zfi_items
                  using value(x_node) type ref to if_ixml_node
                  changing Y_HEADER   type zfi_header.
    ***form get_data tables   YT_ITEM    structure GT_ITEM
                 using value(x_node) type ref to if_ixml_node
                 changing Y_HEADER   type TY_HEADER.
      data: INDENT      type i.
      data: PTEXT       type ref to if_ixml_text.
      data: STRING      type string.
      data: TEMP_STRING(100).
      case X_NODE->get_type( ).
        when if_ixml_node=>co_node_element.
          STRING = X_NODE->get_name( ).
          GV_NODETEXT = STRING.
        when if_ixml_node=>co_node_text.
          PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
          if PTEXT->ws_only( ) is initial.
            STRING = X_NODE->get_value( ).
            case GV_NODETEXT.
             when 'Customer'.
                when 'HEADER'.
                clear GV_HEADER.
             when 'Name'.
               when 'INVOICE_IND'.
               move STRING to GV_HEADER-cust_name.
                move STRING to GV_HEADER-INVOICE_IND.
              when 'CompanyCode'.
                move STRING to GV_HEADER-CompanyCode.
              when 'OBJ_TYPE'.
                move STRING to GV_HEADER-OBJ_TYPE.
              when 'username'.
                move STRING to GV_HEADER-username.
              when 'PO_reference'.
                move STRING to GV_HEADER-PO_reference.
              when 'Invoice_Date'.
                move STRING to GV_HEADER-Invoice_Date.
              when 'Posting_Date'.
                move STRING to GV_HEADER-Posting_Date.
              when 'Amount'.
                move STRING to GV_HEADER-Amount.
              when 'Currency'.
                move STRING to GV_HEADER-Currency.
    *APPEND GV_HEADER.
            Iteam details
              when 'invoice_doc_item'.
                move STRING to GT_ITEM-ITEMNO_ACC.
              when 'currency'.
                move STRING to TEMP_STRING.
                move TEMP_STRING to GT_ITEM-CURRENCY.
              when 'Quantity'.
                move STRING to GT_ITEM-Quantity.
              when 'UoM'.
                move STRING to GT_ITEM-UoM.
            endcase.
          endif.
      endcase.
      if GV_NODETEXT = 'Header'.
        clear GV_HEADER.
      elseif GV_NODETEXT = 'Item'.
        if GV_FIRST_TIME ne 'X'.
           append GT_ITEM.
         clear : gt_item.
           GT_ITEM-ITEMNO_ACC = gt_item-itemno_acc + 1.
        endif.
        GV_FIRST_TIME = ' '.
      endif.
    Get the next child
      X_NODE = x_node->get_first_child( ).
    Recurse
      while not X_NODE is initial.
        perform GET_DATA tables     GT_ITEM
                         using      X_NODE
                         changing   GV_HEADER.
        X_NODE = x_node->get_next( ).
      endwhile.
    endform.
    the XML file is:-
    Thanx in advance

  • XML to ABAP

    hello all,
    my requirement is to read an XML file into a structure of type string, for that i have written an XSLT transformations but when am trying to pass the XML file to the parser am getting run time error saying
    XSLT_BAD_SOURCE_CONTEXT
    CX_XSLT_RUNTIME_ERROR
    below is the code for calling XSLT program
    TYPES: BEGIN OF ty_xml_line,
             data(256) TYPE x,
           END OF ty_xml_line.
    DATA: gt_in        type table of ty_xml_line,
              gt_out       type string.
    DATA: xslt_error   TYPE REF TO cx_xslt_exception,
              xslt_message TYPE string .
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename = 'T:\Documents and Settings\sgolla\Desktop\xmlorder1.xml'
      TABLES
        data_tab = gt_in.
    TRY .
        CALL TRANSFORMATION zord1
      SOURCE XML gt_in
      RESULT xml_output = gt_out .
      CATCH cx_xslt_exception INTO xslt_error.
        xslt_message = xslt_error->get_text( ).
    ENDTRY.
    please help me how to solve it......
    thx in advance
    Sippy.

    REPORT  ZSRK_022                                .
    Read XML file from presentation server*
    Load iXML Lib.
    TYPE-POOLS: IXML.
    CLASS CL_IXML DEFINITION LOAD.
    DATA: G_IXML TYPE REF TO IF_IXML.
    DATA: STREAMFACTORY TYPE REF TO IF_IXML_STREAM_FACTORY.
    DATA: ISTREAM TYPE REF TO IF_IXML_ISTREAM.
    DATA: DOCUMENT TYPE REF TO IF_IXML_DOCUMENT.
    DATA: PARSER TYPE REF TO IF_IXML_PARSER.
    DATA: LV_FILE_URL TYPE RLGRAP-FILENAME.
    You should provide the parameter for file name
    LV_FILE_URL = 'C:input_xml.xml'.
    TYPES: BEGIN OF XML_LINE,
            DATA(256) TYPE X,
          END OF XML_LINE.
    TYPES: BEGIN OF TY_HEADER,
             CUST_NAME(20)     TYPE C,
             CARD_NO(20)       TYPE C,
             TAX_AMOUNT(10)    TYPE C,
             TOTAL_AMOUNT(10)  TYPE C,
           END OF TY_HEADER.
    TYPES: BEGIN OF TY_ITEM,
             ITEM_NO(4)      TYPE N,
             ITEM_ID(20)     TYPE C,
             ITEM_TITLE(50)  TYPE C,
             ITEM_QTY(10)    TYPE C,
             ITEM_UPRICE(10) TYPE C,
           END OF TY_ITEM.
    DATA: GV_HEADER TYPE TY_HEADER.
    DATA: GT_ITEM   TYPE STANDARD TABLE OF TY_ITEM   WITH HEADER LINE.
    DATA: XML_TABLE      TYPE TABLE OF XML_LINE,
          XML_TABLE_SIZE TYPE I.
    The next step is creating the main factory for the iXML library:
    G_IXML = CL_IXML=>CREATE( ).
    Now Create Stream Factory
    STREAMFACTORY = G_IXML->CREATE_STREAM_FACTORY( ).
    upload a file from the client's workstation
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        FILENAME   = LV_FILE_URL
        FILETYPE   = 'BIN'
      IMPORTING
        FILELENGTH = XML_TABLE_SIZE
      TABLES
        DATA_TAB   = XML_TABLE
      EXCEPTIONS
        OTHERS     = 11.
    wrap the table containing the file into a stream
    ISTREAM = STREAMFACTORY->CREATE_ISTREAM_ITABLE( TABLE = XML_TABLE
                                                    SIZE  = XML_TABLE_SIZE ).
    Create XML Document instance
    DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
    Create parser Object
    PARSER = G_IXML->CREATE_PARSER( STREAM_FACTORY = STREAMFACTORY
                                    ISTREAM = ISTREAM
                                    DOCUMENT = DOCUMENT ).
    Parse an XML document into a DOM tree
    *parser-&gtparse( ).
    Parsing Error Processing
    IF PARSER->PARSE( ) NE 0.
      IF PARSER->NUM_ERRORS( ) NE 0.
        DATA: PARSEERROR TYPE REF TO IF_IXML_PARSE_ERROR,
              STR        TYPE STRING,
              I          TYPE I,
              COUNT      TYPE I,
              INDEX      TYPE I.
        COUNT = PARSER->NUM_ERRORS( ).
        WRITE: COUNT, ' parse errors have occured:'.
        INDEX = 0.
        WHILE INDEX < COUNT.
          PARSEERROR = PARSER->GET_ERROR( INDEX = INDEX ).
          I = PARSEERROR->GET_LINE( ).
          WRITE: 'line: ', I.
          I = PARSEERROR->GET_COLUMN( ).
          WRITE: 'column: ', I.
          STR = PARSEERROR->GET_REASON( ).
          WRITE: STR.
          INDEX = INDEX + 1.
        ENDWHILE.
      ENDIF.
    ENDIF.
    Close the stream since it �s not needed anymore
    CALL METHOD ISTREAM->CLOSE( ).
    CLEAR ISTREAM.
    DATA : GV_NODE TYPE REF TO IF_IXML_NODE.
    DATA : GV_NODETEXT TYPE STRING.
    DATA:  GV_FIRST_TIME.
    GV_FIRST_TIME = 'X'.
    GV_NODE = DOCUMENT.
    GT_ITEM-ITEM_NO = 1.
    PERFORM GET_DATA TABLES     GT_ITEM
                     USING      GV_NODE
                     CHANGING   GV_HEADER.
    Last item is still not added.
    APPEND GT_ITEM.
    WRITE  : GV_HEADER-CUST_NAME,
             GV_HEADER-CARD_NO,
             GV_HEADER-TAX_AMOUNT,
             GV_HEADER-TOTAL_AMOUNT.
    LOOP AT GT_ITEM.
      WRITE  /:.
      WRITE  : GT_ITEM-ITEM_NO,
               GT_ITEM-ITEM_ID,
               GT_ITEM-ITEM_TITLE,
               GT_ITEM-ITEM_QTY,
               GT_ITEM-ITEM_UPRICE.
    ENDLOOP.
          FORM Get_data                                                 *
    FORM GET_DATA TABLES   YT_ITEM    STRUCTURE GT_ITEM
                  USING VALUE(X_NODE) TYPE REF TO IF_IXML_NODE
                  CHANGING Y_HEADER   TYPE TY_HEADER.
      DATA: INDENT      TYPE I.
      DATA: PTEXT       TYPE REF TO IF_IXML_TEXT.
      DATA: STRING      TYPE STRING.
      DATA: TEMP_STRING(100).
      CASE X_NODE->GET_TYPE( ).
        WHEN IF_IXML_NODE=>CO_NODE_ELEMENT.
          STRING = X_NODE->GET_NAME( ).
          GV_NODETEXT = STRING.
        WHEN IF_IXML_NODE=>CO_NODE_TEXT.
          PTEXT ?= X_NODE->QUERY_INTERFACE( IXML_IID_TEXT ).
          IF PTEXT->WS_ONLY( ) IS INITIAL.
            STRING = X_NODE->GET_VALUE( ).
            CASE GV_NODETEXT.
              WHEN 'Customer'.
                CLEAR GV_HEADER.
              WHEN 'Name'.
                MOVE STRING TO GV_HEADER-CUST_NAME.
              WHEN 'Cardnum'.
                MOVE STRING TO GV_HEADER-CARD_NO.
              WHEN 'Tax'.
                MOVE STRING TO GV_HEADER-TAX_AMOUNT.
              WHEN 'Total'.
                MOVE STRING TO GV_HEADER-TOTAL_AMOUNT.
            Iteam details
              WHEN 'ID'.
                MOVE STRING TO GT_ITEM-ITEM_ID.
              WHEN 'Title'.
                MOVE STRING TO TEMP_STRING.
                MOVE TEMP_STRING TO GT_ITEM-ITEM_TITLE.
              WHEN 'Quantity'.
                MOVE STRING TO GT_ITEM-ITEM_QTY.
              WHEN 'UnitPrice'.
                MOVE STRING TO GT_ITEM-ITEM_UPRICE.
            ENDCASE.
          ENDIF.
      ENDCASE.
      IF GV_NODETEXT = 'Customer'.
        CLEAR GV_HEADER.
      ELSEIF GV_NODETEXT = 'Item'.
        IF GV_FIRST_TIME NE 'X'.
          APPEND GT_ITEM.
         clear : gt_item.
          GT_ITEM-ITEM_NO = GT_ITEM-ITEM_NO + 1.
        ENDIF.
        GV_FIRST_TIME = ' '.
      ENDIF.
    Get the next child
      X_NODE = X_NODE->GET_FIRST_CHILD( ).
    Recurse
      WHILE NOT X_NODE IS INITIAL.
        PERFORM GET_DATA TABLES     GT_ITEM
                         USING      X_NODE
                         CHANGING   GV_HEADER.
        X_NODE = X_NODE->GET_NEXT( ).
      ENDWHILE.
    ENDFORM.                    "get_data

  • Convert XML to SAP internal table

    Hi gurus,
    My program is suppose to get current exchange rate file from website and upload it in SAP.
    by using FM 'HTTP_GET', im getting the data in XML format.My problem is..i have tried to use transformation but failed to
    map it against XML data element..and i have tried to use CALL FUNCTION 'SCMS_TEXT_TO_XSTRING' and then CALL FUNCTION 'SMUM_XML_PARSE' but it returns initial value with error ''line   0 col  12-unexpected symbol: '>'' .
    Below is an excerpt of my XML file:
    ..<xml version>
    ..<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    .. xmlns:o="urn:schemas-microsoft-com:office:office"
    .. xmlns:x="urn:schemas-    microsoft-com:office:excel"
    .. xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
    .. <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>10875</WindowHeight>........ <WindowWidth>13260</WindowWidth><WindowTopX>480</WindowTopX><WindowTopY>30</Wind
    ..  <Style ss:ID="Default" ss:Name="Normal">
    ..  <Alignment ss:Vertical="Bottom"/>
    ..  <Borders/>
    ..  <Font/>
    ..  <Interior/>
    ..  <NumberFormat/>
    ..  <Protection/>
    ..  </Style>
    ..  <Style ss:ID="BoldColumn">
    ..  <Font ss:FontName="Microsoft Sans Serif" x:Family="Swiss" ss:Bold="1"/>
    .. <Worksheet ss:Name="Page1"><Table ss:StyleID="s21"   > <Column   ss:Width="130"/> <Column   ss:Width="85"/> <Column   .. ss:Width="85"/> <Column   ss:Width="85"/> <Column   ss:Widt
    .. Cell><Cell ss:MergeAcross="1" ss:StyleID="BoldColumn"><Data ss:Type="String">Average Buying Rates</Data></Cell><Cell .. ss:MergeDown="1" ss:StyleID="BoldColumn"><Data ss:Type="Stri
    .. ss:Type="Number">47.3732</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">47.5374</Data></Cell><Cell .. ss:StyleID="Decimal"><Data ss:Type="Number">48.2323</Data></Ce
    .. "  ><Data ss:Type="String">HONG KONG</Data></Cell><Cell ss:StyleID="StringLiteralCenter"  ><Data .. .. ss:Type="String">HKD</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Numb
    .. ss:Type="Number">22.8131</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">23.2595</Data></Cell>.. .. </Row><Row><Cell ss:StyleID="StringLiteral"  ><Data ss:Type="String"
    .. ss:StyleID="StringLiteralCenter"  ><Data ss:Type="String">IDR</Data></Cell><Cell ss:StyleID="Decimal"><Data .. ss:Type="Number">3.0395</Data></Cell><Cell ss:StyleID="Decimal"><Data
    .. ecimal"><Data ss:Type="Number">30.6424</Data></Cell></Row><Row><Cell ss:StyleID="StringLiteral"  ><Data .. ss:Type="String">AUSTRALIA</Data></Cell><Cell ss:StyleID="StringLiteralCe
    .. ell ss:StyleID="Decimal"><Data ss:Type="Number">0.3392</Data></Cell><Cell ss:StyleID="Decimal"><Data .. ss:Type="Number">0.3409</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Typ
    .. StringLiteral"  ><Data ss:Type="String">DENMARK</Data></Cell><Cell ss:StyleID="StringLiteralCenter"  ><Data .. ss:Type="String">DKK</Data></Cell><Cell ss:StyleID="Decimal"><Data ss
    .. ata ss:Type="Number">4.4550</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">4.6073</Data></Cell>.. </Row><Row></Row><Row></Row><Row><Cell ss:MergeAcross="4" ss:Style
    .. s of   23 November 2010</Data></Cell></Row><Row></Row><Row><Cell ss:MergeAcross="4" .. ss:StyleID="BoldColumn_Left" ><Data ss:Type="String">2. Foreign Exchange Rates (THOMSON REUTE
    ..  ><Data ss:Type="String">ZAR</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">4.2735</Data></Cell>.. <Cell ss:StyleID="Decimal"><Data ss:Type="Number">4.3125</Data></
    .. ="Decimal"><Data ss:Type="Number">106.5459</Data></Cell><Cell ss:StyleID="Decimal"><Data .. ss:Type="Number">107.5164</Data></Cell></Row><Row><Cell ss:StyleID="StringLiteral"  ><Da
    .. a></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">4.6916</Data></Cell></Row><Row><Cell .. ss:StyleID="StringLiteral"  ><Data ss:Type="String">BANGLADESH</Data></Cell><Cell
    .. r">0.0074</Data></Cell></Row><Row><Cell ss:StyleID="StringLiteral"  ><Data ss:Type="String">KENYA</Data></Cell><Cell .. ss:StyleID="StringLiteralCenter"  ><Data ss:Type="String">KE
    .. ><Cell ss:StyleID="StringLiteral"  ><Data ss:Type="String">VIET NAM</Data></Cell><Cell ss:StyleID="StringLiteralCenter"  >.. <Data ss:Type="String">VND</Data></Cell><Cell ss:StyleI
    .. A</Data></Cell><Cell ss:StyleID="StringLiteralCenter"  ><Data ss:Type="String">LKR</Data></Cell><Cell .. .. ss:StyleID="Decimal"><Data ss:Type="Number">0.2686</Data></Cell><Cell ss:St
    .. String">OMR</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">77.7094</Data></Cell><Cell
    Please help me to translate my XML file into SAP format...i need it fixed urgently..
    Edited by: Guest101 on Dec 28, 2010 12:11 PM

    It has 2 part one is source code and another is the XML file
    create an XML file with the data provided in the last 2.
    then place it in a path mention the path in the below source.
    1. Complete code for converting XML to internal table in SAP.
    *& Report  ZTST_PGM02
    REPORT  ZTST_PGM02.
    Load iXML Lib.
    type-pools: ixml.
    class cl_ixml definition load.
    data: G_IXML type ref to if_ixml.
    data: STREAMFACTORY type ref to if_ixml_stream_factory.
    data: ISTREAM type ref to if_ixml_istream.
    data: DOCUMENT type ref to if_ixml_document.
    data: PARSER type ref to if_ixml_parser.
    data: LV_FILE_URL type rlgrap-filename.
    You should provide the parameter for file name
    LV_FILE_URL = 'D:\navps\input_xml.xml'.
    types: begin of XML_LINE,
            DATA(256) type x,
          end of XML_LINE.
    types: begin of TY_HEADER,
             CUST_NAME(20)     type c,
             CARD_NO(20)       type c,
             TAX_AMOUNT(10)    type c,
             TOTAL_AMOUNT(10)  type c,
           end of TY_HEADER.
    types: begin of TY_ITEM,
             ITEM_NO(4)      type n,
             ITEM_ID(20)     type c,
             ITEM_TITLE(50)  type c,
             ITEM_QTY(10)    type c,
             ITEM_UPRICE(10) type c,
           end of TY_ITEM.
    data: GV_HEADER type TY_HEADER.
    data: GT_ITEM   type standard table of TY_ITEM  with header line.
    data: XML_TABLE      type table of XML_LINE,
          XML_TABLE_SIZE type i.
    The next step is creating the main factory for the iXML library:
    G_IXML = cl_ixml=>create( ).
    Now Create Stream Factory
    STREAMFACTORY = G_IXML->create_stream_factory( ).
    upload a file from the client's workstation
    call function 'WS_UPLOAD'
         exporting
              filename   = LV_FILE_URL
              filetype   = 'BIN'
         importing
              filelength = XML_TABLE_SIZE
         tables
              data_tab   = XML_TABLE
         exceptions
              others     = 11.
    wrap the table containing the file into a stream
    ISTREAM = STREAMFACTORY->create_istream_itable( table = XML_TABLE
                                                    size  = XML_TABLE_SIZE )
    Get the file data as Stream
    *istream = streamfactory->create_istream_uri( public_id = lv_file_url
                                                system_id = lv_file_url ).
    Create XML Document instance
    DOCUMENT = G_IXML->create_document( ).
    Create parser Object
    PARSER = G_IXML->create_parser( stream_factory = STREAMFACTORY
                                    ISTREAM = istream
                                    DOCUMENT = document ).
    Parse an XML document into a DOM tree
    *parser->parse( ).
    Parsing Error Processing
    if PARSER->parse( ) ne 0.
      if PARSER->num_errors( ) ne 0.
        data: PARSEERROR type ref to if_ixml_parse_error,
              STR        type STRING,
              I          type i,
              COUNT      type I,
              INDEX      type i.
        COUNT = PARSER->num_errors( ).
        write: COUNT, ' parse errors have occured:'.
        INDEX = 0.
        while INDEX < COUNT.
          PARSEERROR = PARSER->get_error( INDEX = index ).
          I = PARSEERROR->get_line( ).
          write: 'line: ', i.
          I = PARSEERROR->get_column( ).
          write: 'column: ', i.
          STR = PARSEERROR->get_reason( ).
          write: STR.
          INDEX = index + 1.
        endwhile.
      endif.
    endif.
    Close the stream since it #s not needed anymore
    call method ISTREAM->close( ).
    clear ISTREAM.
    Now try to make it look good
    data : lv_size     type sytabix,
            lv_ret_code type sysubrc.
    data: lo_xml_document type ref to cl_xml_document.
    field-symbols: <fs_xml_data> type any table.
    lo_xml_document = document.
    call method lo_xml_document->get_as_table
       importing
         table   = <fs_xml_data>
         size    = lv_size
         retcode = lv_ret_code
    *data: items type ref to if_ixml_node_collection.
    *items = document->get_elements_by_tag_name( name = 'Item' ).
    *data: iterator type ref to if_ixml_node_iterator,
         node     type ref to if_ixml_node.
    *iterator = document->create_iterator( ).
    *node = iterator->get_next( ).
    *while not node is initial.
    do something with the node
    node = iterator->get_next( ).
    *endwhile.
    DATA : GV_NODE type ref to if_ixml_node.
    DATA : GV_NODETEXT type STRING.
    data:  GV_FIRST_TIME.
    GV_FIRST_TIME = 'X'.
    GV_NODE = DOCUMENT.
    GT_ITEM-item_no = 1.
    perform GET_DATA tables     GT_ITEM
                     using      GV_NODE
                     changing   GV_HEADER.
    Last item is still not added.
      append GT_ITEM.
    write  : GV_HEADER-cust_name,
             GV_HEADER-card_no,
             GV_HEADER-tax_amount,
             GV_HEADER-total_amount.
    loop at GT_ITEM.
      write  /:.
      write  : GT_ITEM-item_no,
               GT_ITEM-item_id,
               GT_ITEM-item_title,
               GT_ITEM-item_qty,
               GT_ITEM-item_uprice.
    endloop.
          FORM Get_data                                                 *
    form get_data tables   YT_ITEM    structure GT_ITEM
                  using value(x_node) type ref to if_ixml_node
                  changing Y_HEADER   type TY_HEADER.
      data: INDENT      type i.
      data: PTEXT       type ref to if_ixml_text.
      data: STRING      type string.
      data: TEMP_STRING(100).
      case X_NODE->get_type( ).
        when if_ixml_node=>co_node_element.
          STRING = X_NODE->get_name( ).
          GV_NODETEXT = STRING.
        when if_ixml_node=>co_node_text.
          PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
          if PTEXT->ws_only( ) is initial.
            STRING = X_NODE->get_value( ).
            case GV_NODETEXT.
              when 'Customer'.
                clear GV_HEADER.
              when 'Name'.
                move STRING to GV_HEADER-cust_name.
              when 'Cardnum'.
                move STRING to GV_HEADER-card_no.
              when 'Tax'.
                move STRING to GV_HEADER-tax_amount.
              when 'Total'.
                move STRING to GV_HEADER-total_amount.
            Iteam details
              when 'ID'.
                move STRING to GT_ITEM-item_id.
              when 'Title'.
                move STRING to TEMP_STRING.
                move TEMP_STRING to GT_ITEM-item_title.
              when 'Quantity'.
                move STRING to GT_ITEM-item_qty.
              when 'UnitPrice'.
                move STRING to GT_ITEM-item_uprice.
            endcase.
          endif.
      endcase.
      if GV_NODETEXT = 'Customer'.
        clear GV_HEADER.
      elseif GV_NODETEXT = 'Item'.
        if GV_FIRST_TIME ne 'X'.
           append GT_ITEM.
         clear : gt_item.
           GT_ITEM-item_no = gt_item-item_no + 1.
        endif.
        GV_FIRST_TIME = ' '.
      endif.
    Get the next child
      X_NODE = x_node->get_first_child( ).
    Recurse
      while not X_NODE is initial.
        perform GET_DATA tables     GT_ITEM
                         using      X_NODE
                         changing   GV_HEADER.
        X_NODE = x_node->get_next( ).
      endwhile.
    endform.
    Create an XML file with the following DATA given below and place it in the path mentioned above source code.
    2. XML File DATA. You create an XML File in this format to test the same.
      <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
    - <Order>
    - <Customer>
      <Name>Bill Buckram</Name>
      <Cardnum>234 234 234 234</Cardnum>
      </Customer>
    - <Manifest>
    - <Item>
      <ID>209</ID>
      <Title>Duke: A Biography of the Java Evangelist</Title>
      <Quantity>1</Quantity>
      <UnitPrice>$10.75</UnitPrice>
      </Item>
    - <Item>
      <ID>208</ID>
      <Title>100% Pure: Making Cross Platform Deployment a Reality</Title>
      <Quantity>1</Quantity>
      <UnitPrice>$10.75</UnitPrice>
      </Item>
    - <Item>
      <ID>204</ID>
      <Title>Making the Transition from C++ to the Java(tm) Language</Title>
      <Quantity>1</Quantity>
      <UnitPrice>$10.75</UnitPrice>
      </Item>
    - <Item>
      <ID>202</ID>
      <Title>Web Servers for Fun and Profit</Title>
      <Quantity>1</Quantity>
      <UnitPrice>$10.75</UnitPrice>
      </Item>
    - <Item>
      <ID>210</ID>
      <Title>I Think Not: Dukes Likeness to the Federation Insignia</Title>
      <Quantity>1</Quantity>
      <UnitPrice>$10.75</UnitPrice>
      </Item>
      </Manifest>
    - <Receipt>
      <Subtotal>$53.75</Subtotal>
      <Tax>$4.43</Tax>
      <Total>$58.18</Total>
      </Receipt>
      </Order>

  • Treating a text file as a database

    I would like to create a database in the form of a simple text file and use Java to access/maintain it.
    I was thinking at first that JDBC-ODBC would be the way to go but I'm having syntax problems.
    Is there a better way to handle this? Or perhaps does someone have a good example they could share with me?

    If you already know SQL, writing your own JDBC driver that will create and access XML documents is easy
    by John B. O'Donahue
    As Java programmers, we have probably all used JDBC drivers. But until I received a project that was shipped without the commercial database it was built around, I had never thought of writing my own JDBC driver.
    A major factor in my decision to attempt writing my own driver was that I was creating XML documents from my database tables anyway. It made sense to use the XML documents as my storage medium, and either replace the entire interface with a DOM interface, or write a JDBC driver to interface to the XML. Well, I hate ripping out code that works, and writing a JDBC driver looked like a lot of fun, so the decision was easy.
    The main limitation of XML parsers is that they address the mechanics of the document, although the user is generally much more interested in content. The JDBC API, on the other hand, is geared toward handling data. A marriage of the two can give you the best of both worlds, particularly when you consider that a huge percentage of the XML on the Web was generated automatically from a database in the first place.
    In this article, we'll be using the moreover.com news feeds as a real-world example of a practical use of XML. This example also shows off the advantages of a SQL-based approach. We really just want to scan for stories that interest the user, in much the same way as we scan newspaper headlines. A SQL query for headlines containing specific topics is a much more natural, content-oriented approach than a tree-parsing model, which is essentially document oriented.
    http://www.devx.com/premier/mgznarch/Javapro/2001/01dec01/jo0112/jo0112-1.asp

  • Workin with threads

    Hello all!
    I am writing a project that works with nlp(natural language parser),I am using the stanford parser.
    I create a thread pool that takes sentances and run the parser with them.
    when I create one thread its all works fine but when I create more I get errors.
    the "test" procedure is findings words that have some connections.
    If I do an synchronized its supposed to work like one thread but still I get errors.
    My problem is that I have errors on this code:
    public synchronized String test(String s,LexicalizedParser lp ){
        if (s.isEmpty()) return "";
        if (s.length()>80) return "";
        System.out.println(s);
        String[] sent = s.split(" ");
    Tree parse = (Tree) lp.apply(Arrays.asList(sent));
    TreebankLanguagePack tlp = new PennTreebankLanguagePack();
    GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
    GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
    Collection tdl = gs.typedDependenciesCollapsed();
    List list = new ArrayList(tdl);
    //for (int i=0;i<list.size();i++)
    //System.out.println(list.get(1).toString());
    //remove scops and numbers like sbj(screen-4,good-6)->screen good
    Pattern p = Pattern.compile(".*\\((.*?)\\-\\d+,(.*?)\\-\\d+\\).*");
           if (list.size()>2){
        // Split input with the pattern
            Matcher m = p.matcher(list.get(1).toString());
            //check if the result have more than  1 groups
           if (m.find()&& m.groupCount()>1){
               if (m.groupCount()>1)
                   System.out.println(list);
    return  m.group(1)+m.group(2);
            return "";
    }the errors are:
    at blogsOpinions.ThreadPoolTest$1.run(ThreadPoolTest.java:50)
    at blogsOpinions.ThreadPool$PooledThread.run(ThreadPoolTest.java:196)
    Recovering using fall through strategy: will construct an (X ...) tree.
    Exception in thread "PooledThread-6" java.lang.ClassCastException: java.lang.String cannot be cast to edu.stanford.nlp.ling.HasWord
    at edu.stanford.nlp.parser.lexparser.LexicalizedParser.apply(LexicalizedParser.java:289)
    java.lang.NullPointerException
    at edu.stanford.nlp.parser.lexparser.Debinarizer.transformTreeHelper(Debinarizer.java:25)
    at edu.stanford.nlp.parser.lexparser.Debinarizer.transformTreeHelper(Debinarizer.java:33)
    at edu.stanford.nlp.parser.lexparser.Debinarizer.transformTreeHelper(Debinarizer.java:33)
    at edu.stanford.nlp.parser.lexparser.Debinarizer.transformTreeHelper(Debinarizer.java:33)
    at edu.stanford.nlp.parser.lexparser.Debinarizer.transformTreeHelper(Debinarizer.java:33)
    at edu.stanford.nlp.parser.lexparser.Debinarizer.transformTreeHelper(Debinarizer.java:33)
    at edu.stanford.nlp.parser.lexparser.Debinarizer.transformTree(Debinarizer.java:46)
    thanks!

    The full exptions are:
    Task 205: start
    Task 206: start
    Task 207: start
            at java.util.ArrayList.RangeCheck(ArrayList.java:547)
            at java.util.ArrayList.get(ArrayList.java:322)
            at edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.initializeChart(ExhaustivePCFGParser.java:1236)
            at edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.parse(ExhaustivePCFGParser.java:388)
            at edu.stanford.nlp.parser.lexparser.LexicalizedParser.parse(LexicalizedParser.java:372)
    Task 208: start
    Task 210: start
    Task 211: startthe code that have this is
        // Positional Access Operations
         * Returns the element at the specified position in this list.
         * @param  index index of the element to return
         * @return the element at the specified position in this list
         * @throws IndexOutOfBoundsException {@inheritDoc}
        public E get(int index) {
         RangeCheck(index);
         return (E) elementData[index];
        }and
         * Checks if the given index is in range.  If not, throws an appropriate
         * runtime exception.  This method does *not* check if the index is
         * negative: It is always used immediately prior to an array access,
         * which throws an ArrayIndexOutOfBoundsException if index is negative.
        private void RangeCheck(int index) {
         if (index >= size)
             throw new IndexOutOfBoundsException(
              "Index: "+index+", Size: "+size);
        }in this
    Tree parse = (Tree) lp.apply(s);
    Task 217: start
    Task 218: start
            at edu.stanford.nlp.parser.lexparser.LexicalizedParser.apply(LexicalizedParser.java:276)
            at blogsOpinions.ParserText.test(ParserText.java:174)
            at blogsOpinions.ParserText.insertDb(ParserText.java:67)
            at blogsOpinions.ParserText.<init>(ParserText.java:47)
            at blogsOpinions.ThreadPoolTest$1.run(ThreadPoolTest.java:50)
    Task 220: start
    Task 221: startthe exceptions are full and not cut
    thanks

  • Error finding a file

    I've downloaded and installed the Stanford Parser to use with a project of mine and I am having problems with running the Demo of it.
    I'm getting an error which is listed below:
    Loading parser from serialized file englishPCFG.ser.gz ...
    Exception in thread "main" java.lang.RuntimeException: File not found: englishPCFG.ser.gz
         at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserDataFromSerializedFile(LexicalizedParser.java:831)
         at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserDataFromFile(LexicalizedParser.java:608)
         at edu.stanford.nlp.parser.lexparser.LexicalizedParser.<init>(LexicalizedParser.java:174)
         at edu.stanford.nlp.parser.lexparser.LexicalizedParser.<init>(LexicalizedParser.java:160)
         at ParserDemo.main(ParserDemo.java:7)
    Caused by: java.io.FileNotFoundException: englishPCFG.ser.gz (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at edu.stanford.nlp.io.IOUtils.readStreamFromString(IOUtils.java:231)
         at edu.stanford.nlp.parser.lexparser.LexicalizedParser.getParserDataFromSerializedFile(LexicalizedParser.java:818)
         ... 4 more
    I have checked to see if the englishPCFG.ser.gz file is there and it is. I also checked to see where the file is being called from. the default location which has been provided with the program is
    "/u/nlp/data/lexparser/englishPCFG.ser.gz"
    the actual file is located in
    C:\Documents and Settings\Mitesh\Desktop\eclipse\stanford-parser-2010-02-26\stanford-parser-2010-02-26\englishPCFG.ser.gz
    I tried to input this location into the code but it still comes up with the same error.m

    Sorry, I've just been trying to get it to work all weekend and haven't had any luck.
    import java.util.*;
    import edu.stanford.nlp.trees.*;
    import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
    class ParserDemo {
      @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        LexicalizedParser lp = new LexicalizedParser("englishPCFG.ser.gz");
        lp.setOptionFlags(new String[]{"-maxLength", "80", "-retainTmpSubcategories"});
        String[] sent = { "This", "is", "an", "easy", "sentence", "." };
        Tree parse = (Tree) lp.apply(Arrays.asList(sent));
        parse.pennPrint();
        System.out.println();
    TreebankLanguagePack tlp = new PennTreebankLanguagePack();
    GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
      GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
      Collection tdl = gs.typedDependenciesCollapsed();
      System.out.println(tdl);
      System.out.println();
        TreePrint tp = new TreePrint("penn,typedDependenciesCollapsed");
        tp.printTree(parse);
    }this is a snippit of the LexicalizedParser Class where the source is defined.
    public Options getOp() {
        return op;
      private Options op;
      private static final String SERIALIZED_PARSER_PROPERTY = "edu.stanford.nlp.SerializedLexicalizedParser";
      //private static final String DEFAULT_PARSER_LOC = "/u/nlp/data/lexparser/englishPCFG.ser.gz";
      private static final String DEFAULT_PARSER_LOC = "C:/Documents and Settings/Mitesh/Desktop/eclipse/stanford-parser-2010-02-26/bin/englishPCFG.ser.gz";i commented the original line out and added my location here.

  • How to get nodes from nlp

    Hello all!
    My mean problem is that I dont know how to extract nodes from GrammaticalStructure.
    I am using englishPCFG.ser in java netbeans.
    My target is o know the quality of the screen like:
    the screen of iphone 4 is great.
    I want to extract screen and great.
    how can i extract the NN (screen) and VP (great)
    the code that I wrote is:
    LexicalizedParser lp = new LexicalizedParser("C:\\englishPCFG.ser");
        lp.setOptionFlags(new String[]{"-maxLength", "80", "-retainTmpSubcategories"});
        String sent ="the screen is very good.";
        Tree parse = (Tree) lp.apply(Arrays.asList(sent));
       parse.pennPrint();
        System.out.println();
        TreebankLanguagePack tlp = new PennTreebankLanguagePack();
        GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
        GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
        Collection tdl = gs.typedDependenciesCollapsed();thanks for helping

    NLP as Natural language processing, I assume : that bears some explicit acronym resolution, since, as you may have noticed, you have posted on a "general" java programming forum, where many won't know that - I didn't, I just ggogled it :o).
    Moreover, you don't make it explicit whether you are using a library; apparently, yes, presumably, JavaNLP, which again would bear some linking and reference... Again, not everyone may have heard of it (I hadn't, until one minute ago!).
    Then, maybe you'll have more chance asking such specific questions on a specific forum devoted to your library.
    Have you done so, and do you deem the investigations so far lead you to a general Java question rather than to library specifics? Then link or quote or sum up what you have investigated so far ("I dont know how to" and "the code that I wrote is:...", although clear as to what you want, is rather short in terms of describing what you have tried so far).
    Eventually, the library I mentioned seems to have rather extensive online Javadocs (I know nothing of the domain): have you read that?
    Best regards,
    J.

  • Database Update and Client Pull

    HI,
    I want to develop a functionality in which whenever a data changes in the database table then i want to refresh the jsp page that displays the information.
    Is there any easy way apart from using a client pull with a fixed interval limit? Something like a database trigger could be trapped and that information sent to the server??
    Any opinions? A sample working code would be highly appreciated.
    Thanks
    Anu

    If you already know SQL, writing your own JDBC driver that will create and access XML documents is easy
    by John B. O'Donahue
    As Java programmers, we have probably all used JDBC drivers. But until I received a project that was shipped without the commercial database it was built around, I had never thought of writing my own JDBC driver.
    A major factor in my decision to attempt writing my own driver was that I was creating XML documents from my database tables anyway. It made sense to use the XML documents as my storage medium, and either replace the entire interface with a DOM interface, or write a JDBC driver to interface to the XML. Well, I hate ripping out code that works, and writing a JDBC driver looked like a lot of fun, so the decision was easy.
    The main limitation of XML parsers is that they address the mechanics of the document, although the user is generally much more interested in content. The JDBC API, on the other hand, is geared toward handling data. A marriage of the two can give you the best of both worlds, particularly when you consider that a huge percentage of the XML on the Web was generated automatically from a database in the first place.
    In this article, we'll be using the moreover.com news feeds as a real-world example of a practical use of XML. This example also shows off the advantages of a SQL-based approach. We really just want to scan for stories that interest the user, in much the same way as we scan newspaper headlines. A SQL query for headlines containing specific topics is a much more natural, content-oriented approach than a tree-parsing model, which is essentially document oriented.
    http://www.devx.com/premier/mgznarch/Javapro/2001/01dec01/jo0112/jo0112-1.asp
    ====================
    A read-only JDBC driver for Java that uses Comma Separated Value (CSV) files as database tables. Ideal for writing data import programs and conversion program.
    http://sourceforge.net/projects/csvjdbc/
    http://csvjdbc.sourceforge.net/
    ====================
    http://www.amazon.com/exec/obidos/ASIN/1576101592/qid=1002215191/sr=1-10/ref=sr_1_7_10/107-9140627-3143754

  • [svn:cairngorm3:] 21174: Landmark does not work under complex situations

    Revision: 21174
    Revision: 21174
    Author:   [email protected]
    Date:     2011-04-29 11:21:00 -0700 (Fri, 29 Apr 2011)
    Log Message:
    Landmark does not work under complex situations
    https://bugs.adobe.com/jira/browse/CGM-39
    Ticket Links:
        http://bugs.adobe.com/jira/browse/CGM-39
    Modified Paths:
        cairngorm3/trunk/libraries/Navigation/src/com/adobe/cairngorm/navigation/core/EnterAndExi tInvoker.as
        cairngorm3/trunk/libraries/Navigation/src/com/adobe/cairngorm/navigation/waypoint/Waypoin tHandler.as

    Hi John,
    1) I like that the new model adds parameterization. It's cleaner than pulling in parameters from pre-set variables. However, the given example didn't actually make much use of it. The only non-constant parameter multiply-used in the example is the "table" variable. Seems like a lot of work for not a lot of gain, at least in this case?
    2) I am cautious that this new template/model condenses the paradigm sooo much, that it is no longer clear where XPath is involved vs straight constant tag names. Yes, Adobe's example is overly-expanded but that's common in code meant to be a demonstration.
    3) I also am cautious that the example intermingles direct node creation into the XPath search/processing chain. I've learned to be VERY careful with this. It only can work when the changes made do not interfere with the rule processing. In my model, I simply avoid it completely (by not making node-position or node-add/remove/move changes until after tree parsing is complete.) This will always be a safe model.
    Bottom line: while I very much appreciate the parameterization and lintability (is that a word? Sure makes sense to me )... I think I would still define each rule separately rather than bring them all together as an inline array in the rule processing call. To me it seems sooo condensed that the XPath meaning can become lost. (Would someone recognize that //para/section-head is actually an XPath statement that could (in another situation) be //para/* or //para/following-siblings::* ... while some of the other strings are exact-match tag names?)
    I realize this is all a matter of style... my preference: clarity for the future reader, particularly when the future reader is me a year later who forgot what all those parameters and embedded methods were all about ...
    Blessings,
    Pete

  • Dom  - OutOfMemoryError:heap space

    Hey
    I have a text file with the following format:
    galia_na skCiKjcpdm02-pdm23p--2o6 2008/10/28-09:14:11:595 80006024 8860002 68100509 2008/10/15 90 487.35 IskAFT046
    1.     galia_na – User Name
    2.     skCiKjcpdm02-pdm23p--2o6 – Invoice OBID (unique ID)
    3.     2008/10/28-09:14:11:595 – CreationDate or TimestampOut of the Invoice
    4.     80006024 – Invoice Number
    5.     8860002 – Batch Number
    6.     68100509 – Supplier Number
    7.     2008/10/15 – Invoice Date
    8.     90 – Currency
    9.     487.35 – New Amount
    10.     IskAFT046 – Invoice Type
    The file is large, and when trying to build an xml file using DOM tree parser, I encounter " Exception in thread "main" java.lang.OutOfMemoryError: Java heap space". (IT'S because DOM is not working properly with big files, The DOM tree consumes large amount of memory)
    The Xml format:
    <Year ID="2008" netAmount="15883.700" quantity="6">
    <Month ID="Oct" netAmount="2247.310" quantity="3" year="2008">
    <Data ID="0" display="History">
    <OBID display="">skCiKjcpdm02-pdm23p--2o6</OBID>
    <Days_waiting_for_approval display="Days waiting for approval">0</Days_waiting_for_approval>
    <TimeStampOut display="Action Date">2008/10/28</TimeStampOut>
    <InvoiceNumber display="Invoice Number">80006024</InvoiceNumber>
    <BatchNumber display="Batch Number">8860002</BatchNumber>
    <SupplierNumber display="Supplier Number">68100509</SupplierNumber>
    <InvoiceDate display="Invoice Date">2008/10/15</InvoiceDate>
    <Currency display="Currency">90</Currency>
    <NetAmount display="Net Amount">487.35</NetAmount>
    <InvoiceType display="Invoice Type">Purchase</InvoiceType>
    </Data>
    <Data ID="1" display="History">
    <OBID display="">skCiCxdpdm02-pdm23p--2oW</OBID>
    <Days_waiting_for_approval display="Days waiting for approval">0</Days_waiting_for_approval>
    <TimeStampOut display="Action Date">2008/10/28</TimeStampOut>
    <InvoiceNumber display="Invoice Number">80005892</InvoiceNumber>
    <BatchNumber display="Batch Number">8860003</BatchNumber>
    <SupplierNumber display="Supplier Number">68100509</SupplierNumber>
    <InvoiceDate display="Invoice Date">2008/10/02</InvoiceDate>
    <Currency display="Currency">90</Currency>
    <NetAmount display="Net Amount">799.96</NetAmount>
    <InvoiceType display="Invoice Type">Purchase</InvoiceType>
    </Data>
    <Data ID="2" display="History">
    <OBID display="">skCjegjpdm02-pdm23p--2pL</OBID>
    <Days_waiting_for_approval display="Days waiting for approval">0</Days_waiting_for_approval>
    <TimeStampOut display="Action Date">2008/10/28</TimeStampOut>
    <InvoiceNumber display="Invoice Number">3231</InvoiceNumber>
    <BatchNumber display="Batch Number">8860004</BatchNumber>
    <SupplierNumber display="Supplier Number">68104784</SupplierNumber>
    <InvoiceDate display="Invoice Date">2008/09/24</InvoiceDate>
    <Currency display="Currency">90</Currency>
    <NetAmount display="Net Amount">960.00</NetAmount>
    <InvoiceType display="Invoice Type">Purchase</InvoiceType>
    </Data>
    <Month ID="Dec" netAmount="13636.390" quantity="3" year="2008">
    <Data ID="0" display="History">
    <OBID display="">smbna6hpdm02-pdm23p--6dX</OBID>
    <Days_waiting_for_approval display="Days waiting for approval">0</Days_waiting_for_approval>
    <TimeStampOut display="Action Date">2008/12/01</TimeStampOut>
    <InvoiceNumber display="Invoice Number">80295</InvoiceNumber>
    <BatchNumber display="Batch Number">8850770</BatchNumber>
    <SupplierNumber display="Supplier Number">68100508</SupplierNumber>
    <InvoiceDate display="Invoice Date">2008/11/05</InvoiceDate>
    <Currency display="Currency">90</Currency>
    <NetAmount display="Net Amount">4250.25</NetAmount>
    <InvoiceType display="Invoice Type">Purchase</InvoiceType>
    </Data>
    <Data ID="1" display="History">
    <OBID display="">smbnhJepdm02-pdm23p--6eo</OBID>
    <Days_waiting_for_approval display="Days waiting for approval">0</Days_waiting_for_approval>
    <TimeStampOut display="Action Date">2008/12/01</TimeStampOut>
    <InvoiceNumber display="Invoice Number">4744</InvoiceNumber>
    <BatchNumber display="Batch Number">8850771</BatchNumber>
    <SupplierNumber display="Supplier Number">68103640</SupplierNumber>
    <InvoiceDate display="Invoice Date">2008/11/17</InvoiceDate>
    <Currency display="Currency">90</Currency>
    <NetAmount display="Net Amount">1749.78</NetAmount>
    <InvoiceType display="Invoice Type">Purchase</InvoiceType>
    </Data>
    <Data ID="2" display="History">
    <OBID display="">smbniAbpdm02-pdm23p--6el</OBID>
    <Days_waiting_for_approval display="Days waiting for approval">0</Days_waiting_for_approval>
    <TimeStampOut display="Action Date">2008/12/01</TimeStampOut>
    <InvoiceNumber display="Invoice Number">4663</InvoiceNumber>
    <BatchNumber display="Batch Number">8850772</BatchNumber>
    <SupplierNumber display="Supplier Number">68103640</SupplierNumber>
    <InvoiceDate display="Invoice Date">2008/11/07</InvoiceDate>
    <Currency display="Currency">90</Currency>
    <NetAmount display="Net Amount">7636.36</NetAmount>
    <InvoiceType display="Invoice Type">Purchase</InvoiceType>
    </Data>
    </Month>
    </Month>
    I wonder how to process only one "Month" in a time. Write a fragment of the DOM tree into the targer xml file, remove the month which was already updated in the xml file and continue…
    I have read about xml streaming, (javax.xml.stream package), but the thing is I have accumulative data tags, netAmount and quantity, and modifying xml with STax involves read it in... modify it, and write it out again
    <Year ID="2008" netAmount="15883.700" quantity="6">
    <Month ID="Oct" netAmount="2247.310" quantity="3" year="2008">
    I wonder if there is a parser I can use for this purpose! I am using MyEclipse with jdk version 1.4 (can't upgrade!!!)
    Thanks for the help !
    Natalie

    avoid multi post
    http://forums.sun.com/thread.jspa?threadID=5427470

Maybe you are looking for

  • New symptoms since latest firmware update

    OK I have a 1tb sky hd box which hasn't had any really annoying issues up until the new firmware update (the one with the new Kids tile which is annoying in its own right).  Anyway, I have been watching the cricket on SS2 and every so often when they

  • GetUpdateCount()

    I have got one problem with Oracle Driver. As per the documents if I am executing getUpdateCount() two times & I know I execute method will return only one time updateCount then if I am calling getUpdateCount() second time it returns me the same valu

  • Patch 11 now available for download

    As you can see, patch 11 contains many many fixes and some new functionality. Thanks to everyone on the SDN for contributing! Highlights - Login name now able to be edited by either user or merchant - Orders placed for the Internal BP, containing the

  • Need more Info about "Load transactional data when master data not loaded"

    Hi, Can you please explain me this option in the infopackage " Load transactional data when master data is not loaded".... Say i load a transactional data record which has a material no. AAAXX. In the fact table, the material no. is replaced with the

  • Photostream not updating iPhoto

    Photostream is enabled on my iOS devices: iPad and iPhone.  The photostream updates beautifully between those two devices.  I just launched iPhoto, however, and Photostream is empty.  It shows a date at the top of the screen of October 31, 2011.  Not