Child to Parent Node Creation, Mapping Help required

Hi Guys,
I need some suggestions on the following mapping problem, kindly suggest some solution if possible:
I have a sender structure as:
ParentNode
..........RecordSet  (0 to 1)
................ SValue1  (0 to 1)
................ SValue2  (0 to 1)
.................SValue3  (0 to 1)
For the receiver Structure I have following:
ParentNode
..........RSet  (0 to unbounded)
............. RValue  (0 to 1)
..............RField    (0 to 1)
Now my mapping conditions requires for every SValue1, SValue2, SValue3 source fields, I should generate at receiver side a new RSet and the value of SValue1/SValue2/SValue3 field(s) should be Provided into RValue, and RField should have the respective field name.
I am trying this with PI Graphical mapping, is there any better solution for it?

Hi,
As source structure occurence is 0..1 in this case duplicate the target structure and use create if function with source as SValue1 ...so that for each of Svalues...a corresponding target node will get generated...
With graphical mapping you should be able to do this...else need to go for UDF...
HTH
Rajesh

Similar Messages

  • XSLT mapping Help Required.

    XSLT mapping Help Required.
    Hi Experts,
    I am New to XSLT Mapping. I am practising the below Example:
    InputXML File:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
    <ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
    <Person>
    <FirstName>Anshul</FirstName>
    <LastName>Chowdhary</LastName>
    <Gender>Male</Gender>
    <Address>
    <Street>2nd Main</Street>
    <Houseno>83/b</Houseno>
    <City>Mysore</City>
    </Address> </Person>
    </ns0:MT_XSLT_Source>
    XSL StyleSheet File:
    <?xml version='1.0' encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/Gen"
    Xmlns:ns1=”http://XYZ.com/Test”>
    <xsl:template match="/">
    <ns1:MT_XSLT_Target>
    <Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title>
    <Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/>
    </Name>
    <Street> <xsl:value-of select="concat(concat(ns0:Mt_XSLT_Source/Person/Address/Houseno,' '),
    ns0:Mt_XSLT_Source/Person/Address/Street)"/> </Street>
    <City> <xsl:value-of select="ns0:Mt_XSLT_Source/Person/Address/City"/> </City>
    </ns1:MT_XSLT_Target>
    </xsl:template>
    </xsl:stylesheet>
    The Desired Output shuold be:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:MT_XSLT_Target xmlns:ns1="http://XYZ.com/Test">
    <Title>Male</Title>
    <Name>Anshul Chowdhary</Name>
    <Street>83/b 2nd Main</Street>
    <City>Mysore</City>
    </ns1:MT_XSLT_Target>
    I have refered the xsl in xml and i am getting the below Oupt in a Single line like this:
    Anshul Chowdhary Male 2nd Main 83/b Mysore
    I am Unable to display in Target XML Fomrat as shown above. Please check and do the needful.
    Regards,
    GIRIDHAR

    Hi,
    I have used below for testing.
    Input xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
    <ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
    <Person>
    <FirstName>Anshul</FirstName>
    <LastName>Chowdhary</LastName>
    <Gender>Male</Gender>
    <Address>
    <Street>2nd Main</Street>
    <Houseno>83/b</Houseno>
    <City>Mysore</City>
    </Address> </Person>
    </ns0:MT_XSLT_Source>
    xsl code:
    <?xml version='1.0' encoding="UTF-8"?> 
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/gen" 
        xmlns:ns1="http://XYZ.com/Test"> 
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
        <xsl:template match="/"> 
            <ns1:MT_XSLT_Target> 
                <Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title> 
                <Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/> 
                </Name> 
                <Street> <xsl:value-of select="concat(concat(/ns0:MT_XSLT_Source/Person/Address/Houseno,' '), 
                    /ns0:MT_XSLT_Source/Person/Address/Street)"/> </Street> 
                <City> <xsl:value-of select="/ns0:MT_XSLT_Source/Person/Address/City"/> </City> 
            </ns1:MT_XSLT_Target> 
        </xsl:template> 
    </xsl:stylesheet>
    For testing in PI ,change the extension from .txt to .xsl and zip it and upload into PI as an imported archive .
    Regards
    Venkat

  • Treeview Add Child to Parent Node Without Creating a New Parent

    I have a treeview setup with a HierarchicalDataTemplate in my XAML as follows:
    <TreeView Grid.Column="1" Grid.Row="0" ItemsSource="{Binding treeViewObsCollection}">
    <TreeView.ItemTemplate>
    <HierarchicalDataTemplate ItemsSource="{Binding mainNodes}">
    <TextBlock Text="{Binding topNodeName}"/>
    <HierarchicalDataTemplate.ItemTemplate>
    <DataTemplate>
    <TextBlock Text="{Binding subItemName}"></TextBlock>
    </DataTemplate>
    </HierarchicalDataTemplate.ItemTemplate>
    </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
    </TreeView>
    Here is the ViewModel which is set as the Data Context for the XAML File.
    class AdvancedErrorCalculationViewModel : ViewModelBase
    static ObservableCollection<TreeViewClass> _treeViewObsCollection = new ObservableCollection<TreeViewClass>();
    public static ObservableCollection<TreeViewClass> treeViewObsCollection { get { return _treeViewObsCollection; } }
    public class TreeViewClass : ViewModelBase
    public TreeViewClass(string passedTopNodeName)
    topNodeName = passedTopNodeName;
    mainNodes = new ObservableCollection<TreeViewSubItems>();
    public string topNodeName
    get { return this.GetValue<string>(); }
    set { this.SetValue(value); }
    public ObservableCollection<TreeViewSubItems> mainNodes { get; private set; }
    public class TreeViewSubItems : ViewModelBase
    public TreeViewSubItems(string passedSubItemName, string passedSubItemJobStatus)
    subItemName = passedSubItemName;
    subItemJobStatus = passedSubItemJobStatus;
    public string subItemName
    get { return this.GetValue<string>(); }
    set { this.SetValue(value); }
    public string subItemJobStatus
    get { return this.GetValue<string>(); }
    set { this.SetValue(value); }
    public static void AddTreeViewItems(string passedTopNodeName, string passedChildItemName, string passedChildItemJobStatus)
    treeViewObsCollection.Add(new TreeViewClass(passedTopNodeName)
    mainNodes =
    new TreeViewSubItems(passedChildItemName, passedChildItemJobStatus)
    The problem lies with the AddTreeViewItems method
    seen above. Currently, if I call the method by let's say:
    AdvancedErrorCalculationViewModel.AddTreeViewItems("Parent","Child 1", "Completed");
    it creates the parent and child nodes just fine. No issues there.
    However, if I call the method again with the same Parent name but a different Child; for example: 
    AdvancedErrorCalculationViewModel.AddTreeViewItems("Parent","Child 2", "Completed");
    It creates a new Parent node with a child node Child 2 instead. Thus, I have something like this:
    - Parent
    - Child 1
    - Parent
    - Child 2
    I would like to modify this function so that if the parent name is the same, the child node should belong under the previous Parent instead
    of under a new Parent node. Something like this:
    - Parent
    - Child 1
    - Child 2
    Could anyone help me modify my code to detect if the Parent node exists in the observablecollection already and if so, place the child node under the existing parent? The main problem I am facing is trying to add items to a previously created observable collection
    with an existing hierarchy because I don't know how to access the previous observable collection anymore. Help me with this please.
    Thanks in advance. :)

    You need to try and find an existing entry and if it's there add the child to that instead.
    I notice you're  a student and I guess this is probably an assignment.
    By the way.
    I suggest you work on the name of your collections and classes there.
    EG A class should be singular but way more meaningfull than treeviewsubitem.
    Anyhow, finding the top node could be done using linq.  Since you can get none, SingleOrDefault is the method to use.
    Thus something like:
    TreeViewClass tvc = treeViewObsCollection.Where
    (x=>x.Title == passedTopNodeName).SingleOrDefault();
    Will give you tvc null or the qualifying entry.
    If it's null, do what you have now.
    If it's not then add the child item to tvc.
    tvc is a reference to the TreeViewClass you have in that collection.
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • Mapping Help required in Node count

    Hi Friends,
       i  need to count the number of occurences of source node. i'm able to count the occurences.
       but i have some problem with this node. Source node happens only some times.
      Source node.
       <Event>
           type-                      attribute
           <Date>20092509</Date>
       </Event>
    Sometimes Event tag comes as </Event> without any type value then i need to pass " 0 " value.
      Cases :
      1. if empty Event tag happens then need to Pass  "0"
      2.  <Event>
               type
               <Date></Date> in this case also need to pass 0.
    3.    <Event>
               type "Order"
           <Date>20092509</Date>
       </Event>
          <Event>
           type "Delivery"
           <Date>20092509</Date>
       </Event>
      in this case need to pass node count as "2"
    please suggest me on this;
    Regards,
    Deeps

    Hi sandeep,
    Map like this..
                         Date--\
                               then
    Date---->NotEquals---->if          -----\
    Constant[]/                             \
                              else            \
                Constant[0]/                   \
                                             then
    Date----->Exisists---->if--------        ----->Output
                                            else
                               Constant[0]/
    I tested this...
    Working Fine...
    Thanks.

  • Mapping help required - extension

    Hi,
    I 've done the mapping based on the below conditions
    Let say 3 fields called : a,b,c
    if a = RAM then
    b = b/c
    here b field is in one segment and a & c fields are in child segment of above segment.
    Note : all the above fields occurance : 0 to 1
    But, i need to display the target including with the above condition also i need the value of the field "b" should display at target side where the condition doesn't satisfy ..  ie., a # RAM.
    Here i 've tried with if then else condition...but that doesn't work.
    Please help me out how can i get the output.
    Thanks in advance for your help
    Regards,
    Y.Raj

    Hi Yeshwant,
    IF you have the source structure as:
    segment
    --b
    ---subsegment
    a
    c
    then you may need these changes in Raj's mapping image
    b-----------------------------------|
    c (context changed to parent of c)--| useoneasmany -- divide
    c ----------------------------------|
    b-----------------------------------|
    c (context changed to parent of c)--| useoneasmany -- else
    c ----------------------------------|
    Regards
    Suraj

  • Scenario mapping - help required

    Scenario:
    A Customer sends a material (for e.g., SUGARCANE) to the company (SAP Implementing). It processes it and send back as SUGAR.
    The customer is charged for the services rendered.
    The stock of sugarcane/sugar should be visible in the system.
    Please guide me how to map this scenario.
    I will be very much grateful.
    Regards,
    Anbu

    This sales process is referred as Job Work in SAP.
    Refer following SDN thread that can be helpful to you in understanding / reference:
    - Sales Process of JOB WORK
    If in case you have any concern or doubt about the process, do revert back.
    But don't forget to put a effort search more information on JOB WORK for reference/understanding. So that you can specific to your requirement.
    Regards
    JP

  • Mapping help required

    Dear Experts,
    We are working in PI 7.1 Source and target structure are like:
    Node1
         F1
         F2
         F3
         F4
    Node2
          F1
          F2
          F3
          F4
    Node2
          F1
          F2
          F3
          F4
    The requirement like if F2's value is X then we have to pass only that field of that Node in the target side and if F2 is '0' then all the fields would be passed. Target structure is same as source.
    Please advise how can I achieve this.
    Regards,
    Kami

    Hi Kami,
    refer the mapping concept wiki
    Mapping Concepts in SAP XI - Process Integration - SCN Wiki
    regards,
    Harish

  • Hierarchy display child and parent nodes -- Urgent Please

    Sorry wrong forum
    Message was edited by:
            Shree Sunder

    I like ListAgg :D
    with RELATION(PARENT,CHILD) as(
    select NULL,'A' from dual union all
    select 'A', 'B' from dual union all
    select 'A', 'C' from dual union all
    select 'B', 'D' from dual union all
    select 'B', 'E' from dual union all
    select 'D', 'F' from dual union all
    select 'C', 'G' from dual union all
    select NULL,'H' from dual union all
    select 'H', 'I' from dual union all
    select 'H', 'J' from dual)
    SELECT ListAgg(child,'<-')
           within group(order by Level desc) as revPath
    FROM relation
    START WITH child = 'F'
    CONNECT BY PRIOR parent = child;
    revPath
    A<-B<-D<-F

  • Complex Mapping :-Help Required

    Hi All,
    I have a scenario XI--IDoc.
    Sender structure is having one field as Description which will carry some informatiom.I have to read the Summary Field and if I get XAA1:686,XAA2:767 or XAA3:876 like this  inside this  inside this field than I have substring  and take those value individually than we have to map it accordingly.
    You can consider all these value will come separated by ,(comma) and based of the sbustring we have to map it.
    Thanks,
    Rakhi

    1) Pattern p = Pattern.compile("\\b([X][A-Z]{2}[0-9][:][0-9]{3})\\b");
    we made a regular expression here and compiled it and then we make a object of class Matcher to match this compiled regex with our string
    Matcher m = p.matcher(str);
    //then we traverse through the results given to us my this matcher in an array form that is a array constituted by the different values that match this regex.....we traverse this array (m.find()) until this condition is true.....
    then we add the result into the display queue.
    while (m.find())
        String s = m.group(1);
        result.addValue(s);
    (\\b is actually \b to include this \(escape character) i had used two \\
    this is the real regex
    \b([X][A-Z]{2}[0-9][:][0-9]{3})\b
    \b means a seprator between words it can be anything tab or whitespace or new line
    () we use these brackets to mark a word or a unit here this XAA8:456 is a unit so we put the reg ex for this inside braces
    [X] single value mentioned means that it searches for only the single X character
    the very next [A-Z]{2} means that it searches for any character in range A-Z and this rule searches for combination of two letters that follow this rule it means that it searches for two characters together following this i.e adjacent like DF, GY if you think that you want to further drill down your pattern and you will always have AA you can replace this [A-Z]{2} by [A]{2} so it searches for XAA
    now the next thing should be a digit  so we have 0-9 if you dont specify {3} or any number in curly braces it assumes that you are searching for a single character
    then [0-9]{3} digits in the end.....
    use this site if you want to learn regex you can test your regex here
    http://regexr.com/#
    working on your next req

  • Mapping Help required for ORDER Idoc to EDI file

    Hi
    My source strcture is as follows
    E1EDP01
    E1EDP01
       E1EDPT1 (TDID=0001)
         E1EDPT2
             TDLINE = abcd
       E1EDPT1 (TDID=0001)
         E1EDPT2
             TDLINE = XYZ
    and my target line item is mapped with TDLINE(Context E1EDP01)-exist then createif LineItem(This is working fine but item filed is failing)
    The logic to populate itemFIELD1 is if E1EDT1(TDID==0001) then pass TDLINE to ItemFIELD1, how to map this
    (Sometimes E1EDPT2 populate multiple times for one E1EDPT1)

    >and my target line item is mapped with TDLINE(Context E1EDP01)-exist then createif LineItem(This is working fine but item filed is failing)
    Why don't you create the LineItems only when TDID = 0001 because this will ensure to populate item fields with correct value.
    The mapping logic to produce the LineItems should be like this..
    IF (TDID = 0001) THEN (TDLINE set context to E1EDPT1)---RemoveContext---LineItem.
    >The logic to populate itemFIELD1 is if E1EDT1(TDID==0001) then pass TDLINE to ItemFIELD1, how to map this
    In this mapping make sure the context of TDLINE is set to E1EDPT1 and then use RemoveContext ---SplitByValue to the output of "IF" function. e.g.
    IF (TDID = 0001) THEN (TDLINE set context to E1EDPT1)---RemoveContext---SplitByValue---FIELD1.

  • Using FileOutputStream for File Creation. Help Required!!

    Folks,
    I am using the FileOutputStream to create a file.For this I am
    saying:
    FileOutputStream fout2 = new FileOutputStream("Name.txt");
    This creates the File in the Current directory of the IDE(JBuilder 5).
    I want to create ths File in the a logs directory,taking the
    relative path.
    So I want the File to be created as ./logs/Filename.txt??
    How do I set the relative path in the FileOutputStream ??
    Can anyone please respond?

    Yes, "." does not coincide with the classes directory, especially when starting the application from an IDE.
    Take a look at the system properties for some directories:
    System.getProperties().list(System.out);
    System.putProperty("user.dir", "...");For your means I would abuse the ClassLoader, and specify a full path, and start to patch a file name from it:
    java.net.URL u = this.getClass().getResource(".../x.gif");

  • Context Mapping: child-nodes of non-mapped parent nodes

    I am somewhat curious about Context Mapping in WebDynpro.
    Which parents nodes need to be mapped in order to map child nodes ? Does a child node has more than one parent node (e.g. grandparent - two steps above) ?
    A.1  -
    MAPPED----
    >    B.1
      - A1.1   NOT MAPPED
      - A1.2   NOT MAPPED
            - A.1.2.1     MAPPED TO>    B.1.2.4
            - A.1.2.2   NOT MAPPED
      - A1.3   NOT MAPPED
    Is it sufficient that only one of these parent nodes (e.g. direct parent node not mapped, but parent node of this parent node is mapped) need to be mapped so that the child node can be mapped ?
    Is this assumption true or not ?
    The SAP library states:
    "Conversely, child nodes of non-mapped parent nodes cannot be mapped, otherwise this would result in irresolvable conflicts at runtime with respect to the parent-child relation in the context and the mapping relation." (http://help.sap.com/saphelp_nw04/helpdata/de/51/a3384162316532e10000000a1550b0/content.htm)
    This statement is not absolutely clear on this issue.

    Let me put it this way
    You have a node vehicle and you have a child node for that the car. The car node have parameters car1, car2.
    Let the vehicle node have parameters veh1 and veh2
    Then if you map vehicle node one to any other node (say in the comp. controller) you have the option of mapping its children i.e veh1,veh2 and carnode.
    You can have that veh1 is mapped and veh2 is not mapped.
    vehicle node(mapped)
    veh1(may or may not be mapped)
    veh2(may or may not be mapped)
    car node(may or may not be mapped)
    If instead you try to map only the car node the vehicle node will also get mapped automatically but not it's child parameters like veh1 and veh2.
    vehicle node(mapped)
    veh1(may or may not be mapped)
    veh2(may or may not be mapped)
    car nodemapped)
    car1(may or may not be mapped)
    car2(may or may not be mapped)
    Hope this would help.
    Do revert for further clarification
    Regards
    Noufal

  • Copy values from one Parent node to other Parent Node

    Hi all,
    I have a 2 Parent node each having 3 child nodes. I want to copy the values of all the attributes of all the child nodes of one Parent Node to corresponding other node.
    Both the Parent Nodes as well as their Child Nodes have different name but their attributes have same name.For ex:
    Parent Node -A
    Child Nodes - a, b,c
    Child Node "a" has attributes "x" and "y"
    Parent Node -B
    Child Nodes - d,e,f
    Child Node "d" has attributes "x" and "y" .
    Now I want to copy the values od attributes "x" and "y" from one Parent Node to other Parent node.
    Please help me out.
    Helpful answers will be rewarded.
    Thanxs in advance...

    Hi Jin,
    To use copy service API, u need to satisfy 2 condition for the attributes of source node and target node:
    1. The name of the attribute should be same (including the case of the name)- Abc is different from ABC
    2. Type of the attribute should also be the same.
    copy elements works for copying values from Model node to context and does not work vice-versa. To enable the copying of context node to model node, use copycorresponding API.
    Eg:
    int contextNodeSize = wdContext().node<contextNodeName>().size();
    for(int i = 0; i < contextNodeSize; i++)
         <modelNodeName> modelObject = new <modelNodeName>();
         <contextNodeName>Element contextObject = wdContext().node<contextNodeName>().get<contextNodeName>ElementAt(i);
         WDCopyService.copyCorresponding(contextObject, modelObject);
    This will copy the values from Context Node to Model Node.
    Hope this helps you.
    Regards,
    Poojith MV

  • External Context Mapping - Pass data from Child to Parent

    Hello,
    I have the following scenario:
    DCParent Component (contains)
    - DCChildComp1    (used DC)
    - DCChildComp2    (used DC)
    - DCChildComp3    (used DC)
    - DCChildComp4    (used DC)
    What user enters in DCChildComp1 then needs to be made available to DCParent and all other DCChildComp(n) siblings.
    I have looked the posts and blogs in SDN and all of them seem to deal with passing inputField data from Parent to Child. May be I am missing it.
    In my case, I need the data to be passed from DCChildComp1 to DCParent ie Child to Parent. Then from DCParent to other DCChildComps.
    How should I go about
    a. defining the context nodes and Component Interface context nodes in parent vs child vs siblings and
    b. how should I map them externally?
    Step by step instruction would be helpful.
    Thanks in advance,
    SK.

    Thanks for all the help. As I had already seen all the links and blogs you had linked here, I was still confused about how it all came together. Finally, I got it after reading Bertram Ganz's response in this thread [Context Mapping problem;.
    when you map a context in the parent comp to an interface context in the used child component you do not define an external context mapping relation. That's normal context mapping as the data context resides in the child component.
    I have it working now and I am able to push the changes in the child component's context to the parent.
    For those who are interested in how I did it (and those who know a better way to do it
    In the child component DC:
    Map Child's View Context to Child's Controller Context
    Map Child's Controller Context to Child's Interface Controller (make sure the inputEnabled is FALSE - as the child is the data producer and the parent is the data consumer, in my case)
    In the parent DC:
    Add child DC as a Used DC
    Add child Component as a Used Component in the Parent Component
    Add Child's Interface Controller as Required Controller in Parent Component
    Map Child's Interface Controller Context to Parent's Controller Context
    Map Parent's Controller Context to Parent's View Context
    No external mapping required per the thread above. Now, any change in the child component's view is visible in the parent component view.
    Thanks again very much for the help.
    - Siva

  • Problem with trees(Duplication of the parent node in creation of  children)

    Hi guys i am experiencing a slight problem with the creation of trees.Here is a clear explanation of my program.I created a program that generates edges from a set of datapoints then use each and every edge that is generated to create multiple trees with the edge as the rootnode for each and every tree.Everything up to so far everything went well but the problem comes when i want the program to pick every single tree and traverse through the set of generated edges to create the children of a tree.What it does at the moment for each tree is returning the a duplication of the parent node as the child nodes and that is a problem.Can anyone related with this problem help.Your help will be appreciated.
    The code
    TreeNode class
    package SPO;
    import java.util.*;
    public class TreeNode
            Edge edge;
            TreeNode node;
         Vector childrens = new Vector();
            public TreeNode(Edge edge)
                    this.edge = edge;
            public synchronized  void insert(Edge edge)
                    if(edge.fromNode == this.edge.toNode)
                            if(node == null )
                                    node = new TreeNode(edge);
                                    childrens.add(node);
                            else
                        node.insert(edge);
                                    childrens.add(node);
    Tree class
    package SPO;
    import java.util.*;
    public class Tree
            TreeNode rootNode;
         public Tree()
                    rootNode = null;
            public Tree[]  createTrees(Vector initTrees,Vector edges)
                   Tree [] trees =  new Tree[initTrees.size()];
                   for(int c = 0;c < trees.length;c++)
                      trees[c] = (Tree)initTrees.elementAt(c);     
                   for(int i = 0;i < trees.length;i++)
                            for(int x = 0;x < edges.size();x++)
                                    Vector temp = (Vector)edges.elementAt(x);
                                    for(int y = 0;y < temp.size();y++)
                                           trees.insertNode((Edge)temp.elementAt(y));
    return trees;
    public void printTree(Tree tree)
    System.out.print("("+tree.rootNode.edge.fromNode.getObjName()+","+tree.rootNode.edge.toNode.getObjName()+")");
    Vector siblings = tree.rootNode.childrens;
    for(int i = 0; i < siblings.size();i++)
    TreeNode node = (TreeNode)siblings.elementAt(i);
    System.out.print("("+node.edge.fromNode.getObjName()+","+node.edge.toNode.getObjName()+")");
    System.out.println();
    public Vector initializeTrees(Vector edges)
    Vector trees = new Vector();
    for(int i = 0;i < edges.size();i++)
    Vector temp = (Vector)edges.elementAt(i);
    for(int j = 0;j < temp.size();j++)
    Tree tree = new Tree();
    tree.insertNode((Edge)temp.elementAt(j));
    trees.add(tree);
    return trees;
    public synchronized void insertNode(Edge edge)
    if(rootNode == null)
    rootNode = new TreeNode(edge);
    else
    rootNode.insert(edge);
    EdgeGenerator class
    package SPO;
    import java.util.*;
    import k_means.*;
    public class EdgeGenerator
         public EdgeGenerator()
    public Vector createEdges(Vector dataPoints)
    //OrderPair orderPair = new OrderPair();
    Vector edges = new Vector();
    for(int i = 0;i < dataPoints.size()-1 ;i++)
    Vector temp = new Vector();
    for(int j = i+1;j < dataPoints.size();j++)
    //Create an order of edges
    Edge edge = new Edge((DataPoint)dataPoints.elementAt(i),(DataPoint)dataPoints.elementAt(j));
    temp.add(edge);
    edges.add(temp);
    return edges;
    Edge class
    package SPO;
    import k_means.*;
    public class Edge
    public DataPoint toNode;
    public DataPoint fromNode;
    public Edge(DataPoint x,DataPoint y)
    if (x.getX() > y.getX())
    this.fromNode = x;
    this.toNode = y;
    else
    this.fromNode=y;
    this.toNode = x;
    Entry Point
    package SPO;
    import java.util.*;
    import k_means.*;
    public class Tester {
         public static void main(String[] args)
              Vector dataPoints = new Vector();
              dataPoints.add(new DataPoint(140, "Orange"));
              dataPoints.add(new DataPoint(114.2, "Lemmon"));
              dataPoints.add(new DataPoint(111.5, "Coke"));
              dataPoints.add(new DataPoint(104.6, "Pine apple"));
              dataPoints.add(new DataPoint(94.1, "W grape"));
              dataPoints.add(new DataPoint(85.2, "Appletizer"));
              dataPoints.add(new DataPoint(84.8, "R Grape"));
              dataPoints.add(new DataPoint(74.2, "Sprite"));
              dataPoints.add(new DataPoint(69.2, "Granadilla"));
              dataPoints.add(new DataPoint(59, "Strawbery"));
              dataPoints.add(new DataPoint(45.5, "Stone"));
              dataPoints.add(new DataPoint(36.3, "Yam"));
              dataPoints.add(new DataPoint(27, "Cocoa"));
              dataPoints.add(new DataPoint(13.8, "Pawpaw"));
    EdgeGenerator eg = new EdgeGenerator();
    Vector edges = eg.createEdges(dataPoints);
    Tree treeMaker = new Tree();
    Vector partialTrees = treeMaker.initializeTrees(edges);
    Tree [] trees = treeMaker.createTrees(partialTrees,edges);
    for(int i = 0;i < trees.length;i++)
    treeMaker.printTree(trees[i]);
    The program output
    Each and every "@" symbol represents the start of a tree
    @(Orange,Lemmon)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)
    @(Orange,Coke)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)
    @(Orange,Pine apple)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)
    @(Orange,W grape)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)
    @(Orange,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
    @(Orange,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
    @(Orange,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
    @(Orange,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
    @(Orange,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(Orange,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(Orange,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Orange,Cocoa)(Cocoa,Pawpaw)
    @(Orange,Pawpaw)
    @(Lemmon,Coke)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)
    @(Lemmon,Pine apple)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)
    @(Lemmon,W grape)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)
    @(Lemmon,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
    @(Lemmon,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
    @(Lemmon,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
    @(Lemmon,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
    @(Lemmon,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(Lemmon,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(Lemmon,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Lemmon,Cocoa)(Cocoa,Pawpaw)
    @(Lemmon,Pawpaw)
    @(Coke,Pine apple)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)
    @(Coke,W grape)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)
    @(Coke,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
    @(Coke,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
    @(Coke,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
    @(Coke,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
    @(Coke,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(Coke,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(Coke,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Coke,Cocoa)(Cocoa,Pawpaw)
    @(Coke,Pawpaw)
    @(Pine apple,W grape)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)
    @(Pine apple,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
    @(Pine apple,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
    @(Pine apple,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
    @(Pine apple,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
    @(Pine apple,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(Pine apple,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(Pine apple,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Pine apple,Cocoa)(Cocoa,Pawpaw)
    @(Pine apple,Pawpaw)
    @(W grape,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
    @(W grape,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
    @(W grape,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
    @(W grape,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
    @(W grape,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(W grape,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(W grape,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(W grape,Cocoa)(Cocoa,Pawpaw)
    @(W grape,Pawpaw)
    @(Appletizer,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
    @(Appletizer,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
    @(Appletizer,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
    @(Appletizer,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(Appletizer,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(Appletizer,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Appletizer,Cocoa)(Cocoa,Pawpaw)
    @(Appletizer,Pawpaw)
    @(R Grape,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
    @(R Grape,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
    @(R Grape,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(R Grape,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(R Grape,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(R Grape,Cocoa)(Cocoa,Pawpaw)
    @(R Grape,Pawpaw)
    @(Sprite,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
    @(Sprite,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(Sprite,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(Sprite,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Sprite,Cocoa)(Cocoa,Pawpaw)
    @(Sprite,Pawpaw)
    @(Granadilla,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
    @(Granadilla,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(Granadilla,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Granadilla,Cocoa)(Cocoa,Pawpaw)
    @(Granadilla,Pawpaw)
    @(Strawbery,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
    @(Strawbery,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Strawbery,Cocoa)(Cocoa,Pawpaw)
    @(Strawbery,Pawpaw)
    @(Stone,Yam)(Yam,Cocoa)(Yam,Cocoa)
    @(Stone,Cocoa)(Cocoa,Pawpaw)
    @(Stone,Pawpaw)
    @(Yam,Cocoa)(Cocoa,Pawpaw)
    @(Yam,Pawpaw)
    @(Cocoa,Pawpaw)

    Your program description makes no sense. What exactly is it supposed to do?
    Your errors make no sense. What is it doing wrong?
    Your program output makes no sense. Look up pre-order, in-order, and post-order notation for representing trees. Pick one of those that you think would be best. I would go with pre-order. Because what you are doing isn't understandable.
    By the way, I think your concept of a tree is flawed. A node in a tree has 3 things. it has a reference to its parent, it has references to any of its children, and it has some key value that represents the node (if each node were represented by numbers, the value would be an integer or something). In the case of the root, its reference to its parent is null. I don't know what you are doing with your tree, but it is highly confusing.

Maybe you are looking for

  • N80 firmware upgrade product code

    I HAVE READ YOU BOARD RE PRODUCT CODE VARIANTS. VODAFONE ASSURE ME THAT THEY HAVE PROVIDED NOKIA WITH THEIR VARIANT?? MY N80 PRODUCT CODE IS 0535066 CAN YOU HELP MANY THANKS AGAIN FOR YOUR ASSISTANCE

  • Question about cache

    hi all we just upgrade the apex from version 1.6.1.00.03 to version 3.1.2.00.02 because this upgarde was a massive upgrade i need to do some tests to my application. now i've noticed that in the new version there is a cache option in the region,edit

  • Problems with JAVASCRIPT after upgrade to 10.4.3

    Hi There, I have upgraded to 10.4.3 and I have problems using my GMAIL account (cant send emails) the message reads like this (see below). Javascript problems Oops...the system was unable to perform your operation. Please try again in a few seconds.

  • Tracking of points

    Hello everyone, is there any "standard" algorithm for tracking a lower number of points (i.e. ~ 5 ) in a sequence of frames? At the current point, I'm able to analyse a video stream and search for the center points of circles. Now i have to determine

  • Many iTunes issues:

    loaded AppTV - good.  Turned on home share - I think good.  Got new iPhone - good.  Purchased iMatch - I don't think so good.  Synch iphone to cloud and not computer - NOT good. All this happened on the same day.  My iTunes are a MESS.  Half my playl