Append xml node into a list

Hi,
In an embedded sub process with looping logic, we have a db adapter call.
We are trying to insert the single response object from each of the db adapter call into a list.
Problem we are facing is the list is not able to append the new db response into the list.
AppendToList is not of help. XSLT construct copy-to was not of help.
Using the following three messages
Msg1: - Loop Interation 1
<elementCollection>
<element>aaa</element>
</elementCollection>
Msg2: - Loop Interation 2
<elementCollection>
<element>bbb</element>
</elementCollection>
Msg3: - Loop Interation 3
<elementCollection>
<element>ccc</element>
</elementCollection>
to be inserted into the following message
Result: - After all the iterations
<elementCollection>
<element>aaa</element>
<element>bbb</element>
<element>ccc</element>
</elementCollection>
Any help/pointers will be appreciated.
Edited by: 905033 on Jul 4, 2012 10:32 PM
provided sample messages
Edited by: 905033 on Oct 23, 2012 2:55 AM

Please see the transformation bellow... I've built a quick sample and it worked for me.
Cheers,
Vlad
It is considered good etiquette to reward answerers with points (as "helpful" - 5 pts - or "correct" - 10pts).
https://forums.oracle.com/forums/ann.jspa?annID=893
<xsl:stylesheet version="1.0"
  <xsl:param name="Variable_2"/>
  <xsl:param name="Variable_3"/>
  <xsl:template match="/">
    <ns0:elementCollection>
      <xsl:for-each select="ns0:elementCollection/ns0:element">
        <ns0:element>
          <xsl:value-of select="."/>
        </ns0:element>
      </xsl:for-each>
      <xsl:for-each select="$Variable_2/ns0:elementCollection/ns0:element">
        <ns0:element>
          <xsl:value-of select="."/>
        </ns0:element>
      </xsl:for-each>
      <xsl:for-each select="$Variable_3/ns0:elementCollection/ns0:element">
        <ns0:element>
          <xsl:value-of select="."/>
        </ns0:element>
      </xsl:for-each>
    </ns0:elementCollection>
  </xsl:template>
</xsl:stylesheet>

Similar Messages

  • Videophone example, XML result into a list?

    In the video phone application, the reg.cgi appears to ouput a list of 'friends' in xml format
    (from regcgi)
    for f in friends:
        print "\t<friend>\n\t\t<user>%s</user>" % (xml.sax.saxutils.escape(f), )
        c = db.cursor()
        c.execute("select m_username, m_identity from registrations where m_username = ? and m_updatetime > datetime('now', '-1 hour')", (f, ))
        for result in c.fetchall():
            eachIdent = result[1]
            if not eachIdent:
                eachIdent = ""
            print "\t\t<identity>%s</identity>" % (xml.sax.saxutils.escape(eachIdent), )
            if f != result[0]:
                print "\t\t<registered>%s</registered>" % (xml.sax.saxutils.escape(result[0]), )
        print "\t</friend>"
    and the flash app appears to get the results as follows
    (from httpmanager)
    else if (result.result.hasOwnProperty("friend"))
                        // party query response
                        remote = result.result.friend as Object;
                        if (remote.hasOwnProperty("user") && remote.hasOwnProperty("identity"))
                            var identityString:String = remote.identity
                            var userString:String = remote.user;
                            var r:IdManagerEvent = new IdManagerEvent("lookupSuccess", userString, identityString);
                            dispatchEvent(r);
    and it places a call to one of the 'friends' as follows
    (from the videophone app file)
    else if (e.type == "lookupSuccess")
                        // party query response
                        var i:IdManagerEvent = e as IdManagerEvent;
                        placeCall(i.user, i.id);   
    My query is, how would I take the full list that was returned as XML, and for example, populate a list with that data?
    How do you iterate through the list, extracting the required values and put them into a list?
    Im new to flash, and trying to get my head around how to do these simple things...
    Can anyone shed any light, as Im learning loads, but keep hitting struggling points like this as I dont have a clue how flash does these things, and dont know what to investigate... Once a pointer in the right direction is given,  a small example like this is shown, I can take it from there, and investigate/learn more.
    t

    Hi ken_from_uk,
    you can convert your xml to an array collection and you can easily iterate using for loop and access the values in the list ...You can see the code below how to convert xml to ArrayCollection...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="convertXMLtoArrayCollection()">
    <mx:Script>
      <![CDATA[
       import mx.collections.ArrayCollection;
       import mx.rpc.xml.SimpleXMLDecoder;
       private var arrayCollection:ArrayCollection = new ArrayCollection();
       private function convertXMLtoArrayCollection():void
        var xml:XML = new XML(xmlStates.toString());
        var xmlDoc:XMLDocument = new XMLDocument(xml);
        var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
        var resultObj:Object = decoder.decodeXML(xmlDoc);
        if(resultObj.states.state is ArrayCollection)
         arrayCollection = resultObj.states.state as ArrayCollection;
        else if(resultObj.states.state is Object)
         arrayCollection.addItem(resultObj.states.state);
      ]]>
    </mx:Script>
    <mx:XML xmlns="" id="xmlStates">
      <states>
          <state>
              <name_state>State x:</name_state>
              <code_state>X</code_state>
              <cities>
                  <city>
                      <name_city>City One</name_city>
                      <population_city>20000</population_city>
                  </city>
                  <city>
                      <name_city>City Two</name_city>
                      <population_city>10000</population_city>
                  </city>
                  <city>
                      <name_city>City Three</name_city>
                      <population_city>80000</population_city>
                  </city>
              </cities>
          </state>
          <state>
              <name_state>State y:</name_state>
              <code_state>X</code_state>
              <cities>
                  <city>
                      <name_city>City Four</name_city>
                      <population_city>50000</population_city>
                  </city>
                  <city>
                      <name_city>City Five</name_city>
                      <population_city>40000</population_city>
                  </city>
                  <city>
                      <name_city>City Six</name_city>
                      <population_city>70000</population_city>
                  </city>
              </cities>
          </state>
      </states>
    </mx:XML>
    </mx:Application>
    Thanks,
    Bhasker Chari

  • XML nodes into multiple views.

    Hello everybody.
    First of all i want to say that i'm a beginner in Flex Mobile.
    I want to make an application that can read an XML file and change views through XML nodes.
    Here is an example of how it should look after reading an XML file.
    Here is the XML example. I want to read all of the nodes but only show a few of them.
    <?xml version="1.0" encoding="utf-8"?>
    <items>
         <item>
              <title>Item 1</title>
              <image>url</image>
              <description>Lorem ipsum</description>
              <subitems>
                   <subitem_title>Item 1.1</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 1.2</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 1.3</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 1.4</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 1.5</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
         </item>
         <item>
              <title>Item 2</title>
              <image>url</image>
              <description>Lorem ipsum</description>
              <subitems>
                   <subitem_title>Item 2.1</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 2.2</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 2.3</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 2.4</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 2.5</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
         </item>
         <item>
              <title>Item 3</title>
              <image>url</image>
              <description>Lorem ipsum</description>
              <subitems>
                   <subitem_title>Item 3.1</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 3.2</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 3.3</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 3.4</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 3.5</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
         </item>
         <item>
              <title>Item 4</title>
              <image>url</image>
              <description>Lorem ipsum</description>
              <subitems>
                   <subitem_title>Item 4.1</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 4.2</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 4.3</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 4.4</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
              <subitems>
                   <subitem_title>Item 4.5</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
                   <subitem_image>url</subitem_image>
              </subitems>
         </item>
    </items>
    All i could find about reading XML in a list and adding a change handler was only for 2 views, i need for 3 views and show subitems for each item. Showing subitems for each item from an XML file was very tricky and didn't worked for me.
    I could use some little help or advice!

    Follow this tutorial to learn how to get data from XML files remotelly!
         http://www.youtube.com/watch?v=Cksp7IyVNk4
    Use the XML from first post on this topic, but, at every <item></item> add an <id> field like this (make sure every item has an unique id):
    <items>
         <item>
              <id>0</id>
              <title>Item 1</title>
              <image>url</image>
              <description>Lorem ipsum</description>
              <subitems>
                   <subitem_title>Item 1.1</subitem_name>
                   <subitem_description>Lorem ipsum</subitem_description>
    Then, create 3 views (New->MXML Component)!
    List.mxml - SubList.mxml - Details.xml
    After you create them go to List.mxml create a list and import you're XML (follow tutorial before, to know how to do this).
    After you import you're XML file and show it in that list, you have to create a change handler for that list (when an item is selected we whant to change view).
    And, of course, follow Duane's tutorial to know how to do that. You will want to change view to SubList.mxml. In this view you'll have a list of childs for primary node (item node).
    Then,go to SubList.xml and create a list.
    Then, the tricky part here is that you need to drag/drop same getData():XML_data() that u used in first list. A popup window will show. Here u have to let "New service call" checked and at "Data provider" u have to select de subitem node of the XML file. And, of course, u'll have to select you're Label field.
    When u done this, go to code viewer and find the <s:AsyncListView.... code line.
    u'll have to add an .[id]. there like this:
    <s:AsyncListView list="{getDataResult2.lastResult[id].subitem}"/>
    In this way, you're list will show only entries from XML file with ITEM ID = ?!
    Then follow Duane's tutorial again.
    PS: in views u'll have to add some [Bindable] vars and a function for that view to recognize the id.
    Here's a model!
    <fx:Script>
            <![CDATA[
                        import valueObjects.XML_FIELD_type;
                        [Bindable] var id:String;
                        private function init():void
                    var thisID:XML_FIELD_type = data as XML_FIELD_type
                    id = thisID.id;
              ]]>
        </fx:Script>
    After u did this u'll have to add a viewActivate to <s:View> declaration like this:
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:XML_FILE_OR_FIELD="services.XML_FILE_OR_FIELD.*"
            title="Title"
            viewActivate="init()"
            cachePolicy="on"
            destructionPolicy="never">
    XML_FILE_OR_FIELD is generated automatically.
    All of these things u'll find on Duane's tutorial except the 3 view part and parsing that data. Follow it and u will solve you're problem!
    Hope it helped!
    Cheers,
    Daniel

  • Appending XML node in bpel.

    Hi,
    I have a transform activity that creates a XML as below:
    <Students>
    <Student>
    <Name>A</Name>
    <Age>123</Age>
    </Student>
    </Students>
    After that i need to use an assign activity to append another student node with output as below:
    <Students>
    <Student>
    <Name>A</Name>
    <Age>123</Age>
    </Student>
    <Student> <!-- This is the appended node -->
    <Name>C</Name>
    <Age>452</Age>
    </Student>
    </Students>
    let me know how to achieve this using bpel assign activity.
    Thanks.

    It's something like this...
    Variable_1
    <list>
         <data>aa</data>
         <data>bb</data>
    </list>Variable_2
    <list>
         <data>1</data>
         <data>2</data>
    </list>Then you put an append in your ASSIGN activity
    <bpelx:append>
         <bpelx:from variable="Variable_2" query="/list/*"/>
         <bpelx:to variable="Variable_1" query="/list"/>
    </bpelx:append>And you get this as result...
    <list>
    <data>aa</data>
    <data>bb</data>
    <data>1</data>
    <data>2</data>
    </list>Cheers,
    Vlad

  • XML data into Combo & List

    Hi
    I am too new to this and still tring to learn. Well here is what I am into. I am trying to make a simple product catalog, using native components
         a combobox to display DISTINCT health issues
         a listbox to display the products associated to the selected health issue item in ComboBox
         a textarea to display complete information about the selected product in listbox
    Data comes from single external xml file.
    I was able to start off with Combo, but I don't know how to display DISTINCT ITEMS IN IT? Now it display all items including duplicates. Then I added eventlistener to Combo, which on change, the data for selected item is displyed in Textarea, but i don't know how to hook this to List component.
    All files available here:
    https://docs.google.com/folder/d/0ByHOlDbL5njbX1FFd1UtTFNzMTg/edit
    Sure some of you can do it so easy. Appreciate your time and help.
    Thank you
    Kristtee

    Filter the XML before using it to create your dataProvider http://joshblog.net/2007/05/17/filter-xml-data-with-e4x-in-flash-part-2/

  • Load XML file into either List MyType or ObservableCollection MyType

    I have been searching and trying different suggestions for three days now, full time.  I am building a universal app for Windows 8.1 and Windows Phone 8.1.  The problem, apparently, is that doing this is different between Windows 7.1, Windows
    Phone 7.1, Windows 8, Windows 8.1, Windows Phone 8.1, and Windows 8.1 universal apps.  You find hundreds of different ways of doing this, none of which work.
    My XML file is of the form:
    <?xml version="1.0" encoding="utf-16"?>
    <ArrayOfPrize xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Prize>
        <PrizeName>Dog</PrizeName>
        <PrizePath>http://www.dog.com</PrizePath>
        <PrizeOwner>System</PrizeOwner>
        <PrizeChecked>false</PrizeChecked>
        <Won>false</Won>
      </Prize>
    </ArrayOfPrize>
    I get errors like you can't do this with non-public types to header is missing, or I get a deaklock.  Every suggestion I have tried has led to either the same error message as the last one, or the same as some previous error message.  Microsoft
    conveniently left out this common case in their Universal App samples.  Please don't refer me to other articles, because if they were on the internet I have probably already tried them.  Sorry, my frustration is showing through.  Feel free to
    refer me to other articles.
    Below is my latest attempt that does not work:
    public async Task<T> ReadObjectFromXmlLocalFile(string filename)
     try
      T objectFromXml = default(T);
      XmlSerializer serializer = new XmlSerializer(typeof(T));
      Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
      StorageFile file = await localFolder.GetFileAsync(filename);
      string xmlText = await FileIO.ReadTextAsync(file);
      StringReader reader = new StringReader(xmlText);
      objectFromXml = (T)serializer.Deserialize(reader);
      return objectFromXml;
     catch (Exception e)
      ErrorBucket.AddError(e.Message);
      return default(T);
    Incidentally, every folder path leads to either C:\Data\SharedData... or C:\Data\Users..., which is very strange, since my project is not even on the C drive.  I have recreated the directory structure that it is looking for and put my files there, but
    eventually this is going to be an issue.  The program used to look in the correct place and then it stopped and starting looking in C:\Data, and I have no idea why.
    Larry Maturo

    Try code below.  I always like to write XML from the code before reading.  It is easier to debug the class formats when writing than reading.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Xml;
    using System.Xml.Serialization;
    using System.Xml.Schema;
    using System.IO;
    namespace XMLSerialize
    class Program
    const string FILENAME = @"c:\temp\test.xml";
    static void Main(string[] args)
    ArrayOfPrize arrayOfPrize = new ArrayOfPrize(){
    prizes = new List<Prize>(){
    new Prize(){
    prizeName = "Dog",
    prizePath = "http://www.dog.com",
    prizeOwner = "System",
    prizeChecked = false,
    won = false
    XmlSerializer serializer = new XmlSerializer(typeof(ArrayOfPrize));
    StreamWriter writer = new StreamWriter(FILENAME);
    serializer.Serialize(writer, arrayOfPrize);
    writer.Flush();
    writer.Close();
    writer.Dispose();
    XmlSerializer xs = new XmlSerializer(typeof(ArrayOfPrize));
    XmlTextReader reader = new XmlTextReader(FILENAME);
    ArrayOfPrize newArrayOfPrize = (ArrayOfPrize)xs.Deserialize(reader);
    [Serializable, XmlRoot("ArrayOfPrize")]
    public class ArrayOfPrize
    [XmlElement("Prize")]
    public List<Prize> prizes;
    [Serializable, XmlRoot(ElementName = "Prize")]
    public class Prize
    [XmlElement("PrizeName")]
    public string prizeName { get; set; }
    [XmlElement("PrizePath")]
    public string prizePath { get; set; }
    [XmlElement("PrizeOwner")]
    public string prizeOwner { get; set; }
    [XmlElement("PrizeChecked")]
    public Boolean prizeChecked { get; set; }
    [XmlElement("Won")]
    public Boolean won { get; set; }
    jdweng

  • Appending XML Node to XMLTYPE Variable

    Hi All,
    My Database Details,
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE 9.2.0.1.0 Production
    TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production
    SQL> var mycnt number
    SQL> exec :mycnt := 2
    SQL> declare
    xml xmltype := xmltype('
    <EMP>
    <NAME>
    </NAME>
    <SALARY>
    <DATE></DATE>
    <AMOUNT></AMOUNT>
    </SALARY>
    </EMP>');
    l_sal long := '<SALARY><DATE></DATE><AMOUNT></AMOUNT></SALARY>';
    l_str long;
    begin for i in 1 .. :mycnt
    loop
    l_str := l_str || l_sal;
    end loop;
    xml := xmltype(replace (xml.getstringval(), '</EMP>', l_str || '</EMP>'));
    dbms_output.put_line (xml.extract('.').getstringval());
    end;
    <EMP>
    <NAME/>
    <SALARY>
    <DATE/>
    <AMOUNT/>
    </SALARY>
    <SALARY>
    <DATE/>
    <AMOUNT/>
    </SALARY>
    <SALARY>
    <DATE/>
    <AMOUNT/>
    </SALARY>
    </EMP>
    This program is working fine. Consider the following scenario...
    My XML is like this,
    <ABC>
    <AB> -- First element
    <CCC></CCC>
    </AB>
    <AB> -- Second element
    <CCC></CCC>
    </AB>
    </ABC>
    Now i want to replicate the tag of <CCC></CCC>
    to 'N' TIMES from XPATH = /A/AB[1]/CCC and /A/AB[2]/CCC
    For example if N=3 then, the XML should be,
    <ABC>
    <AB>
    <CCC></CCC>
    <CCC></CCC>
    <CCC></CCC>
    </AB>
    <AB>
    <CCC></CCC>
    <CCC></CCC>
    <CCC></CCC>
    </AB>
    </ABC>
    Please provide me some Sample PLSQL code for this,
    Thanks in Advance,
    Simbhu

    not sure that this is waht you want - but maybe you find smth useful:
    SQL> set serveroutput on;
    SQL>
    SQL> declare str xmltype:=xmltype('<ABC><AB><CCC></CCC></AB><AB><CCC></CCC></AB><AB><CCC></CCC></AB></ABC>');
      2  begin
      3  for i in 1..2
      4  loop
      5  select InsertChildXML(str, '/ABC/AB['||i||']', 'CCC', XMLForest('' as "CCC",'' as "CCC")) into str from dual;
      6  end loop;
      7  dbms_output.put_line(str.extract('.').getstringval());
      8  end;
      9  /
    <ABC>
      <AB>
        <CCC/>
        <CCC/>
        <CCC/>
      </AB>
      <AB>
        <CCC/>
        <CCC/>
        <CCC/>
      </AB>
      <AB>
        <CCC/>
      </AB>
    </ABC>
    PL/SQL procedure successfully completed
    SQL>

  • Appending XML Node

    Hi All,
    My Database Details,
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE 9.2.0.1.0 Production
    TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production
    SQL> var mycnt number
    SQL> exec :mycnt := 2
    SQL> declare
    xml xmltype := xmltype('
    <EMP>
    <NAME>
    </NAME>
    <SALARY>
    <DATE></DATE>
    <AMOUNT></AMOUNT>
    </SALARY>
    </EMP>');
    l_sal long := '<SALARY><DATE></DATE><AMOUNT></AMOUNT></SALARY>';
    l_str long;
    begin for i in 1 .. :mycnt
    loop
    l_str := l_str || l_sal;
    end loop;
    xml := xmltype(replace (xml.getstringval(), '</EMP>', l_str || '</EMP>'));
    dbms_output.put_line (xml.extract('.').getstringval());
    end;
    <EMP>
    <NAME/>
    <SALARY>
    <DATE/>
    <AMOUNT/>
    </SALARY>
    <SALARY>
    <DATE/>
    <AMOUNT/>
    </SALARY>
    <SALARY>
    <DATE/>
    <AMOUNT/>
    </SALARY>
    </EMP>
    This program is working fine. Consider the following scenario...
    My XML is like this,
    <ABC>
    <AB> -- First element
    <CCC></CCC>
    </AB>
    <AB> -- Second element
    <CCC></CCC>
    </AB>
    </ABC>
    Now i want to replicate the tag of <CCC></CCC>
    to 'N' TIMES from XPATH = /A/AB[1]/CCC and /A/AB[2]/CCC
    For example if N=3 then, the XML should be,
    <ABC>
    <AB>
    <CCC></CCC>
    <CCC></CCC>
    <CCC></CCC>
    </AB>
    <AB>
    <CCC></CCC>
    <CCC></CCC>
    <CCC></CCC>
    </AB>
    </ABC>
    Please provide me some Sample PLSQL code for this,
    Thanks in Advance,
    Simbhu

    Please read XML DB FAQ. 9.2.0.3.0 is the minimum support release for XDB

  • Mapping an XML structure into one field

    Make use of XSLT mapping (available on SDN...just search with CDATA...i think there is a new feature in PI7.1 (Copy XMl to subtree....something like that).
    Regards,
    Abhishek.

    Hi,
    Chk this:
    /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
    Re: Conversion of source XML structure to single string using PI 7.1
    Thanks
    Amit

  • Convert the IDOC XML file into single string?

    Hello All,
    I have a scenario, where i need to conver the IDOC XML  into single string, to send it to target.
    Please let me know how can we achive this, I dont know java coding.
    Please help me out to write the java code.
    Thanks and Regards,
    Chinna

    Hi Chinna,
    You can do this in two ways -
    1. Java mapping
    https://wiki.sdn.sap.com/wiki/display/XI/JavaMapping-ConverttheInputxmlto+String
    https://wiki.sdn.sap.com/wiki/display/Snippets/JavaMapping-ConverttheInputxmltoString
    2. XSLT mapping
    /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
    Regards,
    Sunil Chandra

  • How to binding incoming xml node list to the tree control as dataProvider

    Recently, I faced into one issue: I want to binding incoming xml node (it's not avaliable at start) list to the tree control as a dataProvider.
    Since the incoming xml node list is not avaliable at beginning but I needs to bind it to the tree, so I create one virtual one in the xml, and prepare to remove it before the tree is shown. (ready for the actual node adding). But It did not work.
    Please see the presudo-code here:
    1.  Model layer(CsModel.as)
    public class CsModel
            [Bindable]
            public var treeXML:XML=<nodes><car label="virtualOne" id="1">
                                   </car></nodes>;
            (Here, I want to build binding relationship on the <car/> node,
             one 'virtual/stub' node is set here with lable="virtualOne".
             But this node will be deleted after IdTree
             control is created completely.)      
            [Bindable]
            public var treeData:XMLList =new XMLListCollection(treeXML.car);
    2. view layer(treePage.mxml)
            private var _model:CsModel = new CsModel();
            private function addNode():void
                    var newNode:XML=<car/>;
                    newNode.@label="newOne";
                    newNode.@id=1;
                    _model.treeXML.appendChild(newNode);
                             private function cleanData():void
                                     delete _model.treeXML.car;
            <mx:VBox height="100%" width="100%">
            <mx:Button label="AddNode" click="addNode()" />
            <mx:Tree id="IdTree"  labelField="@label"
              creationComplete="cleanData()"
              dataProvider="{_model}"/>
        </mx:VBox>
    3. Top view layer (App.Mxml)
    <mx:application>
        <treePage />
    </mx:application>
    For method: cleanData(),It's expected that when the treePage is shown, we first delete the virutalOne to provide one 'clear' tree since we don't want show virtualOne to the user. The virutalOne node just for building the relationship between treeData and treeXML at beginning. But the side effect of this method, I found, is that the relationship between treeXML and treeData was cut off. And this leads to that when I added new node (by click the 'addNode' button) to the xmlXML, the xmlData was not affected at all !
    So Is there any other way to solve this issue or bind the incoming xml node list to the xmlListCollection which will be used as Tree control's dataProvider ?

    If u want to display the name : value then u can do like this
    <xsl:eval>this.selectSingleNode("name").nodeName</xsl:eval> : <xsl:value-of select="name" />

  • Can I append an XML Document into another?

    I have a large xml document which I open into coldfusion (mx
    7), and then a smaller group of files that are opened into thier
    own xml objects. After some customization of xml text values, I
    want to append the smaller xml documents into the larger document
    at specific positions within the document tree.
    I have the code that I thought would do this, using an
    arrayappend function, but what happens is that only the root
    element of the smaller (inserted) xml document is placed into the
    main document.
    Is this possible, or do I need to modify the code so that the
    entire tree of xml data that I am appending is created on the
    fly?

    Personally I do this with XSLT.
    <cfxml variable="doc1">
    <root>
    <member id="10">
    <name>Ian</name>
    <sex>male</sex>
    </member>
    </root>
    </cfxml>
    <cfxml variable="doc2">
    <root>
    <member id="1">
    <name>Joe</name>
    <sex>male</sex>
    </member>
    <member id="2">
    <name>John</name>
    <sex>male</sex>
    </member>
    <member id="3">
    <name>Sue</name>
    <sex>female</sex>
    </member>
    </root>
    </cfxml>
    <cffile action="write" file="#expandPath("/")#\doc2.xml"
    output="#ToString(doc2)#" nameconflict="overwrite">
    <!--- METHOD ONE using a depreciated and undocumented
    method --->
    <cfset newNode = doc1.root.member.cloneNode(true)>
    <cfset doc2.changeNodeOwner(newNode)>
    <cfset doc2.root.appendChild(newNode)>
    <cfdump var="#doc2#" label="Merged by hidden functions"
    expand="no">
    <!--- METHOD TWO using XSLT --->
    <!--- create an xsl docutment--->
    <cfoutput>
    <cfsavecontent variable="transformer">
    <xsl:stylesheet xmlns:xsl="
    http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:output method="xml"/>
    <!--load the merge file -->
    <xsl:variable name="emps"
    select="document('#expandPath("/")#\doc2.xml')"/>
    <!--- this line references and XML file to be combined
    with the main file,
    I wonder if there is a way to use an XML document in memory
    here? --->
    <!-- combine the files -->
    <xsl:template match="/">
    <root>
    <!-- select all the child nodes of the root tag in the
    main file -->
    <xsl:for-each select="root/child::*">
    <!-- copy the member tag -->
    <xsl:copy-of select="."/>
    </xsl:for-each>
    <!-- and all the child nodes of the root tag in the merge
    file -->
    <xsl:for-each select="$emps/root/child::*">
    <!-- copy the member tag -->
    <xsl:copy-of select="."/>
    </xsl:for-each>
    </root>
    </xsl:template>
    </xsl:stylesheet>
    </cfsavecontent>
    </cfoutput>
    <!--- create a combined xml document --->
    <cfset doc2 = XMLparse(XMLtransform(doc1,transformer))>
    <cfdump var="#doc2#" label="Merged by XSLT"
    expand="no">

  • Insert Node into XML using XPATH

    Hi,
    I'm having problems inserting a node into a XML. After getting some attributes from the CRC result i'd like to store them in a temp xml variable.
    After that the parent node of the attributes should be inserterd in a goal XML with a repeating node structure.
    Whats the right way to set a node to a certain position in the goal XML?
    Now the only thing i'm getting is erros about transaction:
    Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: a307d1e:fd15:4d35c503:1351f50 status: ActionStatus.ABORT_ONLY >
        at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectio nManager.java:304)
        at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnec tionManager2.java:396)
    Etc..
    Thx!

    You can always append new nodes which has a unique tag name (this won't get overwritten).
    Which means, each time when you add a node, it should have tag name which has not already present within the same parent node.
    Later you can replace the tag name with the actual name by using XSL transformations.
    I've tried this in one of my project and worked fine.
    Nith

  • Splitting a Linked List at a Given Node, into Two Sublists??

    My code just will not work!! Any help would be appreciated! My problem is in the last method SplitAt. These are the conditions set and my code:
    Splitting a Linked List at a Given Node, into Two Sublists
    a. Add the following as an abstract method to the class
    LinkedListClass:
    public void splitAt (LinkedListClass<T> secondList, T item);
    //This method splits the list at the node with the info item into two sublists.
    //Precondition: The list must exist.
    //Postcondition: first and last point to the first and last nodes of the first sublist,
    // respectively. secondList.first and secondList.last point to the first
    // and last nodes of the second sublist.
    Consider the following statements:
    UnorderedLinkedList<Integer> myList;
    UnorderedLinkedList<Integer> otherList;
    Suppose myList points to the list with the elements 34, 65, 18, 39, 27, 89, and 12 (in this order). The statement
    myList.splitAt(otherList, 18);
    splits myList into two sublists: myList points to the list with elements 34 and 65, and otherList points to the sublist with elements 18, 39, 27, 89, and 12.
    b. Provide the definition of the method splitAt in the class UnorderedLinkedList. Also write a program to test your method.
    public class UnorderedLinkedList<T> extends LinkedListClass<T>
    //Default constructor
    public UnorderedLinkedList()
    super();
    //Method to determine whether searchItem is in
    //the list.
    //Postcondition: Returns true if searchItem is found
    // in the list; false otherwise.
    public boolean search(T searchItem)
    LinkedListNode<T> current; //variable to traverse
    //the list
    boolean found;
    current = first; //set current to point to the first
    //node in the list
    found = false; //set found to false
    while (current != null && !found) //search the list
    if (current.info.equals(searchItem)) //item is found
    found = true;
    else
    current = current.link; //make current point to
    //the next node
    return found;
    //Method to insert newItem in the list.
    //Postcondition: first points to the new list
    // and newItem is inserted at the
    // beginning of the list. Also,
    // last points to the last node and
    // count is incremented by 1.
    public void insertFirst(T newItem)
    LinkedListNode<T> newNode; //variable to create the
    //new node
    newNode =
    new LinkedListNode<T>(newItem, first); //create and
    //insert newNode before
    //first
    first = newNode; //make first point to the
    //actual first node
    if (last == null) //if the list was empty, newNode is
    //also the last node in the list
    last = newNode;
    count++; //increment count
    //Method to insert newItem at the end of the list.
    //Postcondition: first points to the new list and
    // newItem is inserted at the end
    // of the list. Also, last points to
    // the last node and
    // count is incremented by 1.
    public void insertLast(T newItem)
    LinkedListNode newNode; //variable to create the
    //new node
    newNode =
    new LinkedListNode(newItem, null); //create newNode
    if (first == null) //if the list is empty, newNode is
    //both the first and last node
    first = newNode;
    last = newNode;
    else //if the list is not empty, insert
    //newNode after last
    last.link = newNode; //insert newNode after last
    last = newNode; //set last to point to the
    //actual last node
    count++;
    }//end insertLast
    //Method to delete deleteItem from the list.
    //Postcondition: If found, the node containing
    // deleteItem is deleted from the
    // list. Also, first points to the first
    // node, last points to the last
    // node of the updated list, and count
    // is decremented by 1.
    public void deleteNode(T deleteItem)
    LinkedListNode<T> current; //variable to traverse
    //the list
    LinkedListNode<T> trailCurrent; //variable just
    //before current
    boolean found;
    if ( first == null) //Case 1; the list is empty
    System.err.println("Cannot delete from an empty "
    + "list.");
    else
    if (first.info.equals(deleteItem)) //Case 2
    first = first.link;
         if (first == null) //the list had only one node
         last = null;
         count--;
    else //search the list for the given info
    found = false;
    trailCurrent = first; //set trailCurrent to
    //point to the first node
    current = first.link; //set current to point to
    //the second node
    while (current != null && !found)
    if (current.info.equals(deleteItem))
    found = true;
    else
    trailCurrent = current;
    current = current.link;
    }//end while
    if (found) //Case 3; if found, delete the node
    count--;
    trailCurrent.link = current.link;
    if (last == current) //node to be deleted
    //was the last node
    last = trailCurrent; //update the value
    //of last
    else
    System.out.println("Item to be deleted is "
    + "not in the list.");
    }//end else
    }//end else
    }//end deleteNode
    public void splitAt(LinkedListClass<T> secondList, T item)
    LinkedListNode<T> current;
    LinkedListNode<T> trailCurrent;
    int i;
    boolean found;
    if (first==null)
    System.out.println("Empty.");
    first=null;
    last=null;
    count--;
    else
         current=first;
         found=false;
         i=1;
         while(current !=null &&!found)
              if(current.info.equals(secondList))
                   found= true;
                   else
                        trailCurrent=current;
                        i++;
         if(found)
              if(first==current)
                   first=first;
                   last=last;
                   count=count;
                   count=0;
              else
                   first=current;
                   last=last;
                   last=null;
                   count = count- i+1;
                   count = i-1;
              else
                   System.out.println("Item to be split at is "
    + "not in the list.");
              first=null;
              last=null;
              count=0;
    }

    I dont have a test program at all. The program is supposed to prompt for user input of numbers. (it does) Take the input and end at input of -999 (it does). Then it asks user where it wants to split list (it does). When I enter a number it does nothing after that. I am going to post updated code and see if that helps along with all the classes. Thanks!
    This is the class to prompt:
    import java.util.*;
    public class Ch16_ProgEx6
        static Scanner console = new Scanner(System.in);
         public static void main(String[] args)
             UnorderedLinkedList<Integer> list
                              = new UnorderedLinkedList<Integer>();
            UnorderedLinkedList<Integer> subList =
                              new UnorderedLinkedList<Integer>();
             Integer num;
             System.out.println("Enter integers ending with -999.");
             num = console.nextInt();
             while (num != -999)
                 list.insertLast(num);
                 num = console.nextInt();
            System.out.println();
            System.out.println("list: ");
            list.print();
            System.out.println();
            System.out.println("Length of list: " + list.length());
            System.out.print("Enter the number at which to split list: ");
            num = console.nextInt();
            list.splitAt(subList, num);
            System.out.println("Lists after splitting list");
            System.out.print("list: ");
            list.print();
            System.out.println();
            System.out.println("Length of list: " + list.length());
            System.out.print("sublist: ");
            subList.print();
            System.out.println();
            System.out.println("Length of sublist: " + subList.length());
    }This is the ADT:
    public interface LinkedListADT<T> extends Cloneable
        public Object clone();
           //Returns a copy of objects data in store.
           //This method clones only the references stored in
           //each node of the list. The objects that the
           //list nodes point to are not cloned.
        public boolean isEmptyList();
           //Method to determine whether the list is empty.
           //Postcondition: Returns true if the list is empty;
           //               false otherwise.
        public void initializeList();
           //Method to initialize the list to an empty state.
           //Postcondition: The list is initialized to an empty
           //               state.
        public void print();
           //Method to output the data contained in each node.
        public int length();
           //Method to return the number of nodes in the list.
           //Postcondition: The number of nodes in the list is
           //               returned.
        public T front();
           //Method to return a reference of the object containing
           //the data of the first node of the list.
           //Precondition: The list must exist and must not be empty.
           //Postcondition: The reference of the object that
           //               contains the info of the first node
           //               is returned.
        public T back();
           //Method to return a reference of object containing
           //the data of the last node of the list.
           //Precondition: The list must exist and must not be empty.
           //Postcondition: The reference of the object that
           //               contains the info of the last node
           //               is returned.
        public boolean search(T searchItem);
           //Method to determine whether searchItem is in the list.
           //Postcondition: Returns true if searchItem is found
           //               in the list; false otherwise.
        public void insertFirst(T newItem);
           //Method to insert newItem in the list.
           //Postcondition: newItem is inserted at the
           //               beginning of the list.
        public void insertLast(T newItem);
           //Method to insert newItem at the end of the list.
           //Postcondition: newItem is inserted at the end
           //               of the list.
        public void deleteNode(T deleteItem);
           //Method to delete deleteItem from the list.
           //Postcondition: If found, the node containing
           //               deleteItem is deleted from the
           //               list.
        public void splitAt(LinkedListClass<T> secondList, T item);
    }This is the linked list class:
    import java.util.NoSuchElementException;
    public abstract class LinkedListClass<T> implements LinkedListADT<T>
        protected class LinkedListNode<T> implements Cloneable
            public T info;
            public LinkedListNode<T> link;
               //Default constructor
               //Postcondition: info = null; link = null;
            public LinkedListNode()
                info = null;
                link = null;
               //Constructor with parameters
               //This method sets info pointing to the object to
               //which elem points to and link is set to point to
               //the object to which ptr points to.
               //Postcondition:  info = elem; link = ptr;
            public LinkedListNode(T elem, LinkedListNode<T> ptr)
                info = elem;
                link = ptr;
               //Returns a copy of objects data in store.
               //This method clones only the references stored in
               //the node. The objects that the nodes point to
               //are not cloned.
            public Object clone()
                LinkedListNode<T> copy = null;
                try
                    copy = (LinkedListNode<T>) super.clone();
                catch (CloneNotSupportedException e)
                    return null;
                return copy;
               //Method to return the info as a string.
               //Postcondition: info as a String object is
               //               returned.
            public String toString()
                return info.toString();
        } //end class LinkedListNode
        public class LinkedListIterator<T>
            protected LinkedListNode<T> current;  //variable to
                                                  //point to the
                                                  //current node in
                                                  //list
            protected LinkedListNode<T> previous; //variable to
                                                  //point to the
                                                  //node before the
                                                  //current node
               //Default constructor
               //Sets current to point to the first node in the
               //list and sets previous to null.
               //Postcondition: current = first; previous = null;
            public LinkedListIterator()
                current = (LinkedListNode<T>) first;
                previous = null;
               //Method to reset the iterator to the first node
               //in the list.
               //Postcondition: current = first; previous = null;
            public void reset()
                current = (LinkedListNode<T>) first;
                previous = null;
               //Method to return a reference of the info of the
               //current node in the list and to advance iterator
               //to the next node.
               //Postcondition: previous = current;
               //               current = current.link;
               //               A refrence of the current node
               //               is returned.
            public T next()
                if (!hasNext())
                    throw new NoSuchElementException();
                LinkedListNode<T> temp = current;
                previous = current;
                current = current.link;
                return temp.info;
                //Method to determine whether there is a next
                //element in the list.
                //Postcondition: Returns true if there is a next
                //               node in the list; otherwise
                //               returns false.
            public boolean hasNext()
                return (current != null);
               //Method to remove the node currently pointed to
               //by the iterator.
               //Postcondition: If iterator is not null, then the
               //               node that the iterator points to
               //               is removed. Otherwise the method
               //               throws NoSuchElementException.
            public void remove()
                if (current == null)
                    throw new NoSuchElementException();
                if (current == first)
                    first = first.link;
                    current = (LinkedListNode<T>) first;
                    previous = null;
                    if (first == null)
                        last = null;
                else
                    previous.link = current.link;
                    if (current == last)
                        last = first;
                        while (last.link != null)
                            last = last.link;
                    current = current.link;
                count--;
               //Method to return the info as a string.
               //Postcondition: info as a String object is returned.
            public String toString()
                return current.info.toString();
        } //end class LinkedListIterator
           //Instance variables of the class LinkedListClass
        protected LinkedListNode<T> first; //variable to store the
                                           //address of the first
                                           //node of the list
        protected LinkedListNode<T> last;  //variable to store the
                                           //address of the last
                                           //node of the list
        protected int count;  //variable to store the number of
                              //nodes in the list
           //Default constructor
           //Initializes the list to an empty state.
           //Postcondition: first = null, last = null,
           //               count = 0
        public LinkedListClass()
            first = null;
            last = null;
            count = 0;
           //Method to determine whether the list is empty.
           //Postcondition: Returns true if the list is empty;
           //               false otherwise.
        public boolean isEmptyList()
            return (first == null);
           //Method to initialize the list to an empty state.
           //Postcondition: first = null, last = null,
           //               count = 0
        public void initializeList()
            first = null;
            last = null;
            count = 0;
           //Method to output the data contained in each node.
        public void print()
            LinkedListNode<T> current; //variable to traverse
                                       //the list
            current = first;    //set current so that it points to
                                //the first node
            while (current != null) //while more data to print
                System.out.print(current.info + " ");
                current = current.link;
        }//end print
           //Method to return the number of nodes in the list.
           //Postcondition: The value of count is returned.
        public int length()
            return count;
           //Method to return a reference of the object containing
           //the data of the first node of the list.
           //Precondition: The list must exist and must not be empty.
           //Postcondition: The reference of the object that
           //               contains the info of the first node
           //               is returned.
        public T front()
            return first.info;
            //Method to return a reference of object containing
            //the data of the last node of the list.
            //Precondition: The list must exist and must not be empty.
            //Postcondition: The reference of the object that
            //               contains the info of the last node
            //               is returned.
        public T back()
            return last.info;
           //Returns a copy of objects data in store.
           //This method clones only the references stored in
           //each node of the list. The objects that the
           //list nodes point to are not cloned.
        public Object clone()
            LinkedListClass<T> copy = null;
            try
                copy = (LinkedListClass<T>) super.clone();
            catch (CloneNotSupportedException e)
                return null;
                //If the list is not empty clone each node of
                //the list.
            if (first != null)
                   //Clone the first node
                copy.first = (LinkedListNode<T>) first.clone();
                copy.last = copy.first;
                LinkedListNode<T> current;
                if (first != null)
                    current = first.link;
                else
                    current = null;
                   //Clone the remaining nodes of the list
                while (current != null)
                    copy.last.link =
                            (LinkedListNode<T>) current.clone();
                    copy.last = copy.last.link;
                    current = current.link;
            return copy;
           //Method to return an iterator of the list.
           //Postcondition: An iterator is instantiated and
           //               returned.
        public LinkedListIterator<T> iterator()
            return new LinkedListIterator<T>();
           //Method to determine whether searchItem is in
           //the list.
           //Postcondition: Returns true if searchItem is found
           //               in the list; false otherwise.
        public abstract boolean search(T searchItem);
           //Method to insert newItem in the list.
           //Postcondition: first points to the new list
           //               and newItem is inserted at the
           //               beginning of the list. Also,
           //               last points to the last node and
           //               count is incremented by 1.
        public abstract void insertFirst(T newItem);
           //Method to insert newItem at the end of the list.
           //Postcondition: first points to the new list and
           //               newItem is inserted at the end
           //               of the list. Also, last points to
           //               the last node and
           //               count is incremented by 1.
        public abstract void insertLast(T newItem);
           //Method to delete deleteItem from the list.
           //Postcondition: If found, the node containing
           //               deleteItem is deleted from the
           //               list. Also, first points to the first
           //               node, last points to the last
           //               node of the updated list, and count
           //               is decremented by 1.
        public abstract void deleteNode(T deleteItem);
        public abstract void splitAt(LinkedListClass<T> secondList, T item);
    }And this is the UnorderedLinked Class with the very last method the one being Im stuck on. The SplitAt Method.
    public class UnorderedLinkedList<T> extends LinkedListClass<T>
           //Default constructor
        public UnorderedLinkedList()
            super();
            //Method to determine whether searchItem is in
            //the list.
            //Postcondition: Returns true if searchItem is found
            //               in the list; false otherwise.
        public boolean search(T searchItem)
            LinkedListNode<T> current; //variable to traverse
                                       //the list
            boolean found;
            current = first;  //set current to point to the first
                              //node in the list
            found = false;    //set found to false
            while (current != null && !found) //search the list
                if (current.info.equals(searchItem)) //item is found
                    found = true;
                else
                   current = current.link; //make current point to
                                           //the next node
            return found;
            //Method to insert newItem in the list.
            //Postcondition: first points to the new list
            //               and newItem is inserted at the
            //               beginning of the list. Also,
            //               last points to the last node and
            //               count is incremented by 1.
        public void insertFirst(T newItem)
            LinkedListNode<T> newNode;     //variable to create the
                                        //new node
            newNode =
               new LinkedListNode<T>(newItem, first); //create and
                                           //insert newNode before
                                           //first
            first = newNode;   //make first point to the
                               //actual first node
            if (last == null)   //if the list was empty, newNode is
                                //also the last node in the list
                last = newNode;
            count++;     //increment count
            //Method to insert newItem at the end of the list.
            //Postcondition: first points to the new list and
            //               newItem is inserted at the end
            //               of the list. Also, last points to
            //               the last node and
            //               count is incremented by 1.
        public void insertLast(T newItem)
            LinkedListNode newNode; //variable to create the
                                    //new node
            newNode =
               new LinkedListNode(newItem, null);  //create newNode
            if (first == null)  //if the list is empty, newNode is
                                //both the first and last node
                first = newNode;
                last = newNode;
            else     //if the list is not empty, insert
                     //newNode after last
                last.link = newNode; //insert newNode after last
                last = newNode;      //set last to point to the
                                     //actual last node
            count++;
        }//end insertLast
            //Method to delete deleteItem from the list.
            //Postcondition: If found, the node containing
            //               deleteItem is deleted from the
            //               list. Also, first points to the first
            //               node, last points to the last
            //               node of the updated list, and count
            //               is decremented by 1.
        public void deleteNode(T deleteItem)
            LinkedListNode<T> current; //variable to traverse
                                       //the list
            LinkedListNode<T> trailCurrent; //variable just
                                            //before current
            boolean found;
            if ( first == null)    //Case 1; the list is empty
                System.err.println("Cannot delete from an empty "
                                 + "list.");
            else
                if (first.info.equals(deleteItem)) //Case 2
                    first = first.link;
                       if (first == null)  //the list had only one node
                          last = null;
                       count--;
                else  //search the list for the given info
                    found = false;
                    trailCurrent = first; //set trailCurrent to
                                          //point to the first node
                    current = first.link; //set current to point to
                                          //the second node
                    while (current != null && !found)
                        if (current.info.equals(deleteItem))
                            found = true;
                        else
                            trailCurrent = current;
                            current = current.link;
                    }//end while
                    if (found) //Case 3; if found, delete the node
                        count--;
                        trailCurrent.link = current.link;
                        if (last == current)  //node to be deleted
                                              //was the last node
                           last = trailCurrent;  //update the value
                                                 //of last
                    else
                       System.out.println("Item to be deleted is "
                                        + "not in the list.");
                }//end else
            }//end else
        }//end deleteNode
        public void splitAt(LinkedListClass<T> secondList, T item)
         LinkedListNode<T> current;
         LinkedListNode<T> trailCurrent;
         int i;
         boolean found;
         if (first==null)
        System.out.println("Empty.");
        first=null;
        last=null;
        count--;
        count=0;
         else
              current=first;
              found=false;
              i=1;
              while(current !=null &&!found)
                   if(current.info.equals(item))
                       found= true;
                       else
                            trailCurrent=first;
                            current=first;
                            i++;
              if(found)
                   if(first==current)
                        first.link=first;
                        last.link=last;
                           count--;
                        count=0;
                   else
                        first.link=current;
                        last.link=last;
                        last=null;
                        count = count- i+1;
                        count = i-1;
              } else  {
                  System.out.println("Item to be split at is "
                    + "not in the list.");
                   first=null;
                   last=null;
                   count=0;
        Any help or just advice would be fine. Im not the best at Java, better at VB. Am completely stumped! Thanks so much!

  • How I can append new node in existing  XML file

    I've just begun learning DOM XML , so I'm currently at a very beginner level.
    I have an existing XML file that I would like to add an additional node to before saving it to another variable.
    how I can append new node in this file.
    now this code is overwrite new data over old data
    The code looks like this:
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.TransformerFactoryConfigurationError;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Attr;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    public class VerbXMLWriter
        static String EVerb3;
        static String englishTranslate3;
        public void VerbXMLWriter(String EVerb, String englishTranslate )
             EVerb3 = EVerb;
             englishTranslate3=englishTranslate;
        File xmlFile = new File("VerbDB.xml");
        DocumentBuilderFactory factory =  DocumentBuilderFactory.newInstance();
        try
         DocumentBuilder builder = factory.newDocumentBuilder();
         Document document = builder.newDocument();
        Element root = document.createElement("Verb");
         document.appendChild(root);
         Element verb = document.createElement(EVerb3);
         verb.setAttribute("EnglishTranslate",englishTranslate3);
         root.appendChild(verb);
         Source xmlSource = new DOMSource( document );
         Result result = new StreamResult( new FileOutputStream(xmlFile) );
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer =
        transformerFactory.newTransformer();
        transformer.setOutputProperty( "indent", "yes" );
         transformer.transform( xmlSource, result );
      catch(TransformerFactoryConfigurationError factoryError )
        factoryError.printStackTrace();
       catch (ParserConfigurationException pc)
           pc.printStackTrace();
       catch (IOException io)
          io.printStackTrace();
       catch(Exception excep )
           excep.printStackTrace();
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Verb>
    <Play EnglishTranslate="playing" />
    </Verb>Edited by: itb402 on Mar 9, 2008 6:05 AM

    in your code you are already appending new nodes to the root node. so what exactly is your problem? The following steps are usually taken for appending a new node:
    1. Read the XML document
    2. Build a DOM tree
    3. Navigate to the node under which you want to insert the new node
    4. Create a new node.
    5. Insert the new node to the node selected in point #3.
    ~Debopam

Maybe you are looking for