XML Node Selection in Foreach Loop

Good Morning,
I am just building up my first SSIS-package which uses a web service as data source. Now, that I managed the data to be processed using a Foreach Loop, I am wondering how the loop reacts when the sequence of teh nodes changes, or a certain node is not present.
In the "Foreach Loop Editor - Variable Mappings" I have mapped the variables (as they are at the moment) to the certain index (as they appear at the moment), but again: what if an additional nodes comes in? Isn't there a way to explicitly tell the
system to set variable ABC with node ABC, DEF with node DEF and so on... 

Good Morning,
am copying in the reply, I receive from the web service which is then stored in the variable:
<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n
<DataSet>\r\n
<xs:schema id=\"NewDataSet\" xmlns=\"\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\r\n
<xs:element name=\"NewDataSet\" msdata:IsDataSet=\"true\" msdata:UseCurrentLocale=\"true\">\r\n
<xs:complexType>\r\n
<xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n
<xs:element name=\"FLT\">\r\n
<xs:complexType>\r\n
<xs:sequence>\r\n
<xs:element name=\"CARRIER\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"FLIGHT\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"DEP\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"DES\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"DATE_LOC\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"ETD_LOC\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"ETA_LOC\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"DATE_UTC\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"ETD_UTC\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"ETA_UTC\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"PAX_C\" type=\"xs:short\" minOccurs=\"0\" />\r\n
<xs:element name=\"PAX_Y\" type=\"xs:short\" minOccurs=\"0\" />\r\n
<xs:element name=\"SEAT_C\" type=\"xs:short\" minOccurs=\"0\" />\r\n
<xs:element name=\"SEAT_Y\" type=\"xs:short\" minOccurs=\"0\" />\r\n
<xs:element name=\"PAX_EX\" type=\"xs:short\" default=\"0\" minOccurs=\"0\" />\r\n
<xs:element name=\"PAX_CHD_C\" type=\"xs:short\" default=\"0\" minOccurs=\"0\" />\r\n
<xs:element name=\"PAX_CHD_Y\" type=\"xs:short\" default=\"0\" minOccurs=\"0\" />\r\n
<xs:element name=\"PAX_INF\" type=\"xs:short\" default=\"0\" minOccurs=\"0\" />\r\n
</xs:sequence>\r\n
</xs:complexType>\r\n
</xs:element>\r\n
<xs:element name=\"FLTRem\">\r\n
<xs:complexType>\r\n
<xs:sequence>\r\n
<xs:element name=\"CARRIER\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"FLIGHT\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"DEP\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"DES\" type=\"xs:string\" minOccurs=\"0\" />\r\n
<xs:element name=\"DATE_UTC\" type=\"xs:string\" minOccurs=\"0\" />\r\n
</xs:sequence>\r\n
</xs:complexType>\r\n
</xs:element>\r\n
</xs:choice>\r\n
</xs:complexType>\r\n
</xs:element>\r\n
</xs:schema>\r\n
<diffgr:diffgram xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\" xmlns:diffgr=\"urn:schemas-microsoft-com:xml-diffgram-v1\">\r\n
<NewDataSet>\r\n
<FLT diffgr:id=\"FLT1\" msdata:rowOrder=\"0\">\r\n
<CARRIER>XY</CARRIER>\r\n
<FLIGHT>1234</FLIGHT>\r\n
<DEP>ABC</DEP>\r\n
<DES>DEF</DES>\r\n
<DATE_LOC>11.03.2014 00:00:00</DATE_LOC>\r\n
<ETD_LOC>30.12.1899 08:30:00</ETD_LOC>\r\n
<ETA_LOC>30.12.1899 12:15:00</ETA_LOC>\r\n
<DATE_UTC>11.03.2014 00:00:00</DATE_UTC>\r\n
<ETD_UTC>30.12.1899 07:30:00</ETD_UTC>\r\n
<ETA_UTC>30.12.1899 12:15:00</ETA_UTC>\r\n
<PAX_C>0</PAX_C>\r\n
<PAX_Y>120</PAX_Y>\r\n
<SEAT_C>0</SEAT_C>\r\n
<SEAT_Y>210</SEAT_Y>\r\n
<PAX_EX>0</PAX_EX>\r\n
<PAX_CHD_C>0</PAX_CHD_C>\r\n
<PAX_CHD_Y>0</PAX_CHD_Y>\r\n
<PAX_INF>0</PAX_INF>\r\n
</FLT>\r\n
<FLT diffgr:id=\"FLT2\" msdata:rowOrder=\"1\">\r\n
<CARRIER>YZ</CARRIER>\r\n
<FLIGHT>4567</FLIGHT>\r\n
<DEP>DEF</DEP>\r\n
<DES>GHI</DES>\r\n
<DATE_LOC>11.03.2014 00:00:00</DATE_LOC>\r\n
<ETD_LOC>30.12.1899 13:10:00</ETD_LOC>\r\n
<ETA_LOC>30.12.1899 18:35:00</ETA_LOC>\r\n
<DATE_UTC>11.03.2014 00:00:00</DATE_UTC>\r\n
<ETD_UTC>30.12.1899 13:10:00</ETD_UTC>\r\n
<ETA_UTC>30.12.1899 17:35:00</ETA_UTC>\r\n
<PAX_C>0</PAX_C>\r\n
<PAX_Y>203</PAX_Y>\r\n
<SEAT_C>0</SEAT_C>\r\n
<SEAT_Y>210</SEAT_Y>\r\n
<PAX_EX>0</PAX_EX>\r\n
<PAX_CHD_C>0</PAX_CHD_C>\r\n
<PAX_CHD_Y>0</PAX_CHD_Y>\r\n
<PAX_INF>0</PAX_INF>\r\n
</FLT>\r\n
</NewDataSet>\r\n
</diffgr:diffgram>\r\n
</DataSet>

Similar Messages

  • ForEach Loop - Parsing XML subgroup into Variables

    Hi all,I am designing a new ETL process using SSAS.
    We have a controller package which receives an XML string at run time into a variable called BatchRequest :-
    <Batch>
    <Request>
    <Name>Filemon</Name>
    <Params>
    <filepaths>
    <Sourcepath>d:\temp</Sourcepath>
    <Destpath>D:\temp2</Destpath>
    <Archivename>\Archive</Archivename>
    </filepaths>
    </Params>
    </Request>
    </Batch>
    The Batch can contain a number of Requests and a ForEach Loop is used to parse the text for the Name node and the text for the Params Node into variables RequestName and RequestParams respectively.
    however, what I want to be able to do is to take the text for <name> into Requestname but take the entire XML sub string for <Params> into RequestParams.
    At the moment I get the text only (e.g. d:\tempd:\temp2\Archive).
    The Requestname is used by an XML task within the ForEach loop to retrieve full package path details from an external config file, and hence it only needs to be a keyword.
    I played with the idea of including <Params> as a subnode for <Name>, only populating RequestName in the loop parser and then having an XML task which would parse the related parameter string, but i don't know how to tell the XML task that I
    want the parameter string where the <Name> is Filemon (in this example).
    Can anyone give me some suggestions or pointers?
    Thanks
    Iain
    Iain

    Hi idcowden,
    Glad to hear that you have resolved the issue on your own. Thank you for sharing the solution.
    Regards,
    Mike Yin
    TechNet Community Support

  • Counting of XML nodes based on a condition

    Hello,
    I have following XML with me:
    <?xml version="1.0" encoding="utf-8" ?>
    <Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">
         <Rowset>
              <Columns>
                   <Column Description="Material Number" MaxRange="1" MinRange="0" Name="MAT" SQLDataType="1" SourceColumn="MAT"/>
                   <Column Description="Plant" MaxRange="1" MinRange="0" Name="WER" SQLDataType="1" SourceColumn="WER"/>
                   <Column Description="Storage Location" MaxRange="1" MinRange="0" Name="LGO" SQLDataType="1" SourceColumn="LGO"/>
                   <Column Description="" MaxRange="1" MinRange="0" Name="TANK" SQLDataType="1" SourceColumn="TANK"/>
                   <Column Description="Batch Number" MaxRange="1" MinRange="0" Name="BATCH" SQLDataType="1" SourceColumn="BATCH"/>
                   <Column Description="Valuated Unrestricted-Use Stock" MaxRange="1" MinRange="0" Name="CLABS" SQLDataType="8" SourceColumn="CLABS"/>
                   <Column Description="Quality Stock" MaxRange="1" MinRange="0" Name="CINSM" SQLDataType="8" SourceColumn="CINSM"/>
              </Columns>
              <Row>
                   <MAT>111</MAT>
                   <WER>US</WER>
                   <LGO>T1</LGO>
                   <TANK>T100</TANK>
                   <BATCH>2020</BATCH>
                   <CLABS>0</CLABS>
                   <CINSM>19.000</CINSM>
              </Row>
              <Row>
                   <MAT>222</MAT>
                   <WER>US</WER>
                   <LGO>T1</LGO>
                   <TANK>T100</TANK>
                   <BATCH>1010</BATCH>
                   <CLABS>1000000.000</CLABS>
                   <CINSM>0</CINSM>
              </Row>
              <Row>
                   <MAT>333</MAT>
                   <WER>US</WER>
                   <LGO>T1</LGO>
                   <TANK>T100</TANK>
                   <BATCH>1010</BATCH>
                   <CLABS>1000000.000</CLABS>
                   <CINSM>0</CINSM>
              </Row>
              <Row>
                   <MAT>444</MAT>
                   <WER>US</WER>
                   <LGO>T1</LGO>
                   <TANK>T100</TANK>
                   <BATCH>1010</BATCH>
                   <CLABS>1000000.000</CLABS>
                   <CINSM>0</CINSM>
              </Row>
              <Row>
                   <MAT>555</MAT>
                   <WER>US</WER>
                   <LGO>T1</LGO>
                   <TANK>T100</TANK>
                   <BATCH>1010</BATCH>
                   <CLABS>1000000.000</CLABS>
                   <CINSM>0</CINSM>
              </Row>
              <Row>
                   <MAT>666</MAT>
                   <WER>US</WER>
                   <LGO>T1</LGO>
                   <TANK>T100</TANK>
                   <BATCH>1010</BATCH>
                   <CLABS>1000000.000</CLABS>
                   <CINSM>0</CINSM>
              </Row>
         </Rowset>
    </Rowsets>
    Now, I want my select statement to return following based on a count of XML node:
    select
    If count(/Rowsets/Rowset/Row[CLABS > 0]/BATCH) > 1 then 'Mixing'
    else if count(/Rowsets/Rowset/Row[MAT = "Parameter Value"]/MAT) = 0 then 'None'
    else 'Other'
    from Tablename TT where TANK = something and Plant = something
    How can I achive this using Oracle query? I can do it using SQL server but not getting the correct syntax for Oracle :(

    I got the answer on my own :)
    SELECT CASE WHEN count(RW."CountofBATCH") > 1 then 'Mixing'
    WHEN count(RW."CountofMAT") = 0 then 'None'
    ELSE 'Other'
    END
    FROM TABLENAME TT, XMLTable('/Rowsets/Rowset/Row' PASSING TT.XMLCOL
    COLUMNS
    "CountofBATCH" PATH '/Row[CLABS > 0]/BATCH',
    "CountofMAT" PATH '/Row[MAT = "[Parameter Value]"]/MAT'
    ) AS RW
    where
    some condition

  • Get xml node name in loop

    Hi,
    i hv a procedure to get the xml data's(values of the xml) from a clob. in a table.it works fine the parent tags but if the same tag is there for two times then i am not able to loop it because i dont know the tag name for which the loop should be run.
    to be clear.
    <root>
    <tag1>value1
    </tag1>
    <tag1>value2
    </tag1>
    </root>
    i need to run some fns for each node value so i need to loop for each node having same value pls help me to get the node name.

    pls help me to get the node name.Still not sure what you are actually trying to accomplish, but maybe this helps:
    SQL> set echo on
    SQL> col node form a30
    SQL> with xml as (
    select xmltype('<root>
    <tag1>value1
    </tag1>
    <tag1>value2
    </tag1>
    </root>') xml from dual)
    select t.column_value.getrootelement() node
      from xml xml,
    table (xmlsequence(xml.xml.extract('//*'))) t
    NODE                         
    root                         
    tag1                         
    tag1                         
    3 rows selected.

  • Select XML Node by a specific attribute value

    I am newbie for LifeCyle.
    This might be an easy question, but it really got me here.
    I am trying bind xml data into a Drop-Down List. The databinding is working fine, but I would like to have more specific node selected from the xml file by using a attribute value.
    for example Code in AS 3.0
    root.node.(@id=="1").subNode
    How could i do the same thing in LifeCycle Designer 8.0
    Thank you in advance!!!

    there's no native method for this, maybe you should create some functions for this. just like
    private function setAttribute(node:XML, name:String, value:String, index:int = -1):void
        var attrs:XMLList = node.attributes().copy(),
            l:int = attrs.length();
        if(index == -1 || index > l - 1)
            node.@[name] = value;
        else
            delete node.@*;
            var idx:int = 0;
            for (var i:int = 0; i < l + 1; i++)
                if(i == index)
                    node.@[name] = value;
                else
                    var attr:XML = attrs[idx];
                    node.@[attr.name()] = attr.toString();
                    idx++;
    and use it like this:
    setAttribute(myNode, "otherAttribute", "abc", 0);

  • GET XML NODE NAME FOR LOOPING

    Hi,
    i hv a procedure to get the xml data's(values of the xml) from a clob. in a table.it works fine the parent tags but if the same tag is there for two times then i am not able to loop it because i dont know the tag name for which the loop should be run.
    to be clear.
    <root>
    <tag1>value1
    </tag1>
    <tag1>value2
    </tag1>
    </root>
    i need to run some fns for each node value so i need to loop for each node having same value pls help me to get the node name.

    You can simply alter get xml node name in loop to return a count on just the node you are looking for. Not sure why you need to know the count when you can have the logic iterate through the nodes for you, either as an XMLType or a DOMDocument (see nodelist).

  • Get xml node name from clob in loop

    Hi,
    i hv a procedure to get the xml data's(values of the xml) from a clob. in a table.it works fine the parent tags but if the same tag is there for two times then i am not able to loop it because i dont know the tag name for which the loop should be run.
    to be clear.
    <root>
    <tag1>value1
    </tag1>
    <tag1>value2
    </tag1>
    </root>
    i need to run some fns for each node value so i need to loop for each node having same value pls help me to get the node name.

    You can simply alter get xml node name in loop to return a count on just the node you are looking for. Not sure why you need to know the count when you can have the logic iterate through the nodes for you, either as an XMLType or a DOMDocument (see nodelist).

  • The property XMLDataVariable on the XML Source was empty - Case Foreach Loop Container

    I have very simple XML source and OLE DB Source in Foreach Loop Container,
    but seem to get error, because XML Source cannot find the XML.
    "Error at Data Flow Task. The property XMLDataVariable on the XML Source was empty"
    Variables:
    FileExtention = *.xml
    FilePath =
    FolderPath = C:\Customer\XML
    XML Source:
    Data Access mode = XML file from variable
    Variable name = User::filePath
    Foreach Loop Container:
    Enumerator = Foreach File Enumerator
    Expression-Directory = @User:FolderPath
    Expression-FileSpec = @User::FileExtension
    Enumerator Folder = C:\Customer\XML
    Files = *.xml
    Variable mapping-User::FilePath = 0
    Kenny_I

    Have you filled the variable (filePath) with a default value? Otherwise the XML Source cannot validate. Alternative is look for a property "DelayValidation". In most cases this is a property of the connection manager, but you're not using
    one for the xml source....
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Oracle Looping through XML nodes

    Hi,
    I have this XML which i m getting as response from a webservice. i need to loop through nodes and i m not sure how to go about it. i have done example using dbms_xmldom but i m literally stuck. this is the xml here i need to loop through
    statuslognotes for one enquiry, there may be multiple statuslognotes and need to insert into database....
    i also need to check for multiple updatedenquiry and if thats got statuslognotes....i hope you get me.
    <ProcessOperationsResult xmlns="http://www.abc.co.uk/schema/am/connector/webservice" >
    <Response SchemaVersion="1.4" xmlns="" >
    <OperationResponse>
    <GetEnquiryStatusChangesResponse>
    <UpdatedEnquiry>
    <EnquiryNumber>104</EnquiryNumber>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ExternalSystemReference>195</ExternalSystemReference>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1224</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>BBB</AssignedOfficerCode>
    <AssignedOfficerName>Testing</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>AAA</LoggedByUserId>
    </EnquiryStatusLog>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1225</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>DEF</AssignedOfficerCode>
    <AssignedOfficerName>Srinivas</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>AAA</LoggedByUserId>
    </EnquiryStatusLog>
    </UpdatedEnquiry>
    <UpdatedEnquiry>
    <EnquiryNumber>105</EnquiryNumber>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ExternalSystemReference>196</ExternalSystemReference>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1226</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>Test</AssignedOfficerCode>
    <AssignedOfficerName>SS</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>BS</LoggedByUserId>
    </EnquiryStatusLog>
    </UpdatedEnquiry>
    </GetEnquiryStatusChangesResponse>
    </OperationResponse>
    </Response>
    </ProcessOperationsResult>
    Any help appreciated....as i m new to this XPATH stuff in oracle.
    Cheers
    S

    hi,
    i have written this stored procedure, but i m sure this is not perfect. i want someone to help me out with this.
    CREATE OR REPLACE procedure ParseXML as
    l_xml XMLTYPE;
    l_value VARCHAR2(10);
    SCHEMALIST_DOM DBMS_XMLDOM.DOMDOCUMENT;
    SCHEMA_NODELIST DBMS_XMLDOM.DOMNODELIST;
    SCHEMA_NODELIST_SUB DBMS_XMLDOM.DOMNODELIST;
    SCHEMA_NODE DBMS_XMLDOM.DOMNODE;
    SCHEMA_sub_XPATH VARCHAR2(256);
    SCHEMA_XPATH VARCHAR2(256);
    CHILD_XPATH VARCHAR2(256);
    SOURCE_PATH VARCHAR2(256);
    XPATH_INDEX number(2);
    XPATH_sub_INDEX number(2);
    NODE_VALUE VARCHAR2(256);
    Statcode VARCHAR2(256);
    Statname VARCHAR2(256);
    Officer VARCHAR2(256);
    BEGIN
    l_xml := XMLTYPE.createXML('<ProcessOperationsResult xmlns="http://www.abc.co.uk/schema/am/connector/webservice">
    <Response SchemaVersion="1.4" xmlns="">
    <OperationResponse>
    <GetEnquiryStatusChangesResponse>
    <UpdatedEnquiry>
    <EnquiryNumber>104</EnquiryNumber>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ExternalSystemReference>195</ExternalSystemReference>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1224</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>TEST</AssignedOfficerCode>
    <AssignedOfficerName>test</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>BS</LoggedByUserId>
    </EnquiryStatusLog>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1225</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>DEF</AssignedOfficerCode>
    <AssignedOfficerName>SSi</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>SBS</LoggedByUserId>
    </EnquiryStatusLog>
    </UpdatedEnquiry>
    <UpdatedEnquiry>
    <EnquiryNumber>105</EnquiryNumber>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ExternalSystemReference>196</ExternalSystemReference>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1226</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>TEST</AssignedOfficerCode>
    <AssignedOfficerName>test</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>SBS</LoggedByUserId>
    </EnquiryStatusLog>
    </UpdatedEnquiry>
    </GetEnquiryStatusChangesResponse>
    </OperationResponse>
    </Response>
    </ProcessOperationsResult>');
    SCHEMALIST_DOM := DBMS_XMLDOM.newDOMDocument(L_XML);
    SCHEMA_NODELIST := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(SCHEMALIST_DOM,'GetEnquiryStatusChangesResponse');
    SCHEMA_NODELIST_SUB := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(SCHEMALIST_DOM,'/UpdatedEnquiry/EnquiryStatusLog');
    FOR i in 0 .. (DBMS_XMLDOM.GETLENGTH(SCHEMA_NODELIST) - 1) LOOP
    XPATH_INDEX := i+1;
    FOR j in 0 .. (DBMS_XMLDOM.GETLENGTH(SCHEMA_NODELIST_SUB) - 1) LOOP
    XPATH_SUB_INDEX := J+1;
    SCHEMA_SUB_XPATH := '/GetEnquiryStatusChangesResponse/UpdatedEnquiry[' || XPATH_INDEX || ']/EnquiryStatusLog[' || XPATH_sub_INDEX || ']/';
    --dbms_output.put_line(SCHEMA_SUB_XPATH);
    CHILD_XPATH := SCHEMA_SUB_XPATH || 'EnquiryStatusCode/text()';
    dbms_output.put_line('child path text ' || child_XPATH);
    DBMS_XSLPROCESSOR.VALUEOF(DBMS_XMLDOM.MAKENODE(SCHEMALIST_DOM),CHILD_XPATH, Statcode);
    CHILD_XPATH := SCHEMA_SUB_XPATH || 'EnquiryStatusName/text()';
    DBMS_XSLPROCESSOR.VALUEOF(DBMS_XMLDOM.MAKENODE(SCHEMALIST_DOM),CHILD_XPATH, Statname);
    CHILD_XPATH := SCHEMA_SUB_XPATH || 'AssignedOfficerCode/text()';
    DBMS_XSLPROCESSOR.VALUEOF(DBMS_XMLDOM.MAKENODE(SCHEMALIST_DOM),CHILD_XPATH, Officer);
    dbms_output.put_line('EnquiryStatusCode => "' || Statcode || '",');
    dbms_output.put_line('EnquiryStatusname => "' || Statname || '",');
    dbms_output.put_line('AssignedOfficerCode => "' || Officer || '",');
    end loop;
    --GetEnquiryStatusChangesResponse/UpdatedEnquiry[2]
    schema_xpath := '/GetEnquiryStatusChangesResponse/UpdatedEnquiry[' || XPATH_INDEX || ']/EnquiryStatusLog['|| XPATH_INDEX || ']/' ;
    CHILD_XPATH := SCHEMA_XPATH || 'EnquiryStatusCode/text()';
    dbms_output.put_line('another node text ' || child_XPATH);
    DBMS_XSLPROCESSOR.VALUEOF(DBMS_XMLDOM.MAKENODE(SCHEMALIST_DOM),CHILD_XPATH, Statcode);
    end loop;
    end;
    Basically i may just get one UpdatedEnquiry record with multiple EnquiryStatusLog (changes),
    I need to get the EnquiryStatusLog nodes and create a insert stmt with the Enquiry Number.
    and if theres multiple <UpdatedEnquiry> nodes, i need the same thing done.
    Hope i make sense here.....
    Can someone help
    Cheers
    S

  • Modifying child node instances in the foreach loop

    Dear All,
    I have implemented a custom BO with a child node. On executing an action on the root node, i want to loop through the associated child nodes and create an SAP standard BO instance for every child node instance.
    I then want to associate the ID of the standard BO created to a field in the child node.How do i modify the child node instance in this loop?
    Any pointers would be really appreciated.
    Thanks a lot for your help.
    - Kavya

    Hello Kavya,
    First you want to lopo over all child nodes
         ( var myChild in this.Child ) {
    Then you create the standard BO
         customer = Customer.Create();
    Now assign the InternalID to your Child ID
         myChild.ChildId = customer.InternalID;
    HTH,
        Horst

  • Xml nodes which are not meet the schema validation

    Hi All,
    Is there way to keep xml nodes which are not meet the schema validation ,so that i can send those failed records back to the Source Target.
    I thought to implement to adding validate in the ForEach loop.Any hints

    In Windows you hold down the Ctrl key while clicking on the nodes you want to select. Don't know the equivalent in other environments.

  • Xs:group refs and "ORA-30936: Maximum number (1) of XML nodes exceeded'

    We registered a subset of the IBM DITA schemas in Oracle XDB. These schemas contain a lot of xs:group definitions where references to these groups contain "minOccurs" and "maxOccurs" atttributes, for instance:
    <xs:group name="category">
    <xs:sequence>
    <xs:element ref="category"/>
    </xs:sequence>
    </xs:group>
    <xs:complexType name="metadata.class">
    <xs:sequence>
    <xs:group ref="audience" minOccurs="0" maxOccurs="unbounded"/>
    <xs:group ref="category" minOccurs="0" maxOccurs="unbounded"/>
    <xs:group ref="keywords" minOccurs="0" maxOccurs="unbounded"/>
    <xs:group ref="prodinfo" minOccurs="0" maxOccurs="unbounded"/>
    <xs:group ref="othermeta" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="mapkeyref" type="xs:string"/>
    <xs:attributeGroup ref="global-atts"/>
    <xs:attribute ref="class" default="- topic/metadata "/>
    </xs:complexType>
    When we create an instance document that contains more than one "category" element under the element "metadata" element, like:
    <metadata>
    <audience type="purchaser" othertype="" job="using" otherjob="" experiencelevel="general"/>
    <category/>
    <category/>
    </metadata>
    we get the error: ORA-30936: Maximum number (1) of 'category' XML node elements exceeded
    This error is not consistent with the schema and XML parsers like Xerces and the Oracle "XDK parser" think the instance is fine.
    When we skip the reference to the group and reference the element definition "category" directly the problem is gone:
    <xs:complexType name="metadata.class">
    <xs:sequence>
    <xs:group ref="audience" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="category" minOccurs="0" maxOccurs="unbounded"/>
    <xs:group ref="keywords" minOccurs="0" maxOccurs="unbounded"/>
    <xs:group ref="prodinfo" minOccurs="0" maxOccurs="unbounded"/>
    <xs:group ref="othermeta" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="mapkeyref" type="xs:string"/>
    <xs:attributeGroup ref="global-atts"/>
    <xs:attribute ref="class" default="- topic/metadata "/>
    </xs:complexType>
    In this case the problems for the other group references like "audience" remain.
    It looks like Oracle XDB doesn't honor the cardinality attributes "minOccurs" and "maxOccurs" on xs:group elements that are references. Does anyone experienced similar problems?
    Thanks,
    Maarten

    This sounds like bug 5204107. You'll need to open a tar with Oracle Support if you need a fix for this..
    It happens when a group is used once without a maxOccurs and then later with a maxOccurs.
    The workaround is 'in-line' the group before registering the XML Schema. This can be done as follows (assuming the group definition and reference are in the same XML Schema)..
    procedure expandGroup(xmlschema in out xmltype, groupName varchar2,xsdDirectory varchar2)
    is
      xsdSchemaPath varchar2(512);
      groupModel xmltype;
      sequenceModel xmlType := xmlType('<xsd:sequence ' || xdb_namespaces.XMLSCHEMA_PREFIX_XSD || '><xsd:sequence/></xsd:sequence>');
      maxOccursValue binary_integer;
    begin
      -- FInd the Group Definition
      if xmlSchema.existsNode('/xsd:schema//xsd:group[@ref="' || groupName || '"]',NAMESPACES) = 1 then
        if xmlSchema.existsNode('/xsd:schema/xsd:group[@name="' || groupName || '"]',NAMESPACES) = 1 then
          select extract
                   xmlSchema,
                   '/xsd:schema/xsd:group[@name="' || groupName || '"]',
                   NAMESPACES
            into groupModel
            from dual; 
        else
          dbms_output.put_line('xsdDirectory = ' || xsdDirectory);
          select PATH,
                 extract
                   CONTENTS,
                   '/xsd:schema/xsd:group[@name="' || groupName || '"]',
                   NAMESPACES
            into xsdSchemaPath, groupModel
            from (
                   select PATH, xdburitype(path).getXML() CONTENTS
                     from PATH_VIEW
                    where under_path(res,xsdDirectory) = 1
           where existsNode
                   CONTENTS,
                   '/xsd:schema/xsd:group[@name="' || groupName || '"]',
                   NAMESPACES
                 ) = 1;
           dbms_output.put_line('Resolved ' || groupModel.extract('/xsd:group/@name',NAMESPACES).getStringVal() || ' in Schema ' || xsdSchemaPath);
        end if;
        if groupModel.existsNode('/xsd:group/xsd:annotation',NAMESPACES) = 1 then
          select deleteXML
                   groupModel,
                   '/xsd:group/xsd:annotation',
                   NAMESPACES
            into groupModel
            from dual;
        end if;
        -- create a sequence that can be placed in-line in the XML Schema to replace the <group ref=""/>
        groupModel := groupModel.extract('/xsd:group/*',NAMESPACES);
        select updateXML
                 sequenceModel,
                 '/xsd:sequence/xsd:sequence',
                groupModel,
                 NAMESPACES
          into sequenceModel
          from dual;
        if xmlSchema.existsNode('/xsd:schema//xsd:group[@ref="' || groupName || '" and not(@maxOccurs)]',NAMESPACES) = 1 then
          select updateXML
                   xmlSchema,
                   '/xsd:schema//xsd:group[@ref="' || groupName || '" and not(@maxOccurs)]',
                  sequenceModel,
                   NAMESPACES
            into xmlSchema
            from dual;
        end if;
        select insertChildXML
                 sequenceModel,
                 '/xsd:sequence',
                 '@maxOccurs',
                 'unbounded',
                 NAMESPACES
          into sequenceModel
          from dual;
        if xmlSchema.existsNode('/xsd:schema//xsd:group[@ref="' || groupName || '" and @maxOccurs="unbounded"]',NAMESPACES) = 1 then
          select updateXML
                   xmlSchema,
                   '/xsd:schema//xsd:group[@ref="' || groupName || '" and @maxOccurs="unbounded"]',
                   sequenceModel,
                   NAMESPACES
            into xmlSchema
            from dual;
        end if;
        while xmlschema.existsNode('/xsd:schema//xsd:group[@ref="' || groupName || '"]',NAMESPACES) = 1 loop
          maxOccursValue := xmlSchema.extract('/xsd:schema//xsd:group[@ref="' || groupName || '"]/@maxOccurs').getNumberVal();
          select updateXML
                   sequenceModel,
                  '/xsd:sequence/@maxOccurs',
                   maxOccursValue,
                   NAMESPACES
            into sequenceModel
            from dual;
          select updateXML
                   xmlSchema,
                   '/xsd:schema//xsd:group[@ref="' || groupName || '" and @maxOccurs="' || maxOccursValue || '"]',
                   sequenceModel,
                   NAMESPACES
            into xmlSchema
            from dual;
        end loop;
      end if;
    end;
    --

  • 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" />

  • [Forum FAQ] How to calculate the total count of insert rows within a Foreach Loop Container in SSIS?

    Introduction
    We need to loop through all the flat files that have the same structure in a folder and import all the data to a single SQL Server table. How can we obtain the total count of the rows inserted to the destination SQL Server table?
    Solution
    We can use Execute SQL Task or Script Task to aggregate the row count increment for each iteration of the Foreach Loop Container. The following steps are the preparations before we add the Execute SQL Task or Script Task:
    Create a String type variable FilePath, two Int32 type variables InsertRowCnt and TotalRowCnt.
    Drag a Foreach Loop Container to the Control Flow design surface, set the Enumerator to “Foreach File Enumerator”, specify the source folder and the files extension, and set the “Retrieve file name” option to “Fully qualified”.
    On the “Variable Mappings” tab of the container, map the variable FilePath to the collection value.
    Drag a Data Flow Task to the container, in the Data Flow Task, add a Flat File Source, a Row Count Transformation, and an OLE DB Destination, and join them. Create a Flat File Connection Manager to connect to one of the flat files, and then configure the
    Flat File Source as well as the OLE DB Destination adapter. Set the variable for the Row Count Transformation to “User::InsertRowCnt”.
    Open the Property Expressions Editor for the Flat File Connection Manager, and set the expression of “ConnectionString” property to
    “@[User::FilePath]”.
    (I) Execute SQL Task Method:
    In the Control Flow, drag an Execute SQL Task under the Data Flow Task and join them.
    Create one or using any one existing OLE DB Connection Manager for the Execute SQL Task, set the “ResultSet” option to “Single row”, and then set the “SQLStatement” property to:
    DECLARE @InsertRowCnt INT,
                   @TotalRowCnt INT
    SET @InsertRowCnt=?
    SET @TotalRowCnt=?
    SET @TotalRowCnt=@InsertRowCnt+@TotalRowCnt
    SELECT TotalRowCnt=@TotalRowCnt
    On to parameter 1. 
    On the “Result Set” tab of the Execute SQL Task, map result 0 to variable “User::TotalRowCnt”.
    (II) Script Task Method:
    In the Control Flow, drag a Script Task under the Data Flow Task and join them.
    In the Script Task, select variable InsertRowCnt for “ReadOnlyVariables” option, and select variable TotalRowCnt for “ReadWriteVariables”.
    Edit the Main method as follows (C#):
    public void Main()
    // TODO: Add your code here
    int InsertRowCnt = Convert.ToInt32(Dts.Variables["User::InsertRowCnt"].Value.ToString()
    int TotalRowCnt = Convert.ToInt32(Dts.Variables["User::TotalRowCnt"].Value.ToString());
    TotalRowCnt = TotalRowCnt + InsertRowCnt;
    Dts.Variables["User::InsertRowCnt"].Value = TotalRowCnt;
    Dts.TaskResult = (int)ScriptResults.Success;
              Or (VB)
              Public Sub Main()
            ' Add your code here
            Dim InsertRowCnt As Integer =        
            Convert.ToInt32(Dts.Variables("User::InsertRowCnt").Value.ToString())
            Dim TotalRowCnt As Integer =
            Convert.ToInt32(Dts.Variables("User::TotalRowCnt").Value.ToString())
            TotalRowCnt = TotalRowCnt + InsertRowCnt
            Dts.Variables("User::TotalRowCnt").Value = TotalRowCnt
            Dts.TaskResult = ScriptResults.Success
           End Sub
    Applies to
    Microsoft SQL Server 2005
    Microsoft SQL Server 2008
    Microsoft SQL Server 2008 R2
    Microsoft SQL Server 2012
    Microsoft SQL Server 2014
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Hi ITBobbyP,
    If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
    If in this scenario, please refer to the following tips:
    The Foreach Loop container should be configured as shown below:
    Enumerator: Foreach ADO.NET Schema Rowset Enumerator
    Connection String: The OLE DB Connection String for the excel file.
    Schema: Tables.
    In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
    The connection string for Excel Connection Manager is the original one, we needn’t make any change.
    Change Table Name or View name to the variable Sheet_Name.
    If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
    http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Using XSLT to extract value of a XML node with namespace

    I have a XML source code here.
    <?xml version="1.0" encoding="utf-8" ?>
    <rss version="2.0" xmlns:job="http://www.pageuppeople.com">
      <channel>
        <title>SMH Jobs</title>
        <link>internalrecruitment.smhgroup.com.au/jobsrss.ashx?stp=di</link>
        <description>A listing of jobs available here</description>
        <item>
          <title>eCommerce Optimisation Advisor</title>
          <description>A new and exciting opportunity exists for an experienced eCommerce Advisor to join</description>
          <job:location PUReferenceID="3711">Sydney - Inner Suburbs & CBD</job:location>
        </item>
      </channel>
    </rss>
    I want to use XSLT to extract value of a XML node with namespace <job:location>, and the returned value should be string 'Sydney - Inner Suburbs & CBD'. I tried a few XSL code below, but failed with error or nothing was returned.
    <xsl:value-of select="job:location" disable-output-escaping="yes"/>
    <xsl:value-of select="job/location" disable-output-escaping="yes"/>
    <xsl:value-of select="job\location" disable-output-escaping="yes"/>
    <xsl:value-of select="location" disable-output-escaping="yes"/>
    This might be an easy question for you, but I would appreciate if anyone can help.

    Hi Suncorp IT Learner,
    We need to tell the XSLT that some elements are in another namespace. Copy the xmls declarations for the prefixes you need to use. Then use the xsl format as:
    <xsl: value-of select=”job:location/@PUReferenceID”/>
    In following issue, Chriztian has a good explanation:
    http://our.umbraco.org/forum/developers/xslt/33353-XSLT-reading-XML-attribute-value
    Thanks,
    Qiao Wei
    TechNet Community Support

Maybe you are looking for