Obtain only top two nodes in JTree

I have a JTree (say, tree1) with 6 levels. I want another JTree (say, tree2) which has only the top two rows of tree1 i.e, I want the root and it's children only (no grand-children).
How do I get it?
Thanks.
Pavan

Just add a constructor to your subclass:
class MyTreeNode extends DefaultMutableTreeNode {
  public MyTreeNode(Object obj) {
    super(obj);
...Regards

Similar Messages

  • Help needed with finding node in JTree

    Hi,
    In my application i will be entering some string data in a text box for search criteria.
    When I click on search, I will get data from database which will be shown as a JTree.
    This Jtree will have some nodes in which, node with string entered in the search text box exists.
    I need to focus on this node and I have only a string to find this node.
    How can I do this?How can I find a node in JTree using string value?
    Is there any alternate option by which I can achive my need?
    Please suggest.
    Thanks.

    @OP: please assign your dukes.
    @Andre_Uhres: if you don't get rewarded in the next couple of days, please let me know here to get at least one duke for your effort.
    Bye.

  • How to create reports servers with the same name in two nodes in Reports

    Greetings
    We are migrating Oracle Application Server 10g (9.0.4) to a better hardware infrastructure with high availability. We want to provide 2 new Oracle Application Server 10g (9.0.4) in High availability and we want to avoid modify the existing forms and reports code, but the code is looking for a specific reports server name when calling reports, but I couldn't create the same reports server name in the both oas machines, I could create the reports server in only one node. I want to create a reports server with the same name in both nodes but it is not possible. I know that there is a procedure to do that in 10.1,2 (Note 437228.1, How to Create Two Reports Servers With the Same Name in the Same Subnet) but I couldn't find the equivalent procedure in 9.0.4.
    Anybody kwows how to create a reports server with the same name in two nodes using 10g (9.0.4)
    Thanks
    Ramiro Ortiz.

    Hello.
    I applied the patch 4092150 on my oas 9.0.4.2 and I modified my rwnetwork.conf file changing the port to 14022 by following the note "How to Create Two Reports Servers With the Same Name in the Same Subnet? [ID 437228.1]" but I am facing the same error rep-56040 "server already exists in the network".
    When I run osfind command I get the following information (My reports server is senarep and I want to create it on SNMMBOGOAS10):
    osfind: Found 2 agents at port 14000
    HOST: SNMVBOGOAS10.sena.red
    HOST: SNMVBOGOAS09.sena.red
    osfind: There are no OADs running on in your domain.
    osfind: There are no Object Implementations registered with OADs.
    osfind: Following are the list of Implementations started manually.
    HOST: SNMVBOGOAS10.sena.red
    REPOSITORY ID: IDL:oracle/reports/server/EngineComm:1.0
    OBJECT NAME: senarep2
    REPOSITORY ID: IDL:oracle/reports/server/ServerClass:1.0
    OBJECT NAME: senarep2
    HOST: SNMVBOGOAS09.sena.red
    REPOSITORY ID: IDL:oracle/reports/server/EngineComm:1.0
    OBJECT NAME: senarep
    REPOSITORY ID: IDL:oracle/reports/server/ServerClass:1.0
    OBJECT NAME: senarep
    Any Ideas?

  • Can fiber channel be used for connect server to a storage in two nodes RAC

    I decided to have an Oracle RAC cluster with only two nodes.
    The storage I have is a sun 3510FC. Also have five fiber chanal ports. But my each server (Sunfire v240) has got one Ultra160SCSI multimode (SE/LVD) not any fiber chanal ports. I found that there is some FC card available to use but none fiber switch available. I want to install this FC cards to the servers and make a straight connection with fibre cable to the storage. Can this be asolution or do i have to have a fibre switch?

    Hi
    Irrespective of whether such a configuration is supported or not by Oracle.
    Has anybody got 10gR2 RAC working on
    a. 2 servers
    b. shared storage with HBA and fibre channel cables
    c. interconnect on LAN
    (yes we know it is not supported by Oracle...but again we are not going production on that....just for demo/training purposes)
    No FC switch
    No ethernet switch
    If anybody has got this working would be great to hear of 'issues to guard against'
    Thanks

  • Is it possible to restrict the user from creating a sibling and allow him to ONLY create child nodes in DRM?

    When in a hierarchy, a user right clicks on a node to crate a new node, he has two options
    -Child
    -Sibling
    Is it possible to restrict the user from creating a sibling and allow him to ONLY create child nodes?
    Business cases:
    1. different level nodes need to have different prefixes.
    - Thus, the default prefix property definition uses the level number to assign a prefix
    - Also, a validation, to ensure the correct prefix, uses the level number
    But if the user can create a child and a sibling then the default prefix will only be right for a single case and not both.
    Thanks

    If the images are exactly the same size then make sure the layer with the mask
    is the active layer and in the other documents go to Select>Load Selection and choose
    your document with the layer mask under Source document and under channel choose the layer mask.
    After the selection loads press the layer mask icon at the bottom of the layers panel.
    MTSTUNER

  • 11gR2- webutil upload file to AS on two nodes RAC?

    Hellow experts plz help with the following issue,
    we are using 11gR2 forms on two node rac,webutil configured on both nodes. upload/download files to AS folder(UP_FILES) using our forms. node 2 is actually replica of node 1(forms,reports,UP_FILES). we are now facing a problem that the form which upload file to AS, only upload that to the node from where it is running say if it is running from node1 then it upload files to folder UP_FILES on that node( as the entry in webutil.cfg file) but we want that UP_FILES folder should be synced with each other on both nodes and a form running whether from node1 or node2 upload the file to both nodes at time.
    How this will be accomplished?
    --------webutil.cfg entry
    transfer.appsrv.read.3=D:\UP_FILES
    transfer.appsrv.write.3=D:\UP_FILES
    -----FORM UPLOAD CODE
          IF :CONTROL.FILE_LOC IS NOT NULL THEN
            acyr3 := :CONTROL.TXTVOUCHERNO||'-'||acyr2 ;
           FILE_RESULT := WEBUTIL_FILE_TRANSFER.CLIENT_TO_AS_WITH_PROGRESS(CLIENTFILE=>:CONTROL.FILE_LOC,
           SERVERFILE =>'D:\UP_FILES\'||acyr3||'.PDF',
          PROGRESSTITLE=>'UPLOAD TO DATABASE IN PROGRESS',
          PROGRESSSUBTITLE=>'PLEASE WAIT' );
          END IF;
    --FORM DOWNLOAD CODE
            FILE_RESULT := WEBUTIL_FILE_TRANSFER.AS_TO_CLIENT_WITH_PROGRESS
                 CLIENTFILE=>'D:\UP_FILES\'||acyr3||'.PDF',
            SERVERFILE =>'D:\UP_FILES\'||acyr3||'.PDF',
          PROGRESSTITLE=>'DOWNLOAD FROM DATABASE IN PROGRESS',
          PROGRESSSUBTITLE=>'PLEASE WAIT'
                 CLIENT_HOST('rundll32.exe url.dll,FileProtocolHandler D:\UP_FILES\'||acyr3||'.PDF');
                 IF FILE_RESULT THEN
      message('File downloaded successfully from the Application Server');
      END IF;

    Well, you're uploading the file to one node, so this is no surprise. What you can do is to store your file on a shared folder (which might be a bit tricky on windows) or synchronize a folder between your nodes. Unfortunately Forms can't access ASM directly (assuming you are using ASM), so you can't store your files directly in ASM where it would be accessible from both nodes.
    cheers

  • Problem inserting new node into JTree with depthFirstEnumeration()

    Hello,
    I'm currently trying to use depthFirstEnumeration() to add and delete nodes for a simple JTree. I've written a method to handle this, but it keeps coming back with an exception saying that 'new child is an ancestor'.
    All I'm trying to do is add and delete nodes from a JTree using add and remove buttons within a swing program. When a user adds the new node the JTree needs to be updated with new labels in sequential order dependent upon a depthFirst traversal of the JTree.
    My current code for the add button is as follows,
    public void actionPerformed(ActionEvent event) 
            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
            Enumeration e = rootNode.depthFirstEnumeration();
            if(event.getSource().equals(addButton))
                if (selectedNode != null)
                    while (e.hasMoreElements()) {
                    // add the new node as a child of a selected node at the end
                    DefaultMutableTreeNode newNode = (DefaultMutableTreeNode)e.nextElement();
                     // treeModel.insertNodeInto(newNode, selectedNode, selectedNode.getChildCount());
                    //System.out.print(newNode.getUserObject() + "" + newNodeSuffix++);
                    String label = "Node"+i;
                    treeModel.insertNodeInto(newNode, selectedNode, selectedNode.getChildCount());
                    i++;
                      //make the node visible by scrolling to it
                    TreeNode[] totalNodes = treeModel.getPathToRoot(newNode);
                    TreePath path = new TreePath(totalNodes);
                    tree.scrollPathToVisible(path);
                    //System.out.println();
            else if(event.getSource().equals(deleteButton))
                //remove the selected node, except the parent node
                removeSelectedNode();           
        } As you can see in the above code, I've tested the incrementing of the new nodes in a System.out.print() statement and they appear to be incrementing correctly. I just can't see how to correctly output the labels for the nodes.
    Any help and advice always appreciated.

    This is about the 5th posting on the same question. Here is the link to the last posting so you can see what has already been suggested so you don't waste your time making the same suggestion.
    http://forum.java.sun.com/thread.jspa?threadID=704980
    The OP doesn't seem to understand that nodes don't just rename themselves and that renderers will only display the text of the current node. If you want the text displayed to changed, then you need to change the text associated with each node, which means iterating through the entire tree to update each node with new text. Then again, maybe I don't understand the question, but the OP keeps posting the same question without any additional information.

  • New SMB share - can access only from owner node

    Two nodes new Windows 2012R2 cluster on Azure. Setup all completed OK and with no issue. Cluster is online and can failover to both nodes. Create FileServer and then created couple of share using SMB quick. Access left for the default "EveryOne Full
    control"
    Now, I can access the share from the current node of the cluster and ONLY  if I failover the cluster to the second , I started to access the share. Also other machines on the same network can not access the share (All Windows 2012R2)
    I saw few similar posts and read them all , but that does seem to help me. Please advise of any information to resolve this.
    Thanks

    Hi Sir,
    >>Create FileServer and then created couple of share using SMB quick. Access left for the default "EveryOne Full control"
    If you share the folder in Windows Explorer as you normally would for a file share , Please refer to following article regarding to add a file share on existing cluster :
    http://msdn.microsoft.com/en-us/library/dd897486(v=bts.10).aspx
    http://msdn.microsoft.com/en-us/library/dd897474(v=bts.10).aspx
    Best Regards
    Elton Ji
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Creation of diskset in Two node cluster

    Hi All ,
    I have created one diskset in solaris 9 using SVM in two node cluster.
    After diskset creation, I mounted the diskset in a primary node in the mount point /test. But, the disk set is mounting on both the nodes.
    I created this diskset for failover purposes, if one node goes down the other node will take care.
    My idea is to create a failover resource (diskset resources) in the two node cluster.
    Below are steps used for creating the disk set.
    root@host2# /usr/cluster/bin/scdidadm -L d8
    8        host1:/dev/rdsk/c1t9d0   /dev/did/rdsk/d8
    8        host2:/dev/rdsk/c1t9d0   /dev/did/rdsk/d8
    metaset -s diskset -a -h host2 host1
    metaset -s diskset -a -m host2 host1
    metaset -s diskset -a /dev/did/rdsk/d8
    metainit -s diskset d40 1 1 /dev/did/dsk/d8s0
    newfs /dev/md/diskset/rdsk/d40
    mount /dev/md/diskset/dsk/d40 /test
    root@host2# metaset -s diskset
    Set name = diskset, Set number = 1
    Host                Owner
      host2                  Yes
      host1
    Mediator Host(s)    Aliases
      host2
      host1
    Driv Dbase
    d8   YesPlease let me know how to mount the disk set in one node.
    If i am wrong, please correct me.
    Regards,
    R. Rajesh Kannan.

    The file system will only mount on both (all) nodes if you mount it globally, i.e with the global flag or if there is an entry in /etc/vfstab that has a global option.
    Given your output below, I would guess you have a global mount for /test defined in /etc/vfstab.
    Regards,
    Tim
    ---

  • Setting the color of a particular node in JTree

    Hi all!
    I'm new to Java and facing a problem with JTrees.
    I'm using the following snippet to create a JTree :
    DeafultMutableTreeNode root = new DefaultMutableTeeNode("Letters");
    DeafultMutableTreeNode parent1 = new DefaultMutableTeeNode("uppercase");
    DeafultMutableTreeNode parent2 = new DefaultMutableTeeNode("lowercase");
    DeafultMutableTreeNode child1 = new DefaultMutableTeeNode("A");
    DeafultMutableTreeNode child2 = new DefaultMutableTeeNode("B");
    DeafultMutableTreeNode child3 = new DefaultMutableTeeNode("C");
    DeafultMutableTreeNode child4 = new DefaultMutableTeeNode("a");
    DeafultMutableTreeNode child5 = new DefaultMutableTeeNode("b");
    DeafultMutableTreeNode child6 = new DefaultMutableTeeNode("c");
    root.add(parent1);
    root.add(parent2);
    parent1.add(child1);
    parent1.add(child2);
    parent1.add(child3);
    parent2.add(child4);
    parent2.add(child5);
    parent2.add(child6);
    JTree tree = new JTree(root);
    JScrollPane pane = new JScrollPane(tree);
    TreePath path = tree.getNextMatch("lowercase", 0, javax.swing.text.Position.Bias.Forward);
    tree.setSelectionPath(path);
    tree.expandPath(path);
    In the above JTree, the node labeled "lowercase" gets selected and expanded as soon as the program is run.
    What i want to know is that, is there any way in which i can set only the "lowercase" node's background to a different color (say, YELLOW) and have it so, no matter if the node is expanded or collapsed or other nodes are expanded or collapsed.
    ps: Sample snippet would really b helpful.

    You need to write your own renderer for this.
    Read the tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#display

  • Setting the color of a node in JTree

    Hi all!
    I'm new to Java and facing a problem with JTrees.
    I'm using the following snippet to create a JTree :
    DeafultMutableTreeNode root = new DefaultMutableTeeNode("Letters");
    DeafultMutableTreeNode parent1 = new DefaultMutableTeeNode("uppercase");
    DeafultMutableTreeNode parent2 = new DefaultMutableTeeNode("lowercase");
    DeafultMutableTreeNode child1 = new DefaultMutableTeeNode("A");
    DeafultMutableTreeNode child2 = new DefaultMutableTeeNode("B");
    DeafultMutableTreeNode child3 = new DefaultMutableTeeNode("C");
    DeafultMutableTreeNode child4 = new DefaultMutableTeeNode("a");
    DeafultMutableTreeNode child5 = new DefaultMutableTeeNode("b");
    DeafultMutableTreeNode child6 = new DefaultMutableTeeNode("c");
    root.add(parent1);
    root.add(parent2);
    parent1.add(child1);
    parent1.add(child2);
    parent1.add(child3);
    parent2.add(child4);
    parent2.add(child5);
    parent2.add(child6);
    JTree tree = new JTree(root);
    JScrollPane pane = new JScrollPane(tree);
    TreePath path = tree.getNextMatch("lowercase", 0, javax.swing.text.Position.Bias.Forward);
    tree.setSelectionPath(path);
    tree.expandPath(path);
    In the above JTree, the node labeled "lowercase" gets selected and expanded as soon as the program is run.
    What i want to know is that, is there any way in which i can set only the "lowercase" node's background to a different color (say, YELLOW) and have it so, no matter if the node is expanded or collapsed or other nodes are expanded or collapsed.
    ps: Sample snippet would really b helpful.

    You need to write your own renderer for this.
    Read the tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#display

  • JCheckBox as nodes in JTree having problems with custom renderer and editor

    Ok, let me give some background. I have an XML document that I am parsing and reading in as a JTree. Works fine.
    Next, I have overwritten the DefaultTreeCellEditor to return a JCheckBox and in this implementation of the getTreeCellEditorComponent(), I actually tell the node that he is selected. Works great.
    Next, I have overwritten the DefaultTreeCellRenderer to return a JCheckBox and in the implementation of the getTreeCellEditorComponenet, I actually check to see if the Node is selected in the tree based upon the isSelected state of the actual Tree Node set in the tree cell editor, and if so, I set the JCheckBox to selected(true).Works Great.
    Now, here is the issue. If a node in the tree is selected that contains children, then I want all of the children of that node to also be selected. However, when I select a node with children only the selected node is changed, and then a few moments later, the system repaints the entire tree and ALL nodes int the tree are set to a selected state. Strange? Yes. Any ideas?? WONDERFUL!! :)
    Here is the TreeCellEditor code:
    public Component getTreeCellEditorComponent(JTree tree,
    Object value,
    boolean isSelected,
    boolean expanded,
    boolean leaf,
    int row)
    elementCheckBox_ = new JCheckBox();
    Component result = null;
    System.out.println("isSelected? Editor = " + isSelected);
    TreePath newPath = tree.getPathForRow(row);
    System.out.println("value = " + value.getClass().toString());
    if(value instanceof IMarketTreeNodeElement)
    if(isSelected)
    if(((IMarketTreeNodeElement)value).isSelected())
    ((IMarketTreeNodeElement)value).setSelected(false);
    else
    ((IMarketTreeNodeElement)value).setSelected(true);
    elementCheckBox_.setSelected(isSelected);
    return elementCheckBox_;
    Here is the TreeCellRenderer code:
    public Component getTreeCellRendererComponent(JTree tree,
    Object value,
    boolean selected,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus)
    Color colSelBorderCol = UIManager.getColor
    ("Tree.selectionBorderColor");
    selBorder_ = BorderFactory.createLineBorder(colSelBorderCol, 1);
    normBorder_ = BorderFactory.createEmptyBorder(1,1,1,1);
    elementCheckBox_.setText(value.toString());
    if(selected)
    elementCheckBox_.setSelected(selected);
    elementCheckBox_.setForeground(Color.YELLOW);
    elementCheckBox_.setBackground(Color.RED);
    else
    elementCheckBox_.setForeground(tree.getForeground());
    elementCheckBox_.setBackground(tree.getBackground());
    if (hasFocus)
    elementCheckBox_.setBorder(selBorder_);
    else
    elementCheckBox_.setBorder(normBorder_);
    return elementCheckBox_;
    Here is the Node Code setting all child nodes to selected:
    public void setSelected(boolean selected)
    isSelected_ = selected;
    if(isSelected_)
    if((this.getTagName() == "MARKET") ||
    (this.getTagName() == "TIER") &&
    (this.getChildCount() != 0))
    selectChildren(true);
    else
    if((this.getTagName() == "MARKET") ||
    (this.getTagName() == "TIER") &&
    (this.getChildCount() != 0))
    selectChildren(false);
    public boolean isSelected()
    return isSelected_;
    public void selectChildren(boolean selected)
    int children = getChildCount();
    for(int i = 0; i < children; i++)
    IMarketTreeNodeElement elem = (IMarketTreeNodeElement)
    this.getChildNodes().item(i);
    isSelected_ = selected;
    Thanks for any help! :-)

    I tried to run your sample code and it won't compile. The header files:
    #include
    #include
    #include
    #include
    #include
    do not exist on my install of MeasurementStudio. I am a bit suspicous that I don't have the latest and greatest (loading the dialong resouce gave version warnings). Here is one of my header file headers:
    //==============================================================================
    // Title : NiAxes3d.h
    // Copyright : National Instruments 1999. All Rights Reserved.
    // Purpose : Defines the CNiAxes3D class.
    //==============================================================================
    I
    looked on your updates site and don't really see an update that applies to ComponentWorks or MeasurementStudio. My version per the MAX program for 3DControls is 3.5.549.
    Do I need a newer version? What do I have to do to get the updated version? What does it cost?
    Chuck

  • Guest two node Failover Cluster with SAS HBA and Windows 2012 R1

    Hi all, i have two IBM x3560 brand new servers with V3700 IBM Storage. The Servers are connected to the storage through four SAS HBA adabters (two HBA's on each server). I want to create a two node guest Fileserver Failover Cluster. I can present the
    LUN's to the guest machines, but when i 'm running the cluster creation wizard it can't see any disk. I can see the disks on disk management console. Is there any way to achive this (the cluster creation) using my SAS HBA presented
    disks, or i have to use iSCSI to present the disks to my cluster?
    Thank you in advance, George
      

    Hi all, i have two IBM x3560 brand new servers with V3700 IBM Storage. The Servers are connected to the storage through four SAS HBA adabters (two HBA's on each server). I want to create a two node guest Fileserver Failover Cluster. I can present the
    LUN's to the guest machines, but when i 'm running the cluster creation wizard it can't see any disk. I can see the disks on disk management console. Is there any way to achive this (the cluster creation) using my SAS HBA presented
    disks, or i have to use iSCSI to present the disks to my cluster?
    Thank you in advance, George
    1) Update to R2 and use shared VHDX which is a better way to go. See:
    Shared VHDX
    http://blogs.technet.com/b/storageserver/archive/2013/11/25/shared-vhdx-files-my-favorite-new-feature-in-windows-server-2012-r2.aspx
    Clustering
    Options
    http://blogs.technet.com/b/josebda/archive/2013/07/31/windows-server-2012-r2-storage-step-by-step-with-storage-spaces-smb-scale-out-and-shared-vhdx-virtual.aspx
    2) If you want to stick with non-R2 (which is a BAD idea b/c tons of reasons) you can spawn an iSCSI target on top of your storage, make it clustered and make it provide LUs to your guest VMs. See:
    iSCSI Target in Failover
    http://technet.microsoft.com/en-us/library/gg232632(v=ws.10).aspx
    iSCSI Target Failover Step-by-Step
    http://techontip.wordpress.com/2011/05/03/microsoft-iscsi-target-cluster-building-walkthrough/
    3) Use third-party software providing clustered storage (active-active) out-of-box. 
    I would strongly recommend to upgrade to R2 and use shared VHDX.
    StarWind VSAN [Virtual SAN] clusters Hyper-V without SAS, Fibre Channel, SMB 3.0 or iSCSI, uses Ethernet to mirror internally mounted SATA disks between hosts.

  • Two node installation with 2 concurrent managers..

    Need your help. I have 12.1.1 Two node installation on Linux 5.9 with 64 bit.
    Linux2- Database server + Concurrent manager
    Linux1- Apps Node
    Port - 8002 (port pool -2)
    on my app node - linux1, I have 2 directories <SID>_linux1 and <SID>_linux2. First one is for primary apps node and second one is for 2nd concurrent manager. It is a shared directory structure. I have 2 questions:
    1) If I run the autoconfig on Linux1, I can run all the services and connect to apache. However, If I run the autconfig on linux2, I will not be able to connect to web server (for a short time request will be sent to Linux1 and then it gets forwarded to Linux2 - even though Linux2 is not app server).
    2) How do I run the second concurrent manager on LInux2? After I run the 2 concurrent manager, how do I test both concurrent managers are working?
    Your help is much appreciated.

    Hi Hussein,
    Thank you for the info. I was wondering whether the Linux2 concurrent manager was installed correctly or not. I went to xml file and found these entries and it made me think, it didn't install correctly because only concurrent manager should have been yes and the rest should be no. Isn't it? If it is wrong, how do I correct this?
    <oa_system_config>
             <TIER_DB oa_var="s_isDB">NO</TIER_DB>
             <TIER_ADMIN oa_var="s_isAdmin">YES</TIER_ADMIN>
             <TIER_WEB oa_var="s_isWeb">YES</TIER_WEB>
             <TIER_FORMS oa_var="s_isForms">YES</TIER_FORMS>
             <TIER_NODE oa_var="s_isConc">YES</TIER_NODE>
             <TIER_FORMSDEV oa_var="s_isFormsDev">YES</TIER_FORMSDEV>
             <TIER_NODEDEV oa_var="s_isConcDev">YES</TIER_NODEDEV>
             <TIER_WEBDEV oa_var="s_isWebDev">YES</TIER_WEBDEV>
             <config_option type="techstack" oa_var="s_techstack">as1013</config_option>
             <config_option type="techstack" oa_var="s_tnsmode">generateTNS</config_option>
             <config_option type="adx" oa_var="s_apps_version">12.1.1</config_option>
             <config_option type="techstack" oa_var="s_apache_mode">NORMAL</config_option>
             <ias_version oa_var="s_ias_version">10.1.3.4.0</ias_version>
          </oa_system_config>

  • Xmlns attribute appearing in top level node

    I have an xml message that is parsed and its DOM tree built. Then a portion of the message, identified by an xpath, is extracted which is stored as XMLNode, which is later printed to a stream.
    Using the latest Oracle XML library ( comes with Oracle 10 ), the top level element in the node is always appended with extra 'xmlns' attribute.
    This is an example. The original message does not have
    this extra xmlns attribute.
    <RESPONSE xmlns="http://www.nlis-hub.co.uk/NS/2001-01-10">
    <PROPERTY_1>description 1</PROPERTY_1>
    <PROPERTY_2>description 2</PROPERTY_2>
    <PROPERTY_3>description 3</PROPERTY_3>
    </RESPONSE>
    How can we turn this behaviour off ?
    Thanks,
    Dwi

    THanks for replying.
    Yes, the XML document has the namespace specified:
    <ROOT_MESSAGE xmlns="http://www.nlis-hub.co.uk/NS/2001-01-10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlis-hub.co.uk/NS/2001-01-10 Schema.xsd">
    <RESPONSE>
    <PROPERTY_1>description 1</PROPERTY_1>
    <PROPERTY_2>description 2</PROPERTY_2>
    <PROPERTY_3>description 3</PROPERTY_3>
    </RESPONSE>
    </ROOT_MESSAGE>
    In our application, we are storing the <RESPONSE>
    block to db as CLOB. We have a requirement to store it
    exactly as it was received. However, the XML parser (or something) is including the xmlns attribute in the top level node of that portion
    <RESPONSE xmlns="http://www.nlis-hub.co.uk/NS/2001-01-10">
    </RESPONSE>
    This is what is done to obtain the node:
    (xpathStr is the xpath to the RESPONSE node )
    NodeList nodeList = xmlDocument_.selectNodes( xpathStr, this );
    int nodeLength = nodeList.getLength();
    StringWriter xmlStringWriter = new StringWriter();
    PrintWriter xmlPrintWriter = new PrintWriter( xmlStringWriter );
    for( int nodeIndex = 0; nodeIndex < nodeLength; ++nodeIndex )
    XMLNode node = (XMLNode)nodeList.item( nodeIndex );
    node.print( xmlPrintWriter );
    StringBuffer xmlStringBuffer = xmlStringWriter.getBuffer();
    By the time it gets to the output stream, it already has the xmlns attribute appended to the top level node.
    How can we prevent this ?
    Thanks,
    Dwi

Maybe you are looking for