XML Gurus: help with cloning a node without using clone!

Dear all,
I have to copy one piece of XML from one part of the document to another. Unfortunately I cannot simply do a copy and paste:
Node nodeLeaf = nodeChild.cloneNode(true);
nodeAncestor.appendChild(nodeLeaf);
because some fragments of the nodeLeaf mustn't be copied (depending on the node value)
So I cannot make a deep clone of the leaf.
I have to make a clone of nodeLeaf by myself. (Copying its child with a recursive function)
I have built a recursive function but I cannot understand why it doesn't work correclty (text values are skipped and also some pieces of the xml aren't copied correclty)
// Passing the full leaf and a leaf with only the first tag, under which I clone manually the nodes.
Node copyNode = appendNodes(nodeLeaf, nodeLeaf.cloneNode(false));
private Node appendNodes(Node node, Node copyNode) {
NodeList kids = node.getChildNodes();
int length = kids.getLength();
if (kids != null) {
for (int ii = 0; ii < length; ii++) {
Node nodeKid = kids.item(ii);
copyNode.appendChild(nodeKid.cloneNode(false));
appendNodes(nodeKid,nodeKid);
return copyNode;
Anybody can give me a help ?
thanks a lot
Francesco

Here are a couple of suggestions:
1) General stuff.
NodeList kids = node.getChildNodes(); will always generate a NodeList. It may have no entries, but there is no need to check for if (kids != null). Your for loop will do nothing if the length is zero.
2) You need to change your code as follows:
for (int ii = 0; ii < length; ii++)
   Node nodeKid = kids.item(ii);
   Node newOutputNode = nodeKid.cloneNode(false);
   copyNode.appendChild(newOutputNode);
   appendNodes(nodeKid,newOutputNode);
}Dave Patterson

Similar Messages

  • 11i load balancing web nodes without use of Hardware http load balancer

    I am looking at note 217368.1 (Advanced Configurations and Topologies for Enterprise Deployments of E-Business Suite 11i) and some other notes on load balancing but some aspects are not clear.
    Aim is to implement load balancing traffic to web nodes without using Hardware ( BigIP, cisco etc) for HTTP layer load balancing.
    Which is more preferable between dns or Apache Jserv load balancer ?
    Need details like failover capabilities, death detection of node, functionality testing and ways to monitor Apache Jserv load balancer.
    Any help in this regard is welcome .
    thx
    arun

    Oracle recommends using loadbalancing hardware rather than using DNS. If you want the features you mention above, you will need a hardware loadbalancer.
    http://blogs.oracle.com/stevenChan/2006/06/indepth_loadbalancing_ebusines.html
    http://blogs.oracle.com/stevenChan/2009/01/using_cisco_ace_series_hardware_load-balancers_ebs12.html
    HTH
    Srini

  • How do I activate the microphone button in imessage with the iphone 5 without using Siri?

    How do I activate the microphone button in imessage with the iphone 5 without using Siri?

    You don't. You have to activate Siri.

  • Multi-mapping with message bundling but without using BPM

    Hi all,
    I have a requirement to bunch specific no. of records (say 50) from source message and create separate target messages for those bunches. For example, if the source message has 120 records, then there should be three separate target messages created containing 50, 50 and 20 records each.
    I am wondering whether this multi-mapping is possible without using BPM, as the typical no. of records in the source message are in the range of 600 to 800, and rarely (twice or thrice a month) they shoot up to 2000. So my concern is whether BPM would affect the performance. We are using PI at SP12.
    Regards,
    - Shankar.

    Sorry for late reply.. Well the sender is a file system, which sends a single XML file containing multiple records. (I mean I have a sender file adapter that polls periodically from a specific path and picks up the file when it is available)
    The no. of records in the source file may be different in each run. The requirement on the receiver system is that it can handle a file which has maximum of 'n' records only (say 50 in my example)
    Now the sender file can contain any no. of records. It may contain 10 on some day, or 200 the next day, or 120 on the third day. But on the receiver side, I want the files to be created such that each will contain AT MAX 50 records.
    So, if source file has <=50 records, then there will be only 1 target file having the same no. of records.
    If source file has between 51 to 100 records, then there will be two target files. One will have 50 records, and the second will have remaining records.
    And so on..
    Regards,
    - Shankar.

  • How to Implement SSL with Oracle Applications R12 without using Load Balanc

    How to Implement SSL with Oracle Applications R12.1.3 without using Load Balancer

    Please refer to (Enabling SSL in Release 12 [ID 376700.1]).
    Thanks,
    Hussein

  • How to detect the key enter with a numerical control without using loop event?

    I want to accept a numerical value only when the key enter is pressed, but without using the event. How to detect the char "enter" with a numerical control?
    Thanks!

    When the user edits a numeric control with a keyboard, its property "key focus" is true. When the user hits enter, key focus becomes false. Poll the property to latch the control valuse at the true-false transition. That won't work if the user modify the control using up and down arrows.
    LabVIEW, C'est LabVIEW

  • HT1462 can I take a picture of myself with the iMac camera without using iChat?

    is it possible to take a picture of myself with my iMac's camera without using iChat?

    What msn579 said...
    Or, for your computer account picture: http://docs.info.apple.com/article.html?path=Mac/10.7/en/mtusr002.html
    Message was edited by: EZ Jim
    Mac OSX 10.7.3

  • Help in making this GUI without using IDE (snapshot attached)

    [Layout image| [https://rapidshare.com/files/2954811682/layout.JPG]]
    hi, i am new java swing library and i want to create a layout just like a image posted above without using IDE.
    i need some idea/help regarding two issues which i m facing at the moment one how to set the size of the button and how im suppose to set the alignment of labels,textboxes and buttons according to the image here is the source code below :
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JComboBox;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.border.TitledBorder;
    public class Form extends JFrame {
    private JLabel lblUserName;
    private JLabel lblNewPassword;
    private JTextField txtUserName;
    private JPasswordField txtNewPassword;
    private JButton btnLogin;
    private JButton btnClear;
    private JPanel mainPanel;
    private JPanel centerPanel;
    public Form() {
    // initialize the components
    initComponents();
         // add the components
    addComponents();
         // add the listeners
    //addListeners();
    // display components
    displayComponents();
    private void initComponents() {
    getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
    mainPanel = new JPanel(new BorderLayout());
    centerPanel = new JPanel(new GridLayout(3, 4, 20, 5));
    lblUserName = new JLabel("Username : ");
    lblNewPassword = new JLabel("password : ");
    txtUserName = new JTextField(15);
    txtNewPassword = new JPasswordField(15);
    btnLogin = new JButton("Login");
    btnLogin.setPreferredSize(new Dimension(2,2));
    btnClear = new JButton("Clear");
    btnClear.setPreferredSize(new Dimension(2,2));
    private void addComponents() {
    centerPanel.add(lblUserName);
    centerPanel.add(txtUserName);
    centerPanel.add(new JLabel(""));
    centerPanel.add(lblNewPassword);
    centerPanel.add(txtNewPassword);
    centerPanel.add(new JLabel(""));
    centerPanel.add(new JLabel(""));
    centerPanel.add(btnLogin);
    centerPanel.add(btnClear);
    Font titleFont = new Font("San Serif",Font.PLAIN,12);
    Color titleColor = Color.blue;
    mainPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Admin Login",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,titleFont,titleColor));
    mainPanel.add(centerPanel, BorderLayout.CENTER);
    getContentPane().add(mainPanel);
    private void displayComponents() {
    setTitle("Form");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(600, 200);
    setVisible(true);
    public void actionPerformed_BtnUpdate(ActionEvent e) {
    JOptionPane.showMessageDialog(this, "Your profile has been updated successfully.");
    public void actionPerformed_BtnBrowse(ActionEvent e) {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.showOpenDialog(this);
    public static void main(String[] args) {
    try {
    Form myForm = new Form();
         catch (Exception exception) {
    System.err.println("ERROR - " + exception.getMessage());
    Edited by: 932179 on May 4, 2012 1:30 PM
    Edited by: 932179 on May 4, 2012 1:30 PM

    Welcome to the forum.
    Take the list of +"All Known Implementing Classes"+ from here http://docs.oracle.com/javase/7/docs/api/java/awt/LayoutManager.html and find out what combination best fits your needs.
    I usually have some nested BorderLayouts and GridLayouts.
    When I need lables and input fields aligned I use GroupLayout (which I personally prefer over GridBagLayout...).
    Anyway, you may have got better answers if you postet this in the right place:
    Swing
    bye
    TPD

  • Powershell send mail with custom voting option without using outlook object?

    Hi,
    I am currently sending emails through using new-object Net.Mail.SMTPclient because the server that runs the script does not have outlook application.
    My goal right now is to be able to send automated emails that have custom voting option on it where people who receive it in outlook can respond through the voting system.
    Is it possible to do this without using new-object -com outlook.application?

    Hi,
    I am currently sending emails through using new-object Net.Mail.SMTPclient because the server that runs the script does not have outlook application.
    My goal right now is to be able to send automated emails that have custom voting option on it where people who receive it in outlook can respond through the voting system.
    Is it possible to do this without using new-object -com outlook.applicatio

  • Help required to create portal without using any vendor specific API's

    Hi All,
    I am trying to develope a portal without using any vendor specific API or tool like Weblogic workshop or Vignette Wizard. I would like to know whether Sun Microsystem provides any API for developing portal. I would also appreciate if I can get few links for developing portal using java API's...
    Thanks in advance...
    Dgk

    Sure Sun provides the tools: it is called the compiler. Now all you need to do is write the code for a portal. But since there are vendor specific solutions available that could make your life a lot easier, writing one yourself is like reinventing the wheel.
    Pardon my mild sarcasm, but avoiding API's not developed by Sun is not the general idea behind the Java platform. You are encouraged to use those API's.

  • Error in my build.xml file (help with spotting syntax error requested)

    Hi
    I have written an XML file called build.xml for one of my applications. My XML editor complains that there is an error at the last line of the XML file, but I simply find it unable to correct the errror.
    It says:
    Fatal error:Build.xml[76:3-9]: End-Tag without start-tag
    The XML file itself:
    <project basedir="." default="deploy" name="concepts">
    <property name="src.dir" value="src"></property>
    <property name="build.dir" value="${basedir}/build"></property>
    <property name="build.lib" value="${build.dir}/lib"></property>
    <property name="dist.dir" value="dist"></property>
    <property name="classes.dir" value="${build.dir}/classes"></property>
    <property name="build.etc" value="${src.dir}/etc"></property>
    <property name="build.resources" value="${src.dir}/resources"></property>
    <property name="lib.dir" value="lib"></property>
    <property name="web-inf.dir" value="WEB-INF"></property>
    <property name="war.name" value="concepts"></property>
    <property file="../common.properties"></property>
    <target name="init">
    <mkdir dir="${build.dir}"></mkdir>
    <mkdir dir="${classes.dir}"></mkdir>
    <mkdir dir="${dist.dir}"></mkdir>
    </target>
    <target name="deploy" depends="clover-yes, clover-no">
    <javac srcdir="${src.dir}" destdir="${classes.dir}" classpath="${libs}" debug="off" optimize="on" deprecation="on" compiler="${compiler}">
    <include name="org/apache/commons/fileupload/**/*.java" />
    <include name="com/portalbook/portlets/**/*.java" />
    <include name="com/portalbook/portlets/content/**/*.java" />
    </javac>
    <target depends="init" name="compile">
    <javac debug="true" deprecation="true" destdir="${classes.dir}" optimize="false">
    <src>
    <pathelement location="${src.dir}"></pathelement>
    </src>
    <classpath>
    <fileset dir="${lib.dir}">
    <include name="*.jar">
    </include>
    </fileset>
    </classpath>
    </javac>
    </target>
    <target depends="compile" name="war">
    <war destfile="${dist.dir}/${war.name}.war" webxml="WEB-INF/web.xml">
    <classes dir="${classes.dir}"></classes>
    <lib dir="${lib.dir}"></lib>
    <webinf dir="${web-inf.dir}"></webinf>
    </war>
    </target>
    <!-- create the portal-concepts-lib.jar -->
    <jar jarfile="${build.lib}/concepts-lib.jar">
    <fileset dir="${classes.dir}"></fileset>
    </jar>
    <jar jarfile="${build.lib}/concepts.war" manifest="${build.etc}/concepts-war.mf">
    <fileset dir="${build.resources}/concepts-war"></fileset>
    </jar>
    <!-- concepts.ear -->
    <copy todir="${build.resources}/concepts-ear">
    <fileset dir="${build.lib}" includes="concepts.war,concepts-lib.jar"></fileset>
    </copy>
    <jar jarfile="${build.lib}/concepts.ear">
    <fileset dir="${build.resources}/concepts-ear" includes="concepts.war,concepts-lib.jar">
    </fileset>
    </jar>
    <target depends="deploy" name="explode">
    <taskdef classname="org.jboss.nukes.common.ant.Explode" classpath="${libs}" name="explode"></taskdef>
    <explode file="${build.lib}/concepts.ear" name="concepts.ear" todir="${build.lib}/exploded"></explode>
    </target>
    <target depends="war" name="all"></target>
    <target name="clean">
    <delete dir="${build.dir}">
    </delete>
    <delete dir="${dist.dir}">
    </delete>
    </target>
    </project>
    I am a little inexperienced in XML files. So I am unable to spot the error.
    I would greatly appreciate it, if some kind soul were to help me out.
    thanks a lot

    The tag
    <target name="deploy" depends="clover-yes, clover-no">...is never closed.
    close that tag:
    <target name="deploy" depends="clover-yes, clover-no">
         <javac srcdir="${src.dir}" destdir="${classes.dir}" classpath="${libs}" debug="off" optimize="on" deprecation="on" compiler="${compiler}">
              <include name="org/apache/commons/fileupload/**/*.java" />
              <include name="com/portalbook/portlets/**/*.java" />
              <include name="com/portalbook/portlets/content/**/*.java" />
         </javac>
    </target>Second error is that the depends in there (clover-yes, clover-no) are not existing as targets in your xml.

  • Help with getting a node xpath from within the rules engine

    I'm new here and to BizTalk.  In the rule composer I've setup my vocabularies and have started implementing rules. 
    When a rule is evaluated to false I have a custom function called AddValidationError which is attached to the Action section.  This method accepts three parameters, a TTypedXmlDocument containing
    the validation errors node, an xpath to the node that was validated and an error code.  AddValidationErrors will append a new ValidationError node to the validation errors node containing the error code, error message, severity, and the xpath of the node
    that was validated.
    The issue is that I can't figure out how to get the xpath to the node being validated so that I can pass it to the AddValidationError function.  I have tried defining the xpath parameter as
    a TTypedXmlDocument which allows me to pass nodes of type TTypedXmlDocument, from there i can working the xpath but this doesn't allow me to pass nodes of other types, such as String, Int, DateTime, etc.
    Basically I want to be able to add the xpath to the node being validated into the validation errors.  I noticed that the Predicate function Exists cal accepts any node from which it resolves
    the xpath however I can't figure out how it does this.
    Anyway I was hoping that someone could point me in the right direction.  How can I pass a node of any type to a function, or get the xpath to node being validated which I can then simply pass
    as a string.
    Note that I am aware that I can simply type the xpath or copy it from the node properties window but the rule will be managed by people who are not developers, e.g. BA's or system administrators.
     I don't really want to expect them to write an xpath query or piece one together from the node properties.  I also thought that I could add two definition's for each node, one of the value type (String, decimal, DateTime) and another of type TTypedXmlDocument
    and pass the TTypedXmlDocument one to the AddValidationError method, which works but its not really ideal. 

    Can you post the exact issue and what you really need ?
    Do you want to create a Vocabulary or Rule with the predicate functions?
    Regards, Aboorva Raja R Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • XML Invoice - help with Tax Summary

    I've been tasked to modify an already modded XML Invoice using XMLP. I need to add a Tax Summary block at the bottom, showing the breakout of the tax codes and amounts charged on the invoice.
    I've played around with it, but so far I can only get the first tax line to show up. I can't get the others. I need to insert a conditional, but I don't know how or where.
    Has anyone run into anything like this before?
    This probably isn't the best problem summary... but if you could help I'd appreciate it!

    Hi,
    It sounds like you need to use a for-each to show each of your tax lines. If you do not have the for-each XMLP will only show the first tax line that is hits in the XML Output.
    Would suggest that you take a quick look at the XMLP User Guide documentation for more information on how to use for-each.
    Let me know if this does not solve your problem, or if you are still struggling.
    Regards,
    Cj

  • Hi, is there a way to sync my iPod classic with my iPod touch without using a pc? I have also have an iPad2 if that can help??

    HI, I have an iPod touch with all my songs on it and also have a 5th gen classic which is connected to my car. My laptop died on me a while back and I replaced it with an iPad 2.  I now am unsure how I can keep updating my classic seeing as I no longer have a pc with iTunes on it?
    IS there a way I can continue purchasing music via my iPod touch/iPad and then sync them with my iPod classic for he car?  I don't really want to have to buy a new laptop just for iTunes!
    I have seen iTunes match being talked about and am wondering if this could be a solution, but again not sure how I will get new purchases on I the classic as its not wireless etc?!
    THanks in advance for any help.

    No.  You can sync content directly from an iPod to another iPod or iPad.  The content you wish to transfer needs to be in your iTunes library first.
    B-rock

  • Help with cloning an element

    I've included a screenshot.
    http://imgur.com/SpZsCbB
    Basically, what I'm trying to do is "rebuild" the house in the picture so that the garage is eliminated from the shot (covered in stucco like the rest of the house). I'm having issues doing this, and I'm sure there's several ways to go about it (as there usually are).
    Any help from the community is appreciated; thanks in advance!
    Tim

    Thans for the response; the camera does not move; the whole shot is static. I thought about simply using Photoshop, but I assume (dangerous word, I know) that it would look "weird", since I'd be meshing a still image with a moving, grainy one.

Maybe you are looking for

  • ZenXtra: copying from Zen: "file unaccesib

    Hi, When copying from my Zen Xtra, after transfer of a couple of files in queue I receive an error: "file unaccessible..." and I cannot copy anything more unless I reconnect. Moreover Zen and the connection seems to be out of order (ie. not all field

  • Firefox will not open web pages that are called from the mail program that comes with Vista, anyone out there have a solution?

    I have installed Firefox ver 4 on a Toshiba laptop running Vista. My problem is when using the mail client that comes with Vista any url in an email message will not load in the browser, a new tab is created and has the url from the mail message but

  • How do I transfer an existing Aperture library to a new external hard drive

    I have a new external hard drive where I want to store my pictures to free up room on my iMac How do I take an existing Aperture library and move it to the external hard drive so that Aperature can find and use it?  Once it is moved can I delete the

  • My Bill is not prorated

    A month and a half ago, I decided that I did not want to be a customer of Verizon anymore. I decided to port my number to AT&T, since it was in the middle of the month I wanted to make sure that I would not be charged for the rest of the month. Since

  • Ipod no longer beeps on push alearts?

    Hi all, when ever i receive a new message or any push notification, i can only here it through speakers/head phones. It used to beep whenever i got one, it still beeps for an alarm or timer. 1st gen 8gb with iphone OS 3.1.1