Exact JTree Structure to XML

I've been looking for a solution to this problem for some time now, and still no luck.
I'm going to point out first that I do NOT know the exact structure of the Tree Model. This is because the user can manipulate the tree as they wish. My problem comes when I want to save/load this tree structure, I thought that XML seems like the ideal choice.
My problem is that because I don't know the structure of the Tree Model, I'm not sure how to loop through every node in the Tree Model and add it to my XML Document.
People have suggested looping through the Tree Models children, except that wouldn't return the many other nodes that may be in the Tree Model.
If I haven't explained it very well, or you need to know any extra info just reply asking.
Hope someone out there can give me a hand, cheers!

You could get the root node as DefaultMutableTreeNode:
TreeModel treeMdl = jTree.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeMdl.getRoot(); and traverse the tree from there.
DefaultMutableTreeNode class has some related methods:
public Enumeration preorderEnumeration()
public Enumeration postorderEnumeration()
public Enumeration breadthFirstEnumeration()
public Enumeration depthFirstEnumeration()
public int getChildCount()
public TreeNode getChildAt(int index)

Similar Messages

  • Can we express batch relationship structure in XML in the database table

    Hi
    please help me ..
    i have a batch XML batch structure ...can we express batch relationship structure in XML in tha database table?
    yes..then how?
    Thanks
    Amu
    Edited by: amu_2007 on Mar 25, 2010 6:57 PM
    Edited by: amu_2007 on Mar 25, 2010 7:03 PM

    But what is the problem with the initial solution given that split the XML into the data?
    I mean you could do something like this?
    SQL> create table batch (customer    VARCHAR2(10)
      2                     ,cust_name   VARCHAR2(10)
      3                     ,cust_type   VARCHAR2(10)
      4                     )
      5  /
    Table created.
    SQL>
    SQL> create table section (customer    VARCHAR2(10)
      2                       ,sect_name   VARCHAR2(10)
      3                       ,sect_depend VARCHAR2(10)
      4                       )
      5  /
    Table created.
    SQL> create table job_sections (customer        VARCHAR2(10)
      2                            ,sect_name       VARCHAR2(10)
      3                            ,job_sect_name   VARCHAR2(10)
      4                            ,job_sect_depend VARCHAR2(10)
      5                            )
      6  /
    Table created.
    SQL> create table job (customer        VARCHAR2(10)
      2                   ,sect_name       VARCHAR2(10)
      3                   ,job_sect_name   VARCHAR2(10)
      4                   ,job_type        VARCHAR2(10)
      5                   ,job_sub_type    VARCHAR2(10)
      6                   ,job_depend      VARCHAR2(10)
      7                   )
      8  /
    Table created.
    SQL>
    SQL>
    SQL> insert all
      2    when batch_rn = 1 then
      3      into batch (customer, cust_name, cust_type) values (customer, cust_name, cust_type)
      4    when section_rn = 1 then
      5      into section (customer, sect_name, sect_depend) values (customer, sect_name, sect_dependency)
      6    when job_sections_rn = 1 then
      7      into job_sections (customer, sect_name, job_sect_name, job_sect_depend) values (customer, sect_name, job_sect_name, job_sect_dependency)
      8    when 1=1 then
      9      into job (customer, sect_name, job_sect_name, job_type, job_sub_type, job_depend) values (customer, sect_name, job_sect_name, job_type, jo
    10  --
    11  WITH t as (select XMLTYPE('
    12  <BATCH customer="ABC" name="ABC1" type="ABC_TYPE">
    13    <BATCH_SECTIONS>
    14      <SECTION name="X" dependency="NULL">
    15        <JOB_SECTIONS name="JOB1" dependency="NULL" >
    16          <JOBS>
    17            <JOB type="X" sub_type="xx" dependency="NULL" />
    18            <JOB type="X" sub_type="yy" dependency="NULL" />
    19            <JOB type="X" sub_type="zz" dependency="NULL" />
    20          </JOBS>
    21        </JOB_SECTIONS>
    22      </SECTION>
    23      <SECTION name="Y" dependency="X">
    24        <JOB_SECTIONS name="JOB2" dependency="X" >
    25          <JOBS>
    26            <JOB type="Y" sub_type="xx" dependency="X" />
    27            <JOB type="Y" sub_type="yy" dependency="X" />
    28            <JOB type="Y" sub_type="zz" dependency="X" />
    29          </JOBS>
    30        </JOB_SECTIONS>
    31      </SECTION>
    32      <SECTION name="Z" dependency="Y">
    33        <JOB_SECTIONS name="JOB3" dependency="NULL" >
    34          <JOBS>
    35            <JOB type="....." sub_type="...." dependency="NULL" />
    36          </JOBS>
    37        </JOB_SECTIONS>
    38        <JOB_SECTIONS name="JOB4" dependency="NULL">
    39          <JOBS>
    40            <JOB type="...." sub_type="...." dependency="NULL" />
    41          </JOBS>
    42        </JOB_SECTIONS>
    43      </SECTION>
    44    </BATCH_SECTIONS>
    45  </BATCH>
    46  ') as xml from dual)
    47  --
    48  -- END OF TEST DATA
    49  --
    50  ,flat as (select a.customer, a.cust_name, a.cust_type
    51                  ,b.sect_name, NULLIF(b.sect_dependency,'NULL') as sect_dependency
    52                  ,c.job_sect_name, NULLIF(c.job_sect_dependency,'NULL') as job_sect_dependency
    53                  ,d.job_type, d.job_sub_type, NULLIF(d.job_dependency,'NULL') as job_dependency
    54            from t
    55                ,XMLTABLE('/BATCH'
    56                          PASSING t.xml
    57                          COLUMNS customer     VARCHAR2(10) PATH '/BATCH/@customer'
    58                                 ,cust_name    VARCHAR2(10) PATH '/BATCH/@name'
    59                                 ,cust_type    VARCHAR2(10) PATH '/BATCH/@type'
    60                                 ,bat_sections XMLTYPE PATH '/BATCH/BATCH_SECTIONS'
    61                         ) a
    62                ,XMLTABLE('/BATCH_SECTIONS/SECTION'
    63                          PASSING a.bat_sections
    64                          COLUMNS sect_name        VARCHAR2(10) PATH '/SECTION/@name'
    65                                 ,sect_dependency  VARCHAR2(10) PATH '/SECTION/@dependency'
    66                                 ,section         XMLTYPE      PATH '/SECTION'
    67                         ) b
    68                ,XMLTABLE('/SECTION/JOB_SECTIONS'
    69                          PASSING b.section
    70                          COLUMNS job_sect_name        VARCHAR2(10) PATH '/JOB_SECTIONS/@name'
    71                                 ,job_sect_dependency  VARCHAR2(10) PATH '/JOB_SECTIONS/@dependency'
    72                                 ,job_sections         XMLTYPE      PATH '/JOB_SECTIONS'
    73                         ) c
    74                ,XMLTABLE('/JOB_SECTIONS/JOBS/JOB'
    75                          PASSING c.job_sections
    76                          COLUMNS job_type        VARCHAR2(10) PATH '/JOB/@type'
    77                                 ,job_sub_type    VARCHAR2(10) PATH '/JOB/@sub_type'
    78                                 ,job_dependency  VARCHAR2(10) PATH '/JOB/@dependency'
    79                         ) d
    80            )
    81  --
    82  select customer, cust_name, cust_type, sect_name, sect_dependency, job_sect_name, job_sect_dependency, job_type, job_sub_type, job_dependency
    83        ,row_number() over (partition by customer order by 1) as batch_rn
    84        ,row_number() over (partition by customer, sect_name order by 1) as section_rn
    85        ,row_number() over (partition by customer, sect_name, job_sect_name order by 1) as job_sections_rn
    86  from flat
    87  /
    16 rows created.
    SQL> select * from batch;
    CUSTOMER   CUST_NAME  CUST_TYPE
    ABC        ABC1       ABC_TYPE
    SQL> select * from section;
    CUSTOMER   SECT_NAME  SECT_DEPEN
    ABC        X
    ABC        Y          X
    ABC        Z          Y
    SQL> select * from job_sections;
    CUSTOMER   SECT_NAME  JOB_SECT_N JOB_SECT_D
    ABC        X          JOB1
    ABC        Y          JOB2       X
    ABC        Z          JOB3
    ABC        Z          JOB4
    SQL> select * from job;
    CUSTOMER   SECT_NAME  JOB_SECT_N JOB_TYPE   JOB_SUB_TY JOB_DEPEND
    ABC        X          JOB1       X          xx
    ABC        X          JOB1       X          yy
    ABC        X          JOB1       X          zz
    ABC        Y          JOB2       Y          xx         X
    ABC        Y          JOB2       Y          yy         X
    ABC        Y          JOB2       Y          zz         X
    ABC        Z          JOB3       .....      ....
    ABC        Z          JOB4       ....       ....
    8 rows selected.
    SQL>But it would depend what you are actually after in terms of primary keys, and table relationships etc.
    Let me put this simply for you...
    h1. IF YOU DON'T DEMONSTRATE TO US WHAT OUTPUT YOU REQUIRE, WE CAN'T GIVE YOU AN ANSWER

  • Easy way how to convert deep structure to XML

    Hi,
    is there any easy way how to convert a complex deep structure to XML. I have XSLT transformation ready for using, but when I look on examples on using CALL TRANSFORMATION, I am finding only examples for internal tables.
    Something like this CALL TRANSFORMATION SOURCE tab = sometab[].
    Instead of this I need to convert a comlex deep structure.
    Any help is appreciated.
    Thanks.
    Marian

    Hi,
    is there any easy way how to convert a complex deep structure to XML. I have XSLT transformation ready for using, but when I look on examples on using CALL TRANSFORMATION, I am finding only examples for internal tables.
    Something like this CALL TRANSFORMATION SOURCE tab = sometab[].
    Instead of this I need to convert a comlex deep structure.
    Any help is appreciated.
    Thanks.
    Marian

  • Structure of  xml

    How do I format the structure of xml
    from:
    <root><news><title>title
    text</title><body>body
    text</body></news></root>
    to:
    <root>
    <news>
    <title>title text</title>
    <body>body text</body>
    </news>
    </root>
    //code
    var news_xml:XML = new XML();
    news_xml.ignoreWhite = true;
    AddNewsEntry();
    function AddNewsEntry() {
    var newsRoot:XMLNode = news_xml.createElement("root");
    var newsNode:XMLNode = news_xml.createElement("news");
    var titleNode:XMLNode = news_xml.createElement("title");
    var bodyNode:XMLNode = news_xml.createElement("body");
    var titleText:XMLNode = news_xml.createTextNode("title
    text");
    var bodyText:XMLNode = news_xml.createTextNode("body text");
    news_xml.appendChild(newsRoot);
    newsNode.appendChild(titleNode);
    newsNode.appendChild(bodyNode);
    newsRoot.appendChild(newsNode);
    titleNode.appendChild(titleText);
    bodyNode.appendChild(bodyText);
    trace(news_xml);

    Try the attached code. It will convert the XML into a string
    that should be formatted correctly.

  • How to see the IDOC structure in XML format

    Hi, I am ver new to MII. I configured connection between SAPand SAP MII and IDOC is triggering in SAP MII. I can see the idoc triggered in Message monitor.
    Now my query is how to see the IDOC structure in XML format? I written a transaction where I am assigning transaction.xml to my Local.xml and trying to display with message action block. When I display the message I am getting message as below
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    There is no data in the xml, but in SAP side i seen data and segment which sent to MII as a IDOC. Please help me how to resolve this issue.

    Hi, Thanks for quick response.
    In Message monitor I seen the IDOC list after executing POIT transaction code in SAP.
    But the display button is disabled always in message monitor screen. I want to take this IDOC and save it in my SQL database. So I want to see this IDOC structure in XML format. Where i can see this structure?

  • How to structure an XML doc using schema?

    Hi there,
    I have an XML file with a grouped <employee> tags like,
    <employee>
    <employeename>John</employeename>
    <employeename>Dave</employeename>
    </employee>
    I want to structure above xml file to be like this
    <employee>
    <employeename>John</employeename>
    </employee>
    <employee>
    <employeename>Dave</employeename>
    </employee>
    Can I do that in a XML schema (.xsd file)? If I can, how do I do that?
    Thanks,
    Chandi

    Hi Dave,
    Thanks for your response.
    I create this XML from .xsd files using a tool (MapForce by Altova which allows me to do the mappings between relational database table columns and elements in the .xsd file, and it creates Java code for me), the data is read from a database to compose this XML file.
    Everything works fine with this XML file, I just want to change the structure of the XML file when it composes it, I was wondering if I could do that by changing the existing .xsd file?
    Its not easy to use XSLT, I�m dealing with over 600 hierarchical elements with over 15 .xsd files.
    So, what are my options?
    All I want to know is, what should I change in the .xsd in order to compose this XML in the structure that I want.
    It groups all the employee names (<employeename> tag) under one <employee> tag, instead I want to have individual <employee> tags for each and every <employeename> tags (<employee> tag around <employeename> tag for each and every employee)
    Is it possible at all?
    Thanks,
    Chandi

  • JTree + complex documents (XML)

    Hi there,
    I have the following problem:
    I want to visualise complex documents, such as xml-documents by means of the JTree Class.
    I wonder if there is any sense in implementing a class defining what exactly should be shown as a node and what should be shown as a leaf.
    So what I want to do is inherit a class from JTree, passing an instance of a class as described above. Now the JTree would have to draw itself by means of the declaration in the class passed in a constructor.
    Do you understand what I mean?
    Is this senseful, what ways are there in Java implementing this?
    Do you have other ideas?
    Thank you,
    sincerely
    Karlheinz Toni

    I have a program that allows me to edit XML documents (it came from Microsoft). And it does display the XML in its tree form, and allow me to edit nodes or leaves. So yes, it is a perfectly reasonable thing to do.
    In answer to the rest of the question, you don't understand enough yet to ask that question. First of all you would not extend JTree, instead you would create your own tree model to support a generic JTree. If you look at the API documentation for JTree you will find a link to a tutorial about how to do that. Second, you can parse your XML document into a DOM, which is a tree-structured object that your tree model would work with. Here's a link to a whole lot of tutorials about XML: http://java.sun.com/webservices/docs/1.0/tutorial/index.html

  • Source structure of XML file as different from Message type?

    Hi,
    We are picking an xml file from the FTP server of the client.
    We have source message type 'MT_Invoice' with data type as 'DT_Invoice'.
    When we open the message mapping test tab, the source structure is as shown below.
    <ns0:MT_Invoice xmlns:ns0="urn:maxxium:nordic:invoice:inbound">
       <Invoices>
          <Invoice>
          </Invoice>
       </Invoices>
    </MT_Invoice>
    My question is "What should be the structure of the XML file that the client is depositing on to the FTP server?".
    Should it start with the tag 'MT_Invoice' with the namespace or should it simply start from    <Invoices> tag.
    I have tried various combinations for the source xml structure. But all are failing.
    (This is evident from the fact that the mapping is failing. That's why I have given the structure from the source structure of the message mapping tab.)
    Kindly help.
    Thanks,
    John

    >
    john j wrote:
    > Hi,
    >
    > We are picking an xml file from the FTP server of the client.
    >
    > We have source message type 'MT_Invoice' with data type as 'DT_Invoice'.
    >
    > When we open the message mapping test tab, the source structure is as shown below.
    >
    > <ns0:MT_Invoice xmlns:ns0="urn:maxxium:nordic:invoice:inbound">
    >    <Invoices>
    >       <Invoice>
    > .
    > .
    > .
    > .
    >       </Invoice>
    >    </Invoices>
    > </MT_Invoice>
    >
    > My question is "What should be the structure of the XML file that the client is depositing on to the FTP server?".
    >
    > Should it start with the tag 'MT_Invoice' with the namespace or should it simply start from    <Invoices> tag.
    >
    > I have tried various combinations for the source xml structure. But all are failing.
    >
    > (This is evident from the fact that the mapping is failing. That's why I have given the structure from the source structure of the message mapping tab.)
    >
    > Kindly help.
    >
    > Thanks,
    > John
    you are picking an XML file. So you should create the MT which would represent exactly the XML format of the source file.
    So ideally if your file starts with <invoice>, then name your MT as invoice

  • XML Structure in XML Component

    Hi,
    I'm trying to build an XML component in Portal 9.0.2.
    What I need to know is the structure of the XML generated by SQL placed inside the <ORACLE> tags so I can parse it with the XSL style sheet.
    All the examples I've seen (about 2) show the sql coming out in one lump in a table, but I want to be able to parse individual columns from the SQL. All I seem to get is a default presentation of the data.
    Any Ideas ?

    Hi,
    This is not possible currently. There is an enhancement filed for this.
    Thanks,
    Sharmila

  • Automatic creation of KM folder structure from xml pattern

    Hi all,
    is it possible to create a KM folder structure automaticly, following the tree structure of an xml document?
    For example:
    an xml-document with following content:
    <item id=1 level=0>abc</item>
    <item id=2 level=1>aaa</item>
    <item id=3 level=1>bbb</item>
    <item id=4 level=2>ccc</item>
    <item id=5 level=0>def</item>
    I'd like to create a KM folder structure like this:
    - abc
    ---aaa
    ---bbb
    ccc
    - def
    Does anyone have any idea to implement this scenario in KM?
    Much obliged!
    Steffi

    Not currently - well at least not easily - there is always the programatic approach.
    I would suggest you can create an FSDB repository - this means you can then create your structure in the file system using standard desktop tools.
    After that you could do a mass copy back into the db based KM repository if you so wished.
    For your downstream systems you could always ICE the data across meaning you dont have to create everything again.
    Haydn

  • Deep structure to XML and saving in SAP tables

    Hi all,
    ich habe filled an internal table (deep strucure) with mutiple fields. Most of these fields are defined as structure.
    Example: 1st field ist document number, 2nd field is defined as TLINETAB, 3rd field ist another document number, 4th field is filled with node table of a column tree, 5th field ist filled with the item table of a column tree and in the last field I save the ALV properties of buttons, defined with lvc_t_styl.
    So my problem is that I want to save all these contents in database tables and restore in my application when the user ist starting again. How can I save this and how have I define the database table to save? I thought 1st field is e.g. document number, 2nd is a counter and 3rd field is a CHAR field. Then the internal table will be converted (XML?) and the result will be append to my table line by line.
    Thanks for help and regards
    Michael

    Hi,
    This looks like a perfect use for the Shared Objects functionality, introduced in SAP Web AS 6.40. See some [SAP documentation|http://help.sap.com/saphelp_nw70/helpdata/en/14/dafc3e9d3b6927e10000000a114084/frameset.htm] for this feature and an [example of use|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/900e3d9d-559e-2910-9dae-b132157a220f?QuickLink=index&overridelayout=true].
    Hope this helps,
    Grzegorz

  • Structure of XML that can be interpreted by KM?

    Hi,
       My requirement is as follows - I need to bring in the documents stored in an external repository(Lotus Domino server) into KM repository thereby avoiding the external repository totally. This is how I am trying to approach - to convert all documents in the external repository into XML documents that is understandable by KM. Now, what I would like to know is the structure of the XML. Is there a specific XML structure that KM can read & hence store the documents accordingly in its repository?
    Any help will be greatly appreciated.
    Regards,
    M.Subathra

    Any thoughts on this?

  • Multilevel structure to XML

    Hi,
    I have a multilevel structure that looks like that :
    a = structNew()
    a.a.a.a = apple
    a.a.a.b = banana
    a.a.b.a = potato
    a.b = beef
    What would be the best way of converting that structure in an
    XML document that would look like the following attached code ?
    Any suggestion ? The structure isn't always 4-levels deep.
    Sometimes it can be 3, 4, 8, 2...
    I thought I would just loop recursively over my structure :
    calling a method that would check if the item is a struct and if so
    create a new XML node inside the XML node being processed or else
    just put the value in node currently being open, then return the
    result back to the calling method... and so on.
    Is there any sort of code snippet that may convert a
    multilevel structure to an XML document ? All examples I've found
    so far only deals with one level.
    Thanks in advance,
    Patrick

    Thanks, I already came accross that code but unfortunately it
    does process only the first level of a structure :
    form.author
    form.book_title
    form.nb_book_pages
    And I needed :
    form.author.firstname
    form.author.lastname
    form.book.title
    form.book.pages
    etc...
    But I found a solution ! I did it through a recursive
    function inside a CFC... I'll post the code soon, I don't have it
    at hand right now.
    Patrick

  • IDOC --- XI -- HTTP (via a flat file structure, not XML)

    I am working on a senario in which we need to send a third party payroll service provider our HR Master Data records (Message type HROT_UM).  The manual method is to create a flat file from an IDOC and place the file in a shared directory, then upload the flat file by logging on to the web server.  We would like to automate this process using XI.
    Is it possible to send a flat file structure to a webserver using a HTTP receiver adapter?  If not, can you provide a basic view of how to accomplish this task.  Please note that FTP is not an option for us. 
    Any suggestions or recommendations would be greatly appreciated.

    hey
    flat file over HTTP is not possible,it takes only XML.
    have a look at the following thread
    Send file through http
    thanx
    ahmad
    PL:reward with points for helpful answers

  • Ddic structure to XML

    Hi,
    is there an easy way to create a xml string based on a ddic structure?
    Its a nested structure and I want to avoid to create all elements manually.
    Perfect way would be that i could fill the structure with data and then transform this into a xml string.
    for instance:
    ls_test-header-name = 'tester'
    ls_test-header-county = 'germany'
    ls_test-item-material = '4711'
    ls_test-item-pos = '1'
    should be transformed to:
    <?xml version="1.0"?>
       <ls_test>
           <header>
             <name>tester</name>
             <country>germany</country>
           </header>
           <item>
              <material>4711</material>
              <pos>1</pos>
          </item>
        </ls_test>
    Thanks,
    Christoph

    Hi Christoph,
    following link describes the xml transformation suggested above:
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/e3/7d4719ca581441b6841f1054ff1326/frameset.htm
    and here is a small example
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/ae/101640a991c742e10000000a1550b0/frameset.htm
    Hope this is helpful.
    Regards
    Bernd

Maybe you are looking for

  • IBooks 1.3 on iPod Touch 2G (4.2.1) dictionary not available for this language

    I have an iPod Touch 2G, running 4.2.1.  I also have iBooks 1.3.  Everything is running well, but unfortunately I do not have the built in dictionary for ebooks that I have bought on the iBooks store.  I have 14 books from their store, but I am not a

  • Interesting iMessage Problem between Macbook Pro/iPad 1

    I was recently forced into getting a Macbook Pro (I would have preferred an iMac if I had to buy a Mac at all) and everything has gone as well as can be expected (background: I build PCs and am a Linux user. I am proficient in Mac/Windows/Linux with

  • Playing music through Air Tunes using Windows Media Player

    Hello to all. I am planning on buying the Air Port Express so I can play music wirelessly from my Dell. The only problem I have with is that I can't use the keyboard media buttons (play/pause, stop, next, previous) with iTunes. These buttons work wit

  • Inspector link tools disabled?

    I'm just getting started with iWeb, and have had some initial success geting my web page up (just travel photos -- yawn). However I have not had much using the Inspector tool to set up hyperlinks, as the "Enable as hyperlinks" checkbox is greyed out

  • Content Aware not always working?

    What are the specifications for how to make content aware work?  Sometimes I delete something and it asks for content aware, but other times it just deletes it.  Do you know what's up? -TitanVex