Join Nodes from different XML strings

Hi,
Please can you help me in joining 2 similar XML documents such that required nodes are appended.
Need to combine the nodes of XML (input source:String) A and B as below:
A:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MSG_Cont xmlns:ns0="http://xmlns.sample.xml.com/Xref">
    <ns0:Header>
        <ns0:ProjectName>Services-1</ns0:ProjectName>
        <ns0:TimeStamp>11-05-2007 08:24:08</ns0:TimeStamp>
    </ns0:Header>
    <ns0:Body>
        <ns0:MID_INTER_XREF>
            <ns0:INT_ID>0</ns0:INT_ID>
            <ns1:CDS_Person xmlns:ns1="http://xmlns.sample.xml.com/PXref">
                <ns1:PERS_TITLE>MGR</ns1:PERS_TITLE>
                <ns1:PERS_FIRST_NM>BUY</ns1:PERS_FIRST_NM>
                <ns1:PERS_LAST_NM>INT</ns1:PERS_LAST_NM>
            </ns1:CDS_Person>
            <ns0:CLS>48</ns0:CLS>
            <ns0:COM>410</ns0:COM>
            <ns0:SW>P</ns0:SW>
            <ns0:ALT_ID>  </ns0:ALT_ID>
            <ns0:ACTV_CD>I</ns0:ACTV_CD>
            <ns0:LST_UPDT_DT>2006-01-30</ns0:LST_UPDT_DT>
        </ns0:MID_INTER_XREF>
        <ns0:MID_INTER_XREF>
         <ns0:INT_ID>96</ns0:INT_ID>
         <ns1:CDS_Person xmlns:ns1="http://xmlns.sample.xml.com/PXref">
          <ns1:PERS_TITLE>MGR</ns1:PERS_TITLE>
          <ns1:PERS_FIRST_NM>TEMP</ns1:PERS_FIRST_NM>
          <ns1:PERS_LAST_NM>GRT</ns1:PERS_LAST_NM>
         </ns1:CDS_Person>
         <ns0:CLS>48</ns0:CLS>
         <ns0:COM>935</ns0:COM>
         <ns0:SW>D</ns0:SW>
         <ns0:ALT_ID>F$</ns0:ALT_ID>
         <ns0:ACTV_CD>A</ns0:ACTV_CD>
         <ns0:LST_UPDT_DT>2006-01-30</ns0:LST_UPDT_DT>
     </ns0:MID_INTER_XREF>
    </ns0:Body>
</ns0:MSG_Cont>B:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MSG_Cont xmlns:ns0="http://xmlns.sample.xml.com/Xref">
    <ns0:Header>
        <ns0:ProjectName>Services-1</ns0:ProjectName>
        <ns0:TimeStamp>11-05-2007 08:24:08</ns0:TimeStamp>
    </ns0:Header>
    <ns0:Body>
        <ns0:MID_INTER_XREF>
            <ns0:INT_ID>0</ns0:INT_ID>
            <ns1:CDS_Person xmlns:ns1="http://xmlns.sample.xml.com/PXref">
                <ns1:PERS_TITLE>TECH</ns1:PERS_TITLE>
                <ns1:PERS_FIRST_NM>BUY</ns1:PERS_FIRST_NM>
                <ns1:PERS_LAST_NM>INT</ns1:PERS_LAST_NM>
            </ns1:CDS_Person>
            <ns0:CLS>98</ns0:CLS>
            <ns0:COM>910</ns0:COM>
            <ns0:SW>P</ns0:SW>
            <ns0:ALT_ID>  </ns0:ALT_ID>
            <ns0:ACTV_CD>I</ns0:ACTV_CD>
            <ns0:LST_UPDT_DT>2006-01-30</ns0:LST_UPDT_DT>
        </ns0:MID_INTER_XREF>
        <ns0:MID_INTER_XREF>
         <ns0:INT_ID>96</ns0:INT_ID>
         <ns1:CDS_Person xmlns:ns1="http://xmlns.sample.xml.com/PXref">
          <ns1:PERS_TITLE>TECH</ns1:PERS_TITLE>
          <ns1:PERS_FIRST_NM>TEMP</ns1:PERS_FIRST_NM>
          <ns1:PERS_LAST_NM>GRT</ns1:PERS_LAST_NM>
         </ns1:CDS_Person>
         <ns0:CLS>98</ns0:CLS>
         <ns0:COM>435</ns0:COM>
         <ns0:SW>D</ns0:SW>
         <ns0:ALT_ID>F$</ns0:ALT_ID>
         <ns0:ACTV_CD>A</ns0:ACTV_CD>
         <ns0:LST_UPDT_DT>2006-01-30</ns0:LST_UPDT_DT>
     </ns0:MID_INTER_XREF>
    </ns0:Body>
</ns0:MSG_Cont>Combined (desired Output):
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MSG_Cont xmlns:ns0="http://xmlns.sample.xml.com/Xref">
    <ns0:Header>
        <ns0:ProjectName>Services-1</ns0:ProjectName>
        <ns0:TimeStamp>11-05-2007 08:24:08</ns0:TimeStamp>
    </ns0:Header>
    <ns0:Body>
        <ns0:MID_INTER_XREF>
            <ns0:INT_ID>0</ns0:INT_ID>
            <ns1:CDS_Person xmlns:ns1="http://xmlns.sample.xml.com/PXref">
                <ns1:PERS_TITLE>MGR</ns1:PERS_TITLE>
                <ns1:PERS_FIRST_NM>BUY</ns1:PERS_FIRST_NM>
                <ns1:PERS_LAST_NM>INT</ns1:PERS_LAST_NM>
            </ns1:CDS_Person>
            <ns0:CLS>48</ns0:CLS>
            <ns0:COM>410</ns0:COM>
            <ns0:SW>P</ns0:SW>
            <ns0:ALT_ID>  </ns0:ALT_ID>
            <ns0:ACTV_CD>I</ns0:ACTV_CD>
            <ns0:LST_UPDT_DT>2006-01-30</ns0:LST_UPDT_DT>
        </ns0:MID_INTER_XREF>
        <ns0:MID_INTER_XREF>
         <ns0:INT_ID>96</ns0:INT_ID>
         <ns1:CDS_Person xmlns:ns1="http://xmlns.sample.xml.com/PXref">
          <ns1:PERS_TITLE>MGR</ns1:PERS_TITLE>
          <ns1:PERS_FIRST_NM>TEMP</ns1:PERS_FIRST_NM>
          <ns1:PERS_LAST_NM>GRT</ns1:PERS_LAST_NM>
         </ns1:CDS_Person>
         <ns0:CLS>48</ns0:CLS>
         <ns0:COM>935</ns0:COM>
         <ns0:SW>D</ns0:SW>
         <ns0:ALT_ID>F$</ns0:ALT_ID>
         <ns0:ACTV_CD>A</ns0:ACTV_CD>
         <ns0:LST_UPDT_DT>2006-01-30</ns0:LST_UPDT_DT>
     </ns0:MID_INTER_XREF>
     <ns0:MID_INTER_XREF>
         <ns0:INT_ID>0</ns0:INT_ID>
         <ns1:CDS_Person xmlns:ns1="http://xmlns.sample.xml.com/PXref">
          <ns1:PERS_TITLE>TECH</ns1:PERS_TITLE>
          <ns1:PERS_FIRST_NM>BUY</ns1:PERS_FIRST_NM>
          <ns1:PERS_LAST_NM>INT</ns1:PERS_LAST_NM>
         </ns1:CDS_Person>
         <ns0:CLS>98</ns0:CLS>
         <ns0:COM>910</ns0:COM>
         <ns0:SW>P</ns0:SW>
         <ns0:ALT_ID>  </ns0:ALT_ID>
         <ns0:ACTV_CD>I</ns0:ACTV_CD>
         <ns0:LST_UPDT_DT>2006-01-30</ns0:LST_UPDT_DT>
     </ns0:MID_INTER_XREF>
     <ns0:MID_INTER_XREF>
         <ns0:INT_ID>96</ns0:INT_ID>
         <ns1:CDS_Person xmlns:ns1="http://xmlns.sample.xml.com/PXref">
          <ns1:PERS_TITLE>TECH</ns1:PERS_TITLE>
          <ns1:PERS_FIRST_NM>TEMP</ns1:PERS_FIRST_NM>
          <ns1:PERS_LAST_NM>GRT</ns1:PERS_LAST_NM>
         </ns1:CDS_Person>
         <ns0:CLS>98</ns0:CLS>
         <ns0:COM>435</ns0:COM>
         <ns0:SW>D</ns0:SW>
         <ns0:ALT_ID>F$</ns0:ALT_ID>
         <ns0:ACTV_CD>A</ns0:ACTV_CD>
         <ns0:LST_UPDT_DT>2006-01-30</ns0:LST_UPDT_DT>
     </ns0:MID_INTER_XREF>
    </ns0:Body>
</ns0:MSG_Cont>Trying to use the dom document.importNode() and appendChild(). But, looks like appendChild removes any already existing node (in this case - ns0:MID_INTER_XREF).
Any help appreciated.
TIA,
Praveen

Well, the requirement was to have elements from different XML in a single master XML. The way we achieved this - read from each XML, append to a string buffer and construct the combined XML (which passes on for use elsewhere).
Hope this helps anyone with a similar requirement.
Many Thanks for looking.

Similar Messages

  • How to remove a node from a xml

    Hi All,
    I want to remove a node from my xml output. Can anyone suggest me how to get that? I want to implement this by using the ASSIGN activity.
    My sample output is
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
         <env:Header>
              <wsa:MessageID>urn:4EF1A350677C11E1BFA7794ED76B03EF</wsa:MessageID>
              <wsa:ReplyTo>
                   <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
              </wsa:ReplyTo>
         </env:Header>
         <env:Body>
              <SiebelOrderQueryByExample_Output xmlns="http://siebel.com/asi/">
                   <ListOfOrderInterface xmlns="http://www.siebel.com/xml/Siebel%20Order">
                        <Orders>
                             <Id>1-15IXJ</Id>
                             <AccountId>1-2EE</AccountId>
                             <OrderNumber>1012-1234</OrderNumber>
                             <ListOfLineItems>
                                  <LineItems>
                                       <Id>1-15IYN</Id>
                                       <LineNumber>303</LineNumber>
                                       <OrderNumber>1012-1234</OrderNumber>
                                       <OrderHeaderId>1-15IXJ</OrderHeaderId>
                             </LineItems>
                                  </ListOfLineItems>
                             </Orders>
    </ListOfOrderInterface>
              </SiebelOrderQueryByExample_Output>
         </env:Body>
    </env:Envelope>
    I want to delete the <ListOfLineItems>node from the xml above so that my resultant would be,
         <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
         <env:Header>
              <wsa:MessageID>urn:4EF1A350677C11E1BFA7794ED76B03EF</wsa:MessageID>
              <wsa:ReplyTo>
                   <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
              </wsa:ReplyTo>
         </env:Header>
         <env:Body>
              <SiebelOrderQueryByExample_Output xmlns="http://siebel.com/asi/">
                   <ListOfOrderInterface xmlns="http://www.siebel.com/xml/Siebel%20Order">
                        <Orders>
                             <Id>1-15IXJ</Id>
                             <AccountId>1-2EE</AccountId>
                             <OrderNumber>1012-1234</OrderNumber>
         </Orders>
    </ListOfOrderInterface>
              </SiebelOrderQueryByExample_Output>
         </env:Body>
    </env:Envelope>     
    Please suggest something Its urgent.
    Thanks in Advance.

    It goes something like this, taken from the above blog entry:
    Removing a node from node-list
    With the bpelx: extensions in BPEL you are able to insert and update nodes in a node list. A node-list is an XML message that contains a set of records. In this article I use the following example:
    <BookList xmlns="http://message.vijfhuizen.com">
    <Book>
    <title>The Lord Of The Rings</title>
    <author>J.R.R. Tolkien</author>
    </Book>
    <Book>
    <title>Harry Potter</title>
    <author>J.R.R. Tolkien</author>
    </Book>
    <Book>
    <title>The Hobbit</title>
    <author>J.R.R. Tolkien</author>
    </Book>
    <Book>
    <title>Storm; Chronicals of Pandarve</title>
    <author>Don Lawrence</author>
    </Book>
    </BookList>
    For creating and updating node lists the bpelx: functions are enough to handle this. But when you want to remove a particular node, you can use the bpelx:remove function. But this function can only remove a node from a particular position. For example removing the second node you code:
    <bpel:assign>
    <bpelx:remove>
    <bpelx:target variable="VarBookList" query="/Booklist/Book[2]" />
    </bpelx:append>
    </bpel:assign>
    It is hard to code the bpelx:remove to create a xpath to dynamicly remove node. You would like to remove the second node based on the xpath:
    /Booklist/Book[title="Harry Potter" and author="J.R.R. Tolkien"]
    You can add the above xpath in the bpelx:remove, but you are not able to make this dynamically.
    There is a solution. The trick is to create a stylesheet that copies the data into a new message, but removing that particular records. Create a stylesheet that does the normal copy of the XML message. Then add a <choose> element in the stylsheet to filter that particular record.
    <xsl:template match="/">
    <BookList>
    <xsl:for-each select="/BookList/Book">
    <xsl:choose>
    <xsl:when test="title='Harry Potter' and author='J.R.R. Tolkien'"/>
    <xsl:otherwise>
    <Book>
    <title>
    <xsl:value-of select="title"/>
    </title>
    <author>
    <xsl:value-of select="author"/>
    </author>
    </Book>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
    </BookList>
    Now we have a XSL stylesheet that removes a particular record, but this is not variable. This can be done via XSLT parameters.
    <xsl:param name="pTitle"/>
    <xsl:param name="pAuthor"/>
    <xsl:template match="/">
    <BookList>
    <xsl:for-each select="/BookList/Book">
    <xsl:choose>
    <xsl:when test="title=$pTitle and author=$pAuthor"/>
    <xsl:otherwise>
    <Book>
    <title>
    <xsl:value-of select="title"/>
    </title>
    <author>
    <xsl:value-of select="author"/>
    </author>
    </Book>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
    </BookList>
    </xsl:template>
    Now we are able to use this stylesheet in BPEL. In general BPEL create the following code:
    <assign name="Transform">
    <bpelx:annotation>
    <bpelx:pattern>transformation</bpelx:pattern>
    </bpelx:annotation>
    <copy>
    <from expression="ora:processXSLT('RemoveNode.xsl'
    , bpws:getVariableData('Variable_BookList','payload')" />
    <to variable="Variable_BookListTemp" part="payload"/>
    </copy>
    </assign>
    But this code does not pass parameters to the stylesheet. The ora:processXSLT() can do this it has an additional parameter in this function:
    <assign name="Transform">
    <bpelx:annotation>
    <bpelx:pattern>transformation</bpelx:pattern>
    </bpelx:annotation>
    <copy>
    <from expression="ora:processXSLT('RemoveNode.xsl'
    , bpws:getVariableData('Variable_BookList','payload')" />
    , bpws:getVariableData('BPELxslparameters'))"/>
    <to variable="Variable_BookListTemp" part="payload"/>
    </copy>
    </assign>
    Now only you have to create the BPELxslparameters variable and assign it with the correct name/value pairs. The structure of the this variable is as follows:
    <?xml version="1.0" encoding="windows-1252" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://schemas.oracle.com/service/bpel/common"
    targetNamespace="http://schemas.oracle.com/service/bpel/common"
    elementFormDefault="qualified">
    <xsd:element name="parameters">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="value" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    Create in BPEL the variable BPELxslparameters and let it point to this strucure:
    <process ....
    xmlns:common="http://schemas.oracle.com/service/bpel/common"
    .../>
    <variable name="BPELparameters" element="common:parameters"/>
    Now we can in BPEL create an empty XML message, based on this strcuture and assign the values to these parameters and then call the processXSLT function.
    <bpelx:assign name="Assign_GenerateEmptyParameterSet">
    <copy>
    <from>
    <parameters xmlns="http://schemas.oracle.com/service/bpel/common">
    <item>
    <name>pTitle</name>
    <value/>
    </item>
    <item>
    <name>pAutor</name>
    <value/>
    </item>
    </parameters>
    </from>
    <to variable="BPELparameters" query="/common:parameters"/>
    </copy>
    </bpelx:assign>
    <assign name="Assign_setXSLTParameters">
    <copy>
    <from expression="'Harry Potter'"/>
    <to variable="BPELparameters" query="/common:parameters/common:item[1]/common:value"/>
    </copy>
    <copy>
    <from expression="'J.R.R. Tolkien'"/>
    <to variable="BPELparameters" query="/common:parameters/common:item[1]/common:value"/>
    </copy>
    </assign>
    Posted by Marc Kelderman SOA Blog at 1/16/2008 09:20:00 PM

  • How to join  fields from different internal tables and display into one int

    hai i have one doubt...
    how to join  fields from different internal tables and display into one internal table..
    if anybody know the ans for this qus tell me......

    hii
    you can read data as per condition and then can join in one internal table using READ and APPEND statement..refer to following code.
    SELECT bwkey                         " Valuation Area
             bukrs                         " Company Code
        FROM t001k
        INTO TABLE i_t001k
       WHERE bukrs IN s_bukrs.
      IF sy-subrc EQ 0.
        SELECT bwkey                       " Valuation Area
               werks                       " Plant
          FROM t001w
          INTO TABLE i_t001w
           FOR ALL ENTRIES IN i_t001k
         WHERE bwkey = i_t001k-bwkey
           AND werks IN s_werks.
        IF sy-subrc EQ 0.
          LOOP AT i_output INTO wa_output.
            READ TABLE i_t001w INTO wa_t001w WITH KEY werks = wa_output-werks.
            READ TABLE i_t001k INTO wa_t001k WITH KEY bwkey = wa_t001w-bwkey.
            wa_output-bukrs = wa_t001k-bukrs.
            MODIFY i_output FROM wa_output.
            CLEAR wa_output.
          ENDLOOP.                         " LOOP AT i_output
        ENDIF.                             " IF sy-subrc EQ 0
    regards
    twinkal

  • Adding multiple same-name nodes from one xml into another

    Hi,
    Following on from my question the other day (Adding multiple different nodes from one xmltype into another), I now have a slightly more complex requirement that I cannot work out where to start, assuming that it's something that can reuse some/all of yesterday's work (thanks again, odie_63!). ETA: I'm on 11.2.0.3
    So, here's the (slightly amended) xml along with yesterday's solution:
    with sample_data as (select xmltype('<root>
                                           <xmlnode>
                                             <subnode1>val1</subnode1>
                                             <subnode2>val2</subnode2>
                                           </xmlnode>
                                           <xmlnode>
                                             <subnode1>val3</subnode1>
                                             <subnode2>val4</subnode2>
                                           </xmlnode>
                                         </root>') xml_to_update,
                                xmltype('<a>
                                           <b>valb</b>
                                           <c>valc</c>
                                           <d>
                                             <d1>vald1</d1>
                                             <d2>vald2</d2>
                                           </d>
                                           <e>vale</e>
                                           <f>valf</f>
                                           <g>
                                             <g1>valg1</g1>
                                             <g2>valg2</g2>
                                           </g>
                                           <h>
                                             <h1>valh1</h1>
                                             <h2>valh2</h2>
                                           </h>
                                           <multinode>
                                             <name>fred</name>
                                             <type>book</type>
                                             <head>1</head>
                                           </multinode>
                                           <multinode>
                                             <name>bob</name>
                                             <type>car</type>
                                             <head>0</head>
                                           </multinode>                                        
                                         </a>') xml_to_extract_from
                          from   dual)
    select xmlserialize(document
               xmlquery(
                 'copy $d := $old
                  modify (
                    insert node element extrainfo {
                      $new/a/b
                    , $new/a/d
                    , $new/a/f
                    , $new/a/h
                    } as first into $d/root
                  return $d'
                 passing sd.xml_to_update as "old"
                       , sd.xml_to_extract_from as "new"
                 returning content
             indent
    from sample_data sd;
    That gives me:
    <root>
      <extrainfo>
        <b>valb</b>
        <d>
          <d1>vald1</d1>
          <d2>vald2</d2>
        </d>
        <f>valf</f>
        <h>
          <h1>valh1</h1>
          <h2>valh2</h2>
        </h>
      </extrainfo>
      <xmlnode>
        <subnode1>val1</subnode1>
        <subnode2>val2</subnode2>
      </xmlnode>
      <xmlnode>
        <subnode1>val3</subnode1>
        <subnode2>val4</subnode2>
      </xmlnode>
    </root>
    However, I now need to add in a set of new nodes based on information from the <multinode> nodes, something like:
    <root>
      <extrainfo>
        <b>valb</b>
        <d>
          <d1>vald1</d1>
          <d2>vald2</d2>
        </d>
        <f>valf</f>
        <h>
          <h1>valh1</h1>
          <h2>valh2</h2>
        </h>
        <newnode>
          <name>fred</name>
          <type>book</type>
        </newnode>
        <newnode>
          <name>bob</name>
          <type>car</type>
        </newnode>
      </extrainfo>
      <xmlnode>
        <subnode1>val1</subnode1>
        <subnode2>val2</subnode2>
        <type>book</type>
      </xmlnode>
      <xmlnode>
        <subnode1>val3</subnode1>
        <subnode2>val4</subnode2>
        <type>car</type>
      </xmlnode>
    </root>
    If it's easier, I *think* we would be ok with something like:
    <newnode>
      <type name="fred">book</type>
      <type name="bob">car</type>
    </newnode>
    The closest I've come is:
    with sample_data as (select xmltype('<root>
                                           <xmlnode>
                                             <subnode1>val1</subnode1>
                                             <subnode2>val2</subnode2>
                                           </xmlnode>
                                           <xmlnode>
                                             <subnode1>val3</subnode1>
                                             <subnode2>val4</subnode2>
                                           </xmlnode>
                                         </root>') xml_to_update,
                                xmltype('<a>
                                           <b>valb</b>
                                           <c>valc</c>
                                           <d>
                                             <d1>vald1</d1>
                                             <d2>vald2</d2>
                                           </d>
                                           <e>vale</e>
                                           <f>valf</f>
                                           <g>
                                             <g1>valg1</g1>
                                             <g2>valg2</g2>
                                           </g>
                                           <h>
                                             <h1>valh1</h1>
                                             <h2>valh2</h2>
                                           </h>
                                           <multinode>
                                             <name>fred</name>
                                             <type>book</type>
                                             <head>1</head>
                                           </multinode>
                                           <multinode>
                                             <name>bob</name>
                                             <type>car</type>
                                             <head>0</head>
                                           </multinode>                                        
                                         </a>') xml_to_extract_from
                          from   dual)
    select xmlserialize(document
               xmlquery(
                 'copy $d := $old
                  modify (
                    insert node element extrainfo {
                      $new/a/b
                    , $new/a/d
                    , $new/a/f
                    , $new/a/h
                    , element newnode {
                                       $new/a/multinode/name
                                       ,$new/a/multinode/type
                    } as first into $d/root
                  return $d'
                 passing sd.xml_to_update as "old"
                       , sd.xml_to_extract_from as "new"
                 returning content
             indent
             ) fred
    from sample_data sd;
    Which produces:
    <newnode>
      <name>fred</name>
      <name>bob</name>
      <type>book</type>
      <type>car</type>
    </newnode>
    - obviously not right!
    Can anyone provide any hints? I've tried searching for similar examples, but I mustn't be putting in the right search terms or something!

    odie_63 wrote:
    or, similarly, to get the alternate output :
    copy $d := $old
    modify (
      insert node element extrainfo {
        $new/a/b
      , $new/a/d
      , $new/a/f
      , $new/a/h
      , element newnode {
          for $i in $new/a/multinode
          return element type {
            attribute name {data($i/name)}
          , data($i/type)
      } as first into $d/root
    return $d
    So we're going with the second method, but I've discovered that the "$i/name" node is not always present. When that happens, I would like to use a default value (for example, "george"). I promise I've searched and searched, but I'm completely failing to turn up anything that sounds remotely like what I'm after (seriously, I can't believe my google-fu sucks this badly!).
    Is there a simple way of doing it? The only thing that I've found that looks vaguely relevant is "declare default namespace...." but I'm not sure that that's the correct thing to use, or if it is, how I'm supposed to reference it when populating the attribute value.

  • Extracting elements from an xml string - org.apache.xerces.dom.DeferredText

    Hello all,
    I am new to xml, and I thought I had a handle on things until I got this problem...I am getting an xml string from the body of an e-mail message, and then I am trying to extract elements out of it. Here is an example xml string:
    <?xml version="1.0" encoding="UTF-8"?>
    <filterRoot>
       <filter action="MOVE" bool="AND" name="My Saved Filter" target="Deleted Items">
          <condition attribute="TO" bool="AND" contains="CONTAINS">
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
          </condition>
       </filter>
    </filterRoot>I am trying to extract the <filter> element out and store it into a Vector of Elements (called, not surprisingly, filters). However, I am getting a class cast exception:
    java.lang.ClassCastException: org.apache.xerces.dom.DeferredTextImplIt is being called from where I trying to extract the <filter> in this way:
            filterRoot = doc.getDocumentElement(); // get topmost element
            NodeList list = filterRoot.getChildNodes();
            Vector newFilters = new Vector();
            debug("There are "+list.getLength()+" filters in document");
            for(int i=0; i<list.getLength(); i++) {
                Node n = list.item(i);
                debug("Node "+i+" getNodeValue() is "+n.getNodeValue());
                Element temp = (Element)n;
                newFilters.add(temp);
            }Perhaps my question is, how do I correctly get hold of the <filter> node so that I may cast it as an Element?
    thanks,
    Riz

    Yes, I already knew that it is not a bug.
    But, I got next step problem.
    I put "false" to "include-ignorable-whitespace" feature in xerces parser.
    But, I still found unnecessary TextNodes in my parser object.
    Feature link : http://xerces.apache.org/xerces-j/features.html.
    I use xerces-2_8_0.
    DOMParser parser = new DOMParser();
    parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace", false);
    parser.parse(inputSource);
    document = ps.getDocument();
    System.out.println(document.getDocumentElement().getChildNodes().length()); // still wrong lengthIs tehre any example of usage this feature?
    What is default defination of white-space "\n "(enter with one space) or " "(juz white space) or something else?
    Thanks,

  • How To Remove Empty Node From Source XML

    Hi,
    How can I remove an empty node from the source xml in a XSLT mapping.
    For e.g. If the source xml is like:
    <SRC>
    <Node1>SAP</Node2>
    <Node2/>
    <Node3>XI</Node3>
    </SRC>
    Then the xml should become:
    <SRC>
    <Node1>SAP</Node2>
    <Node3>XI</Node3>
    </SRC>
    I need to do this because the output of my XSLT mapping is showing blank spaces for each blank node.
    Thanks,
    Abhishek.

    Use <xsl:if>
    Or else you may find different options here
    http://www.dpawson.co.uk/xsl/sect2/N3328.html#d4804e304
    Regards,
    Prateek

  • How can I use DOM to copy Nodes between different XML Document ?

    Can I copy one Node or Element from one XML Document to another Document by DOM ?
    Because I use the Xerces , but it is not work if I want to copy Node between different Document, or I am doing something wrong. Anyone can help me , I will deeply appreciated !!

    check out the importNode() method of Document.

  • How to join tables from different databases (DBLink/DB connection )

    Hello,
    i have an issue and i hope you could help me to solve it. My problem is: I want to create native sql select which joins two tables from different DB (both of them are ORACLE, one of them internal, another one - external). I have found several notes and posts, but without any success. Db connection exists in dbcon table, so this part of my problem has been solved.
    I would like something like that:
    select * from table1@xxx inner join table2.
    i can not split this select into two separate ones, because both tables store over 30 mln. entries and i do not want to create any copies of them.
    Br,
    dez

    Hi,
    you might need to create a DB-Link on DB level and use EXEC SQL.
    Lots of stuff on google about this, like
    Oracle DBLink ( external database )
    Volker

  • How to "join" data from different SyncBO's within MAM?

    Hi,
    Have anyone tried "joining" the data from different SyncBO's into one in a custom MAM application?  For example, the SyncBO MAM30_30 (Functional Location) has references to MAM30_016 (Catalog + Code Groups).  Is there an easy way to display all of the related information together, instead of first looping through objects from MAM30_030, then for each individual object, loop through a list of MAM30_016? 
    Basically, the application that we're working with has 3000+ Functional Locations, so we are looking for a way to join the data and display them as one object to improve performance.
    Many thanks!
    Jeffrey

    Thanks Norbert.  Unfortunately, we cannot create new Syncbo's, as we have limited access to that R/3 backend.
    Basically, what we want to do is customize the MAM bit so that it can display the Tech Obj List with all its codes and children item syncbo's, instead of having the user click on the link to see more info.  We would like to do this without having to loop through the child sync bo's.
    Many thanks!

  • Updating an oracle table with data from an xml string

    Hi - I need help with the following problem:
    We have a table in the database with a field of xml type. We are going to take each string that gets inserted into the xml type field in the 'xml table' and parse the data into another oracle table with corresponding fields for every element.
    once the record gets inserted into the 'real table' the user might want to update this record they will then insert another record into the 'xml table' indicating an update(with a flag) and then we need to update the 'real table' with the updated values that have been sent in.
    The problem that I am having is that I do not know how to create this update statement that will tell me which fields of the table need to be updated.(only the fields that need to be updated will be in the xml string in the 'xml table').
    Please help me with this - ASAP!

    Are you wanting to upload the file through an Oracle Form or just upload a file? If it isn't via forms, then you should probably post your question here: {forum:id=732}
    You also should post the version of Forms, Database, etc...
    As far as uploading files via a text file, I personally like to use Oracle External Tables even in Forms. You can Google that and there is plenty of information. If you search this forum, then you will see lots of people use UTL_FILE in forms, but you can Google that also for more information.

  • How to use Xpath to query elements loaded from different xml docs?

    I have a big DBLP XML doc (95mb), to load into the container, i splitted the doc into many small xml docs by the publication types, such as articles, books, inproceedings, etc.
    I tried to use xpath query such as
    query 'collection()/dblp[article/author]/book[title]'
    I got empty answers.
    but if i use XQuery such as
    query 'let $r:=collection()/dblp,$a :=$r/inproceedings/author
    for $l2 in $r/book
    where $a and $l2/title
    return <result> {$l2}{$a}</result>'
    i got answers. However, if i remove {$a} from the return clause, i still got empty answers.
    is there any problem with my Xpath query and flwor Xquery?
    regards,
    xiaoying

    Hi John,
    Following is the procedure i have used to load the xml docs (after the indexes have been created):
    private static void loadXmlFiles(File path2DbEnv,String theContainer, File file) throws Throwable {
         //Open a container in the db environment
              XmlManager theMgr = null;
              XmlContainer openedContainer = null;
              myDbEnv env;
              try {
              env = new myDbEnv(path2DbEnv);
         theMgr = new XmlManager(env.getEnvironment(), new XmlManagerConfig());
         //use node container
         theMgr.setDefaultContainerType(XmlContainer.NodeContainer);
                   try{
                   openedContainer = theMgr.createContainer(theContainer);
                   }catch (XmlException e){
                        //if the container alreay exist, then open it;     
                        openedContainer = theMgr.openContainer(theContainer);
              //Get an update context.
              XmlUpdateContext updateContext = theMgr.createUpdateContext();
                   String theFile = file.toString();
                   String docName=file.getName();
              //Get the input stream.
              XmlInputStream theStream = theMgr.createLocalFileInputStream(theFile);
              System.out.println("Adding " + theFile + " to container " +
                             theContainer);
         //     Do the actual put
              openedContainer.putDocument(docName, // The document's name
              theStream, // The actual document.
              updateContext, // The update context
         //     (required).
              null); // XmlDocumentConfig object
              System.out.println("done.");
              //XmlException extends DatabaseException, which in turn extends Exception.
              // Catching Exception catches them all.
              } catch (XmlException e){
                   System.err.println("Error loading files into container " + theContainer);
                   System.err.println(" Message: " + e.getMessage());
                   //In the event of an error, we abort the operation
                   // The database is left in the same state as it was in before
                   // we started this operation.
                   throw e;
              finally {
              cleanup(theMgr, openedContainer);
    Unfortunately, i waited for around 20 hours 148mb doc was not loaded; so i gave up.
    Could you please give me some suggestions on how to load the large doc efficiently ? thanks.
    regards,
    xiaoying

  • Can we join table from different schema?

    Hi
    All,
    I have a SYS schema and MED schema. Now, I want to join DBA_USERS tables from SYS schema to EMPLOYEE table from MED schema to get an username. i am using following query but it's not working.
    select username,empl_userid,empl_nm_lst,empl_nm_fst from sys.dba_users db, med.employee emp where db.username = emp.empl_userid;
    Thanks,
    vishal

    g8 it is working now I just modify my query to make user name in upper case and then compare..
    select username,empl_userid,empl_nm_lst,empl_nm_fst from sys.dba_users db, med.employee emp where db.username = upper(emp.empl_userid);
    before that it was returning nothing..
    thanks for your help ... awesome..
    vishal
    Edited by: vishal patel on Sep 29, 2008 2:39 PM
    Edited by: vishal patel on Sep 29, 2008 2:40 PM

  • Join resuslt from different table

    I have table A:
    col 1 | Col 2
    AC11 AC21
    and table B:
    col 1 | Col 2
    BC11 BC21
    I need a select statement that'll return
    RESULT:
    AC11 | AC12 | BC11 | BC12
    is this possible?

    Continuing with my above post:
    But if there are more then 1 rows in each table then there will be a problem so a common field (foreign key) will be required for proper results using join.
    with table1 as (select 'AC11' col1, 'AC21' col2
                    from dual
                    union
                    select 'AC111' col1, 'AC211' col2
                    from dual),
    table2 as (select 'BC11' col1, 'BC21' col2
                    from dual
               union
               select 'BC111' col1, 'BC211' col2
                    from dual)
                    select table1.col1, table1.col2, table2.col1, table2.col2
                    from table1, table2
    COL1  COL2  COL1_ COL2_
    AC11  AC21  BC11  BC21
    AC11  AC21  BC111 BC211
    AC111 AC211 BC11  BC21
    AC111 AC211 BC111 BC211
    4 rows selected.Instead of 2 the output will be 4 records as there is no JOIN condition.
    Best Regards
    Arif Khadas

  • Map node from different View Container

    hi all,
    i have a question about WDA. In case i have 3 view controllers: V_MAIN, V_A, and V_B. This program lets the user to fill out the form on V_A and V_B. V_MAIN has view containers embedded by V_A and V_B.
    If i want an application to submit the form by click the Submit button on V_MAIN. The button has an action to send the parameters which fetch from V_A and V_B to do something further.
    I've tried to declare the variable by
    data: lr_v_a type if_v_a=>element_node.
    the system shows an error "The type if_v_a=>element_node. is unknown"
    Do you guys have any ideas about this? Please share me then.
    Hope you can figure out what I'm saying. Thanks in advance.
    Peerasit

    Hi...
    Use Global Component controller for all the view your using.... so that any time if you want data.... you can access it from the component controller...... try to use always global........
    so if you click submit and want to do something further..... you can get the values from component controller and pass it to the next process..... its simple.....
    Hope this will help you.....
    Thanks & regards
    Raja

  • Deleting Nodes from XML Tree (JTree)

    I have created a XML Tree(extended from JTree) using XNodes ( extended from DefaultMutableTreeNode)
    After some insertions, i need to delete certain nodes from the XML Tree.. but after deletion, XNode will be null.
    subroutine is as follows...
    appreciates any advice
    Thanx
    private XNode RemoveExtraNode( XNode xNode ){
    int child;
    String nodeType;
    XNode childNode=null;
    if ( (child=xNode.getChildCount() ) > 0){
    for(int i=0;i<child;i++){
    childNode=(XNode)xNode.getChildAt(i);          
         nodeType = childNode.getType();
         if(nodeType.equals("DTD") )
         childNode.removeFromParent();
    }//end for (int i=1;i<child;i++)
    }//endif((child=xNode.getChildCount())!=0)
    return xNode;     
    }//RemoveExtraNode

    Hi IKEDA
    Thanx for the reply.
    I have tried xNode.remove(childNode) b4 and it still return a null JTree.
    Anyway fyi i discover i can delete last child of xNode and return the correct java tree. therefore to delete a node of my choice i simply insert its next sibling nodes in its place and delete that particular node when it becomes the last child.

Maybe you are looking for

  • Can't get albums/songs in correct order!!! (11.1.3)

    I can't get songs and albums to order correctly on my iPod. All but one album has the correct song order on iTunes on my laptop and they are all ordered by artist/year on iTunes, I can't get that ordering method to transfer to the iPod. And on half t

  • I cannot delete photos in iphoto

    Suddenly I am unable to delete photos in iphoto with either the delete button, dragging to trash, or clicking on the trash icon. I am now ONLY able to delete by holding down option + command + delete buttons at the same time. I've combed these archiv

  • Turn horizontal layout to vertical when you place vertical photograph

    Hi I am Sathya Murthy Basically I am photographer I want to place photos in layers in a single psd file for  this i have found a scripting from the website http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html which is working fine. But the pro

  • Why is an NTFS partition not mounting on Powerbook & how to get it to

    I have a new external portable (bus powered) Maxtor Mini III drive that is formatted NTFS for Windows, My powerbook 1.5gHz cannot mount it. Disk utility recognizes the drive by name, but shows no volume and the erase tab is all gray. It mounts read a

  • Differennce b/w workarea and header line

    can any one tell me the difference between workarea and header line.