Count multiple nodes in XML using xPath

Hi',
How to count the CUSTSERIAL node in the below XML using xPath.
<missingICCRec>
<MissingField xmlns="http://www.Google.com/MissingFields/v1.0">
<CUSTSERIAL xmlns="http://Google.com/InboundService">23809002RN</CUSTSERIAL>
<CUSTSERIAL xmlns="http://Google.com/InboundService">23809003RN</CUSTSERIAL>
<CUSTSERIAL xmlns="http://Google.com/InboundService">23809004RN</CUSTSERIAL>
</MissingField>
</missingICCRec>
Thanks
Yatan

Yatan,
I created a simple BPEL with assign to count the node. Using ora:countNodes() function is throwing exception but when i tried with count() it works.
XSD seems to be valid. Only you need to have the function as below.
count(bpws:getVariableData('inputVariable','payload','/client:process/client:missingICCRec/client:MissingField/client:CUSTSERIAL'))
XSD Used:
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/PIMtoRPASAmendment/BPLENodeCount/BPLENodeCount"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="process">
<complexType>
<sequence>
<element name="missingICCRec">
<complexType>
<sequence>
<element name="MissingField">
<complexType>
<sequence>
<element name="CUSTSERIAL" maxOccurs="unbounded" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name="processResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
This works !!!
Please let me know if this helps.
Thanks,
Vijay

Similar Messages

  • 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

  • How to extract node value by using xpath in orchestration shape

    i want extract the node value by using xpath in expression shape in orch, then assign to variable.
    then decide shape in if branch im using check condition based nodevalue .
    str = xpath(Message_3, ("string(/*[local-name()='Root' and namespace-uri()='http://BizTalk_Server_ProjectRNd2.Schema3']/*[local-name()='no' and namespace-uri()=''])"));
    but i got below error:
    xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'BizTalk_Server_ProjectRNd2.BizTalk_Orchestration1(f3c581d3-049f-8a8a-9316-fc1235b03f99)'.
    The service instance will remain suspended until administratively resumed or terminated. 
    If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
    InstanceId: 020779be-713d-408c-9ff4-fd1462c2e52c
    Shape name: Expression_1
    ShapeId: b865a3e1-7ebe-410d-9f60-8ad2139ad234
    Exception thrown from: segment 1, progress 10
    Inner exception: There is an error in the XML document.
    Exception type: InvalidOperationException
    Source: System.Xml
    Target Site: System.Object Deserialize(System.Xml.XmlReader, System.String, System.Xml.Serialization.XmlDeserializationEvents)
    The following is a stack trace that identifies the location where the exception occured
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
       at Microsoft.XLANGs.Core.Part.XPathLoad(Part sourcePart, String xpath, Type dstType)
       at BizTalk_Server_ProjectRNd2.BizTalk_Orchestration1.segment1(StopConditions stopOn)
       at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
    Additional error information:
            <no xmlns=''> was not expected.
    Exception type: InvalidOperationException
    Source: System.Xml
    Target Site: System.Object Read_string()
    The following is a stack trace that identifies the location where the exception occured
       at System.Xml.Serialization.XmlSerializationPrimitiveReader.Read_string()
       at System.Xml.Serialization.XmlSerializer.DeserializePrimitive(XmlReader xmlReader, XmlDeserializationEvents events)
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

    Hi,
    as per your  code i got below error 
    Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'BizTalk_Server_ProjectRNd2.BizTalk_Orchestration1(f3c581d3-049f-8a8a-9316-fc1235b03f99)'.
    The service instance will remain suspended until administratively resumed or terminated. 
    If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
    InstanceId: f5fffb05-e6d6-4765-83da-4e6c9696dd8a
    Shape name: Expression_1
    ShapeId: b865a3e1-7ebe-410d-9f60-8ad2139ad234
    Exception thrown from: segment 1, progress 10
    Inner exception: There is an error in the XML document.
    Exception type: InvalidOperationException
    Source: System.Xml
    Target Site: System.Object Deserialize(System.Xml.XmlReader, System.String, System.Xml.Serialization.XmlDeserializationEvents)
    The following is a stack trace that identifies the location where the exception occured
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializat
    this is my schema:
      <?xml version="1.0" encoding="utf-16"
    ?>
    <xs:schema xmlns="http://BizTalk_Server_ProjectRNd2.Schema3" xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
    xmlns:ns0="https://BizTalk_Server_ProjectRNd2.PropertySchema" targetNamespace="http://BizTalk_Server_ProjectRNd2.Schema3" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:annotation>
    <xs:appinfo>
    <b:imports>
      <b:namespace
    prefix="ns0" uri="https://BizTalk_Server_ProjectRNd2.PropertySchema" location=".\PropertySchema.xsd"
    />
      </b:imports>
      </xs:appinfo>
      </xs:annotation>
    <xs:element name="Root">
    <xs:annotation>
    <xs:appinfo>
    <b:properties>
      <b:property
    name="ns0:no" xpath="/*[local-name()='Root' and namespace-uri()='http://BizTalk_Server_ProjectRNd2.Schema3']/*[local-name()='no' and namespace-uri()='']"
    />
      </b:properties>
      </xs:appinfo>
      </xs:annotation>
    <xs:complexType>
    <xs:sequence>
      <xs:element
    name="no" type="xs:string" />
      <xs:element
    name="name" type="xs:string" />
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:schema>

  • Write XML using XPath

    Hi,
    I have a problem. I need to WRITE a XML using XPath.
    Supose that XPath String : "/clients/client/name"
    Equivalent XML :
    <clients>
    <client>
    <name></name>
    </client>
    <clients>
    Please, helpme ...
    The XPath Strings are dinamic, there are lot of combinations.
    Is there an API (free ?) that support this ?
    Thankz

    Normally XPath is used for searching existing XML documents, not for creating new ones. So it's unlikely that anything exists to do what you ask. But not impossible, people do the strangest things. Have you searched Google?
    Of course you realize you can't use arbitrary XPath expressions here, for example what would you do with a predicate?

  • Read xml using xpath in java

    Hi ALL,
    I have a xml as follows:
    <AAA>
    <BBB>
    <CCC>xyz</CCC>
    <DDD>abc</DDD>
    </BBB>
    </AAA>
    Now using any of the java class, i just need read the value of "CCC" as follows:
    (i.e using xpath i need to read the value)
    String val = x.somemethod("/AAA/BBB/CCC");
    Thanks!

    In case you're curious - here's the dom4j equivalent of dvohra09's sample code.
    SAXReader saxReader = new SAXReader("org.apache.xerces.parsers.SAXParser");
    Document doc = saxReader.read(source); //Where source is your file, input source, input stream, reader, or url
    String value = doc.valueOf("//AAA/BBB/CCC"); //Result given the xml from OP = 'xyz'OK - not much difference with this simple example but if you haven't settled on an API, dom4j is worth looking at (IMHO).
    &#8734; brewman &#8734;

  • Creating New XML using xPath

    Hi,
    I wanted to know if an XML Document created in the Database using xPaths. I mean, I don't want to creat any XML file on the OS in the first place. I want to create an XML using a table containing xPaths. Can this be done in XDB ?
    Thanks in Advance,
    Piyush

    Hi Piyush
    I don't see how you can create a XML document via xpath!?!? xpath it's only used to reference data in an XML document...
    Chris

  • Creating XML using XPath

    Hello,
    I want to creat XML document using Dom and XPath, as per my knowledge goes I can't create it using XPath {I may b wrong, if I am then pls tell me know :-) }.
    If there doesn't exists any thing like this I am thinkin of wrapping a class {say its XPathProcesserDom} which takes the XPath querry and internaly creates XML Document and returns on request. Is this a good idea :-)
    waiting for comments :-)....
    thanks and regards,
    MaheshPujari

    Hi Piyush
    I don't see how you can create a XML document via xpath!?!? xpath it's only used to reference data in an XML document...
    Chris

  • Fetching xml node nth value using Xpath

    HI Experts ,
    with reference to below question, i have one more doubt.
    https://social.msdn.microsoft.com/Forums/en-US/f894e5e2-8926-4604-9171-616da3f00cd7/xpath-to-fetch-value-in-flatfile-schema?forum=biztalkgeneral
    I used below xpath to fetch nth value of full repeating message nodes
    indexStr = System.Convert.ToString(index);DATE=xpath(In_FF, "string(//*[local-name() = 'Details']["+indexStr+"])/*[local-name()='DATE'])");index=index + 1;
    and i got below error, can any help me in this?
    Exception thrown from: segment 2, progress 43
    Inner exception: 'string(//*[local-name() = 'Details'][1])/*[local-name()='DATE'])' has an invalid token.
    Exception type: XPathException
    Source: System.Xml
    Target Site: MS.Internal.Xml.XPath.AstNode ParseXPathExpresion(System.String)
    The following is a stack trace that identifies the location where the exception occured

    your XPATH expression is WRONG.
    it should be
    DATE=xpath(In_FF,
    "string(//*[local-name() = 'Details']["+indexStr+"]/*[local-name()='DATE'])");
    There is NO ")" after ["+indexStr+"].
    The more reliable way is to use a string variable and use the System.String.Format() call as below
    xPathExpr = System.String.Format("string(//*[local-name() = 'Details'][{0}]/*[local-name()='DATE'])", index);
    DATE=xpath(In_FF, xPathExpr);
    The "invalid token" is because of the mismatched ")" in your XPATH Expression.
    Regards.

  • Upload xml using xpath when data in scattered in different tags

    Hi,
    My problem is "I have to upload a big XML File into a relational master child model of hierarcy=5,but the struture of the xml is not as per the Data Model".I am using the xpath approach in PL/SQL because there is no other way I can get this done.Can you tel me how can I do this effeciently using this approach.Secondly,How can I increase the performance in this scenarion ?
    Thanks a Lot !!!

    Hi Marco,
    Thanks for your advice.
    Please tel me how canI use Xmltype view to come out of this problem.As I already mention that the xml tree is not per the Data model and the nodes name is also differenr so how can I do this.I don't know java but can handle pl/sql.
    Thanks !! Waiting for further advice.

  • Displaying XML using XPath expressions

    Hi. I have a XML file which looks something like this:
    <?xml version="1.0"?>
    <SAQ>
    <question id="1">
    What does UML stand for?
    <answer id="1" correct="yes">
    Unified Modelling Language
    <explanation>
    Explanation
    </explanation>
    </answer>
    <answer id="2" correct="no">
    United Modelling Language
    <explanation>
    Wrong
    </explanation>
    </answer>
    </question>
    I want to just display the Question, not the child Answer and Explantion nodes under it, but when I use:
    <c:set var="temp" value="1" />
    <x:out select="$doc//SAQ//question[@id = $temp]" />
    it displays:
    What does UML stand for? Unified Modelling Language Explanation United Modelling Language Wrong
    How do I just display the parent question node and not its child answer and explanation nodes?
    Thanks!

    use the text() xpath function it should work:
    <x:out select="$doc//SAQ//question[@id = $temp]/text()" />

  • How to remove elements/attributes from XML using Xpath in XSLT ??

    Hello ,
    Is there anyway or method of Xpath from which I can delete the elements and attributes from XML at runtime ??
    Like I have such XML and I have to remove per attribute highlighted below
    <person per="and">
    <e:emp a="ir" b="ad" >
    </e:emp>
    </person>
    And want a result like this
    <person>
    <e:emp a="ir" b="ad" >
    </e:emp>
    </person>
    Thanks

    To achieve this you can use the bpelx:remove function: http://download.oracle.com/docs/cd/E12483_01/integrate.1013/b28981/manipdoc.htm#CIHJBJFD
    your assign will look like:
    <bpel:assign>
    <bpelx:remove>
    <target variable="person" query="/person/@per" />
    </bpelx:remove>
    </bpel:assign>
    Regards,
    Melvin

  • 11.1.2.3 multiple node install, not using a shared location for HTTP config files

    I finished, as best as I could a three server install of 11.1.2.3; foundation server with Workspace, R&A, EPMA, Essbase tools, an Essbase only server, and a Planning server.  I did not use a 'sharedlocation (Advanced link in HTTP screen) for the servers.  My question is; 'What needs to be done to complete the configuration, as Planning Administration does not show up in Workspace?'  It is possible to re-configure HTTP to a 'sharedLocation' after the install and config tasks are done?
    Thanks,

    You can configure the OHS shared location at any point
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Retrieve records based on condition from xml using XPATH

    Hi all,
    I have a table form_content where there are two columns - form_content_id (numeric) and xml_content (clob). The structure of xml_content is
    <RAF xmlns="http://www.abnamro.com/WCS/GCEG/KRT">
    <XBorderRAF>
    <ClientProfile isBranch="1" isBusinessAddressDifferent="1" isSubsidiary="0" regDate="2009-09-01">
    <RegisteredAddress city="test" country="GB" nameOfContactPerson="3454545" street1="test" telephoneNumber="34534545"/>
    </ClientProfile>
    </XBorderRAF>
    </RAF>
    I want to retrive all form_contant_id from form_content table where country is 'GB' inside RegisteredAddress tag.
    I am able to retrive all form_content_id with country value using below query,
    SELECT form_content_id,
    extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')
    as registerAddress
    from
    form_content
    but I am finding it difficult to reterive records based on any condition..
    SELECT form_content_id,
    extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')
    as registerAddress
    from
    form_content
    where
    (extractValue(xmltype(xml_content),'/RAF/XBorderRAF/ClientProfile/RegisteredAddress/@country', 'xmlns="http://www.abnamro.com/WCS/GCEG/KRT"')='GB'
    Please help me to resolve this problem. ....
    Thanks

    Ok, thaks to all who looked this query, I found the answer
    select form_content_id
    from xmltest
    where existsnode(xmltype(xml_content), '/RAF/XBorderRAF/ClientProfile/RegisteredAddress[@country="GB"]','xmlns="http://www.abnamro.com/WCS/GCEG/KRT"') = 1;

  • Xml loading using xpath in pl/sql

    Hi,
    I am loading xml using xpath query bu i am stucked here.I am not able to pass the loop counter "I" into the query.Please help.
    The problem is in line " 13 FROM xml_table,table(XMLSequence(extract(OBJECT_VALUE, '/BIF/SBI/SBC/flag'))) li;
    " in the below block
    1 declare
    2 SBI_count pls_integer;
    3 begin
    4 select count(*)
    5 into SBI_count
    6 from xml_table,table(XMLSequence(extract(OBJECT_VALUE, '/BIF/SBI') ) );
    7 dbms_output.put_line( 'SBI_count '||SBI_count );
    8 for I in 1..SBI_count
    9 LOOP
    10 INSERT INTO Subclass_Date_Flags( Subclass_Id,
    11 subclass_date_flags_8 )
    12 SELECT 'SID',extractvalue(VALUE(li), '//flag')
    13 FROM xml_table,table(XMLSequence(extract(OBJECT_VALUE, '/BIF/SBI[I]/SBC/flag'))) li;
    14 dbms_output.put_line( 'Row '||SQL%ROWCOUNT );
    15 END LOOP;
    16 commit;
    17* end;
    SQL> /
    SBI_count 2
    Row 0
    Row 0
    PL/SQL procedure successfully completed.

    Try this code, just keep a reference to your root node so you can keep appending children to it:
    DECLARE
    xmlDoc xmldom.DOMDocument;
    xmlNode xmldom.DOMNode;
    xmlNode1 xmldom.DOMNode;
    xmlElem1 xmldom.DOMElement;
    xmlElem2 xmldom.DOMElement;
    xmlText xmldom.DOMText;
    CURSOR cur_emp IS
    SELECT *
    FROM emp;
    --WHERE empno = 7369;
    row_emp emp%ROWTYPE;
    BEGIN
    xmlDoc := xmldom.newDOMDocument;
    xmlNode := xmldom.makeNode(xmlDoc);
    xmlElem1 := xmldom.createElement(xmlDoc,'root');
    xmlNode := xmldom.appendChild(xmlNode,xmldom.makeNode(xmlElem1));
    OPEN cur_emp;
    LOOP
    FETCH cur_emp INTO row_emp;
    EXIT WHEN cur_emp%NOTFOUND;
    xmlElem2 := xmldom.createElement(xmlDoc,'name');
    xmldom.setAttribute(xmlElem2, 'empno',TO_CHAR(row_emp.empno));
    xmlNode1 := xmldom.appendChild(xmlNode,xmldom.makeNode(xmlElem2));
    xmlText := xmldom.createTextNode(xmlDoc,row_emp.ename);
    xmlNode1 := xmldom.appendChild(xmlNode1,xmldom.makeNode(xmlText));
    END LOOP;
    CLOSE cur_emp;
    xmldom.writeToFile(xmlDoc,'c:\xmltest1.txt');
    END;
    null

  • Select does not recognizes subelement/nodes in xml

    Problem:
    Querying(or update) xml using xpath recognizes only the root node, and ignores all of the subnodes.
    What was done:
    1. I created and registered xml schema using dbms_xmlschema
    2. Created a table with xmltype column refeencing above schema
    3. Inserted xml into the table successfully into 9.2.0.1.0 DB
    Has anyone necountered similar problems? Any suggestions?
    Thanks!

    Hi,
    We need to see the commands you are issuing in order to provide more help.
    By default, XDB only does a "partial" validation on structured XMLType tables. For full validation you would need to code a CHECK constraint or a BEFORE INSERT trigger. The link below provides more information:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb03usg.htm#sthref318
    It sounds like you are targetting XML nodes that don't exist, both in your update and select commands. Oracle doesn't consider that an error and if it doesn't find the nodes, then it merely returns NULL or doesn't update anything. You can test for nodes with existsnode() prior to firing the statements or simply test the results of the SQL statement after.
    Keith

Maybe you are looking for

  • Xperia Z2 phone Copy -Paste option is not available in most of places

    Hi, I have noticed that there is no option to do copy-paste from many of places in this phone. e.g. from chrome, address bar , can not copy the url ..  Where in Samsung, can copy paste from most of the places. Can expect any new software update from

  • Compress the request of inventory cube 0ic_c03

    Hi experts, I want to compress the infocube 0ic_c03 daily for the delta requests through process chains. In the process chain, process types there are 2 options: 1.Collapse only those requests that were loaded XXX days ago 2.Number of requests that y

  • Measuring performance tcp udp connection using java

    ho find t answers for these questions .. 1. Is it possible to set some upper cut off for the data rate or transmission rate in TCP or UDP ? 2. IF true, get t source code for t same ? 3. is it possible to measure t data rate of a TCP or UDP connection

  • European Legislation - Infotype 0077 (Additional Data)

    Due to changes in the recording of additional data I need to hold further information relating to gender, sexuality etc. Does anyone know if SAP (Europe wide) are changing this infotype or if it will be a customization required by the individual? If

  • Quick Poll in Detailed Navigation area

    Hi Experts, I have successfully created Quick Poll iview. I want to show this iview in detailed navigation area. Can you please let me know how to go about it? Regards, EP