Heed help in Xpath query??

Hello,
It is an interesting forum. Here is my situation. I have the following XML
<?xml version="1.0" encoding="UTF-8"?>
<DepartmentList>
     <Department>
          <DeptNo>10</DeptNo>
          <DeptName>ACCOUNTING</DeptName>
          <Location>NEW YORK</Location>
          <Employee>
               <EmployeeId>7782</EmployeeId>
               <Name>CLARK</Name>
               <Job>MANAGER</Job>
               <Manager>7839</Manager>
               <Hiredate>09-JUN-81</Hiredate>
               <Salary>2450</Salary>
          </Employee>
          <Employee>
               <EmployeeId>7839</EmployeeId>
               <Name>KING</Name>
               <Job>PRESIDENT</Job>
               <Hiredate>17-NOV-81</Hiredate>
               <Salary>5000</Salary>
          </Employee>
          <Employee>
               <EmployeeId>7934</EmployeeId>
               <Name>MILLER</Name>
               <Job>CLERK</Job>
               <Manager>7782</Manager>
               <Hiredate>23-JAN-82</Hiredate>
               <Salary>1300</Salary>
          </Employee>
     </Department>
     <Department>
          <DeptNo>20</DeptNo>
          <DeptName>RESEARCH</DeptName>
          <Location>DALLAS</Location>
          <Employee>
               <EmployeeId>7369</EmployeeId>
               <Name>SMITH</Name>
               <Job>CLERK</Job>
               <Manager>7902</Manager>
               <Hiredate>17-DEC-80</Hiredate>
               <Salary>800</Salary>
          </Employee>
          <Employee>
               <EmployeeId>7566</EmployeeId>
               <Name>JONES</Name>
               <Job>MANAGER</Job>
               <Manager>7839</Manager>
               <Hiredate>02-APR-81</Hiredate>
               <Salary>2975</Salary>
          </Employee>
          <Employee>
               <EmployeeId>7788</EmployeeId>
               <Name>SCOTT</Name>
               <Job>ANALYST</Job>
               <Manager>7566</Manager>
               <Hiredate>19-APR-87</Hiredate>
               <Salary>3000</Salary>
          </Employee>
          <Employee>
               <EmployeeId>7876</EmployeeId>
               <Name>ADAMS</Name>
               <Job>CLERK</Job>
               <Manager>7788</Manager>
               <Hiredate>23-MAY-87</Hiredate>
               <Salary>1100</Salary>
          </Employee>
          <Employee>
               <EmployeeId>7902</EmployeeId>
               <Name>FORD</Name>
               <Job>ANALYST</Job>
               <Manager>7566</Manager>
               <Hiredate>03-DEC-81</Hiredate>
               <Salary>3000</Salary>
          </Employee>
     </Department>
     <Department>
          <DeptNo>30</DeptNo>
          <DeptName>SALES</DeptName>
          <Location>CHICAGO</Location>
          <Employee>
               <EmployeeId>7499</EmployeeId>
               <Name>ALLEN</Name>
               <Job>SALESMAN</Job>
               <Manager>7698</Manager>
               <Hiredate>20-FEB-81</Hiredate>
               <Salary>1600</Salary>
               <Commission>300</Commission>
          </Employee>
          <Employee>
               <EmployeeId>7521</EmployeeId>
               <Name>WARD</Name>
               <Job>SALESMAN</Job>
               <Manager>7698</Manager>
               <Hiredate>22-FEB-81</Hiredate>
               <Salary>1250</Salary>
               <Commission>500</Commission>
          </Employee>
          <Employee>
               <EmployeeId>7654</EmployeeId>
               <Name>MARTIN</Name>
               <Job>SALESMAN</Job>
               <Manager>7698</Manager>
               <Hiredate>28-SEP-81</Hiredate>
               <Salary>1250</Salary>
               <Commission>1400</Commission>
          </Employee>
          <Employee>
               <EmployeeId>7698</EmployeeId>
               <Name>BLAKE</Name>
               <Job>MANAGER</Job>
               <Manager>7839</Manager>
               <Hiredate>01-MAY-81</Hiredate>
               <Salary>2850</Salary>
          </Employee>
          <Employee>
               <EmployeeId>7844</EmployeeId>
               <Name>TURNER</Name>
               <Job>SALESMAN</Job>
               <Manager>7698</Manager>
               <Hiredate>08-SEP-81</Hiredate>
               <Salary>1500</Salary>
               <Commission>0</Commission>
          </Employee>
          <Employee>
               <EmployeeId>7900</EmployeeId>
               <Name>JAMES</Name>
               <Job>CLERK</Job>
               <Manager>7698</Manager>
               <Hiredate>03-DEC-81</Hiredate>
               <Salary>950</Salary>
          </Employee>
     </Department>
     <Department>
          <DeptNo>40</DeptNo>
          <DeptName>OPERATIONS</DeptName>
          <Location>BOSTON</Location>
     </Department>
</DepartmentList>
It was stored in XMLTYPE table TESTXML
I have following queries
1) Select extractvalue(value(q),'//Employee')
from TESTXML x
, TABLE(XMLSEQUENCE(EXTRACT(value(x), '//Department/employee'))) p
, TABLE(XMLSEQUENCE(EXTRACT(value(p), '//Employee'))) q
2) Select extractvalue(value(q),'//Department')
from TESTXML x
, TABLE(XMLSEQUENCE(EXTRACT(value(x), '//Department/employee'))) p
, TABLE(XMLSEQUENCE(EXTRACT(value(p), '//Employee'))) q
I am getting no rows selected .
the query
Select extractvalue(value(p),'//Department')
from TESTXML x
, TABLE(XMLSEQUENCE(EXTRACT(value(x), '//Department'))) p
ERROR at line 1:
ORA-19025: EXTRACTVALUE returns value of only one node
How do we query on above XML using Xpath such as list of all departments, list of employees within department?
Thanks in advance.
Ram

Ram
I suggest you take the time to study the XML DB standard demo in some detail. It answer this and many of the other questions that you are asking. The answer to this question is to use xmlsequence, which allows the set of nodes which match your xpath expressed to be treated as a virtual table.
-Mark

Similar Messages

  • Help with XPath Query

    CREATE TABLE TEST_XML
    DOC_ID NUMBER(10),
    DOC_XML SYS.XMLTYPE
    Insert into TEST_XML
    (DOC_ID, DOC_XML)
    Values
    (1, XMLTYPE('<doc>
    <id>1</id>
    <store>
    <id>STR1</id>
    <dept>
    <id>DEPT1_STR1</id>
    <file_name>dept1 FOR store1</file_name>
    </dept>
    <dept>
    <id>DEPT2_STR1</id>
    <file_name>dept2 FOR store1</file_name>
    </dept>
    <id>STR2</id>
    <dept>
    <id>DEPT1_STR2</id>
    <file_name>dept1 FOR store2</file_name>
    </dept>
    <dept>
    <id>DEPT2_STR2</id>
    <file_name>dept2 FOR store2</file_name>
    </dept>
    </store>
    </doc>
    Insert into TEST_XML
    (DOC_ID, DOC_XML)
    Values
    (2, XMLTYPE('<doc>
    <id>2</id>
    <store>
    <id>STR2</id>
    <dept>
    <id>DEPT1_STR2</id>
    <file_name>dept1 FOR store2</file_name>
    </dept>
    <dept>
    <id>DEPT2_STR2</id>
    <file_name>FIR21 FOR store2</file_name>
    </dept>
    </store>
    </doc>
    COMMIT;
    I am trying to write a query to return the following result set:
    DOC_ID STORE_ID DEPT_ID
    1 STR1 DEPT1_STR1
    1 STR1 DEPT2_STR1
    1 STR2 DEPT1_STR2
    1 STR2 DEPT2_STR2
    2 STR2 DEPT1_STR2
    2 STR2 DEPT2_STR2
    I am able to write the query to return all DOC/STORE combinations and another one for all DOC/DEPT combinations:
    select extractValue(a.doc_xml,'/doc/id') as doc_id,
    --extractValue(value(dept),'/doc/store/id') as store_id,
    extractValue(value(dept),'/dept/id') as dept_id
    from test_xml a,
    table(XMLSequence(extract(a.doc_xml,'/doc/store/dept'))) dept
    and another one for all DOC/DEPT combinations:
    select extractValue(a.doc_xml,'/doc/id') as doc_id,
    extractValue(value(str),'/id') as store_id
    from test_xml a,
    table(XMLSequence(extract(a.doc_xml,'/doc/store/id'))) str
    but I cannot figure out how to combine the two.
    Oracle v10.1.0.5.0
    Thanks
    -Art

    I don't have EmployeeStatus attribute in my FIM, but it should be something like:
    /Person[(starts-with(EmployeeID, '%')) and (not(EmployeeStatus
    = 'Disabled')) and (not((EmployeeEndDate > '1800-01-01T00:00:00') or (EmployeeEndDate < '1800-01-01T00:00:00')))]
    I know the date looks weird - you can change it (move the date more to the past) or you can rebuild this part of query.
    If you found my post helpful, please give it a Helpful vote. If it answered your question, remember to mark it as an Answer.

  • XPath query rewrite and insertChildXML (10g2): Help?

    Hi all,
    I have a registered schema for a <log> document. The schema defines an element /log/logData and under that there, /log/logData/data having maxOccurs="unbounded". So the form of documents is
    <log>
    <logData>
    <data>a</data>
    <data>b</data>
    <data>c</data>
    </logData>
    </log>
    In the schema definition I have enabled "storeArrayAsVArray='true'". The <data> elements are stored in a nested table. Every type is stored object-relationally.
    To an instance documen, I add <data> elements so:
    UPDATE log SET object_value = insertChildXML(object_value, 'log/logData', 'data', '<data>foo</data>') WHERE existsNode ('/log[@uid="foo"]')
    The call succeeds but the problem is that I need to make this call thousands of times. Initiallly the call might take 100 ms, but after a few hundred inserts inserting a single element takes over a second, and the time keeps increasing.
    I believe at least part of the problem is that XPath query rewrites are not working for this call.
    Following Chapter 6 of Oracle XML DB Developer's Guide, to debug the problem I have switched on
    ALTER SESSION SET EVENTS '19021 trace name context forever, level 1';
    and then every invocation causes:
    ORA-19022: XML XPath functions are disabled
    indicating that Oracle could not rewrite the query. Then I set
    ALTER SESSION SET EVENTS '19027 TRACE NAME CONTEXT FOREVER, LEVEL 8192'
    to obtain a trace file. Here is a portion of that trace:
    *** 2005-10-30 16:54:44.984
    *** ACTION NAME:() 2005-10-30 16:54:44.968
    *** MODULE NAME:(SQL*Plus) 2005-10-30 16:54:44.968
    *** SERVICE NAME:(SYS$USERS) 2005-10-30 16:54:44.968
    *** SESSION ID:(137.38364) 2005-10-30 16:54:44.968
    NO REWRITE
         Reason ==> xseq:not optuop
    NO REWRITE
         Reason ==> xseq:not optuop
    NO REWRITE
         Reason ==> not SQLX operand
    NO REWRITE
         Reason ==> non sqlx expression input
    NO REWRITE
         Reason ==> non rewritable sqlx input
    NO REWRITE
    (the rest of the file repeats these lines)
    I have no idea how to interpet that! Can anyone out there offer some insight/assistance?
    Thanks if you can,
    Hugh

    Below is a complete example script. Cannot seem to get rewrite for even this simple case. By that I mean, executing both of the SELECT statements near the end yield the ORA-19022, and that executing the insertChildXML takes progressively longer to execute the more child elements there are.
    Any pointers appreciated!
    Hugh
    set echo on
    ALTER SESSION SET EVENTS '19021 trace name context forever, level 1';
    ALTER SESSION SET EVENTS '19027 TRACE NAME CONTEXT FOREVER, LEVEL 8192';
    exec dbms_xmlschema.deleteSchema('http://hughw.net/foo', dbms_xmlschema.DELETE_CASCADE_FORCE);
    begin
    dbms_xmlschema.registerSchema('http://hughw.net/foo', XMLType('<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="http://hughw.net/foo" xmlns="http://hughw.net/foo" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"
    xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
    <xs:element name="root" xdb:defaultTable="ROOT" >
    <xs:complexType xdb:SQLType="ROOT_T">
    <xs:sequence>
    <!-- could use out of line storage -->
    <!-- commented out
    <xs:element name="child" type="childType" minOccurs="0" maxOccurs="unbounded"
    xdb:SQLName="CHILDREN"
    xdb:SQLInline="false" xdb:defaultTable="CHILD"
    />
    -->
    <!-- use nested table -->
    <xs:element name="child" type="childType" minOccurs="0" maxOccurs="unbounded"
    xdb:SQLName="CHILDREN"
    xdb:SQLCollType="CHILD_V"
    />
    </xs:sequence>
    <xs:attribute name="uid" type="xs:string" use="required"/>
    </xs:complexType>
    </xs:element>
    <xs:complexType name="childType" xdb:SQLType="CHILD_T">
    <xs:simpleContent>
    <xs:extension base="xs:string"/>
    </xs:simpleContent>
    </xs:complexType>
    </xs:schema>'));
    end;
    insert into root values( XMLType('<?xml version="1.0" encoding="UTF-8"?>
    <root uid="1" xmlns="http://hughw.net/foo"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://hughw.net/foo http://hughw.net/foo">
    <child>a</child>
    <child>b</child>
    <child>c</child>
    </root>'));
    CREATE INDEX ROOT_INDEX ON ROOT (extractValue(object_value,'/root/@uid'));
    select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root;
    explain plan for select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root;
    SELECT PLAN_TABLE_OUTPUT FROM table(DBMS_XPLAN.display('plan_table', NULL, 'serial'));
    select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root
    WHERE existsNode(object_value, '/root[@uid="1"]') = 1;
    explain plan for select insertChildXML(object_value, '/root', 'child', '<child>x</child>>') FROM root
    WHERE existsNode(object_value, '/root[@uid="1"]') = 1;
    SELECT PLAN_TABLE_OUTPUT FROM table(DBMS_XPLAN.display('plan_table', NULL, 'serial'));

  • Copying Variables in BPEL using XPath Query

    Hi,
    I am new to BPEL and i want to know if it is possible to copy data from one variable to another using XPath Query in the <from> <to> tags, when the two variables are of different message types.
    I am trying to create a sample BPEL that would receive a String through the receive tag tied to one partner link (WSDl) and then invoke a different webservice using the <invoke> tag tied to another partner link (WSDL) by passing the received variable.
    I have pasted the BPEL File and the two WSDl files involved.
    My Issue is that when I send a soap request to the BPEL, it is passed as null to the webservice invoked.
    Probably because the copy tags don't work.
    Please help.
    BPEL File
    <!--
    ~ Licensed to the Apache Software Foundation (ASF) under one
    ~ or more contributor license agreements. See the NOTICE file
    ~ distributed with this work for additional information
    ~ regarding copyright ownership. The ASF licenses this file
    ~ to you under the Apache License, Version 2.0 (the
    ~ "License"); you may not use this file except in compliance
    ~ with the License. You may obtain a copy of the License at
    ~
    ~ http://www.apache.org/licenses/LICENSE-2.0
    ~
    ~ Unless required by applicable law or agreed to in writing,
    ~ software distributed under the License is distributed on an
    ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    ~ KIND, either express or implied. See the License for the
    ~ specific language governing permissions and limitations
    ~ under the License.
    -->
    <process name="HelloWorld2"
    targetNamespace="http://ode/bpel/unit-test"
    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
    xmlns:tns="http://ode/bpel/unit-test"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:test="http://ode/bpel/unit-test.wsdl"
    xmlns:ns0="http://poc.com"
    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
    <import location="HelloWorld2.wsdl"
    namespace="http://ode/bpel/unit-test.wsdl"
    importType="http://schemas.xmlsoap.org/wsdl/" />
    <import location="sayHello.wsdl"
    namespace="http://poc.com"
    importType="http://schemas.xmlsoap.org/wsdl/" />
    <partnerLinks>
    <partnerLink name="helloPartnerLink"
    partnerLinkType="test:HelloPartnerLinkType"
    myRole="me" />
    <partnerLink name="sayHelloBPELPL"
    partnerLinkType="ns0:sayHelloPLT"
    partnerRole="you" initializePartnerRole="yes" />
    </partnerLinks>
    <variables>
    <variable name="myVar" messageType="test:HelloMessage"/>
    <variable name="tmpVar" messageType="test:HelloMessage"/>
    <variable name="inVar" messageType="ns0:sayHelloRequest"/>
    <variable name="outVar" messageType="ns0:sayHelloResponse"/>
    </variables>
    <sequence>
    <receive
    name="start"
    partnerLink="helloPartnerLink"
    portType="test:HelloPortType"
    operation="hello"
    variable="myVar"
    createInstance="yes"/>
    <assign name="ass1">
    <copy>
    <from variable = "myVar" part = "TestPart"/>
    <to variable = "inVar"
    part = "parameters"
    query= "/sayHello/ns0:param0" />
    </copy>
    </assign>
    <invoke partnerLink = "sayHelloBPELPL"
    portType = "ns0:sayHelloPortType"
    inputVariable = "inVar"
    operation = "sayHello"
    outputVariable = "outVar">
    </invoke>
    <assign name="ass2">
    <copy>
    <from variable = "outVar"
    part = "parameters"
    query= "/sayHelloResponse/ns0:return" />
    <to variable = "tmpVar" part="TestPart"/>
    </copy>
    </assign>
    <reply name="end"
    partnerLink="helloPartnerLink"
    portType="test:HelloPortType"
    operation="hello"
    variable="tmpVar"/>
    </sequence>
    </process>
    WSDL File1
    <?xml version="1.0" encoding="utf-8" ?>
    <!--
    ~ Licensed to the Apache Software Foundation (ASF) under one
    ~ or more contributor license agreements. See the NOTICE file
    ~ distributed with this work for additional information
    ~ regarding copyright ownership. The ASF licenses this file
    ~ to you under the Apache License, Version 2.0 (the
    ~ "License"); you may not use this file except in compliance
    ~ with the License. You may obtain a copy of the License at
    ~
    ~ http://www.apache.org/licenses/LICENSE-2.0
    ~
    ~ Unless required by applicable law or agreed to in writing,
    ~ software distributed under the License is distributed on an
    ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    ~ KIND, either express or implied. See the License for the
    ~ specific language governing permissions and limitations
    ~ under the License.
    -->
    <wsdl:definitions
    targetNamespace="http://ode/bpel/unit-test.wsdl"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://ode/bpel/unit-test.wsdl"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
    xmlns:ns0="http://poc.com">
    <wsdl:message name="HelloMessage">
    <wsdl:part name="TestPart" type="xsd:string"/>
    </wsdl:message>
    <wsdl:portType name="HelloPortType">
    <wsdl:operation name="hello">
    <wsdl:input message="tns:HelloMessage" name="TestIn"/>
    <wsdl:output message="tns:HelloMessage" name="TestOut"/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="hello">
    <soap:operation soapAction="" style="rpc"/>
    <wsdl:input>
    <soap:body
    namespace="http://ode/bpel/unit-test.wsdl"
    use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body
    namespace="http://ode/bpel/unit-test.wsdl"
    use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="HelloService">
    <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
    <soap:address location="http://localhost:8082/ode/processes/helloWorld"/>
    </wsdl:port>
    </wsdl:service>
    <plnk:partnerLinkType name="HelloPartnerLinkType">
    <plnk:role name="me" portType="tns:HelloPortType"/>
    <plnk:role name="you" portType="tns:HelloPortType"/>
    </plnk:partnerLinkType>
    </wsdl:definitions>
    WSDL File 2
    <?xml version="1.0" encoding="UTF-8" ?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:ns0="http://poc.com"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:ns1="http://org.apache.axis2/xsd"
    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
    targetNamespace="http://poc.com">
    <wsdl:types>
    <xs:schema xmlns:ns="http://poc.com" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://poc.com">
    <xs:element name="sayHello">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" name="param0" nillable="true" type="xs:string" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="sayHelloResponse">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" name="return" nillable="true" type="xs:string" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    </wsdl:types>
    <wsdl:message name="sayHelloRequest">
    <wsdl:part name="parameters" element="ns0:sayHello" />
    </wsdl:message>
    <wsdl:message name="sayHelloResponse">
    <wsdl:part name="parameters" element="ns0:sayHelloResponse" />
    </wsdl:message>
    <wsdl:portType name="sayHelloPortType">
    <wsdl:operation name="sayHello">
    <wsdl:input message="ns0:sayHelloRequest" wsaw:Action="urn:sayHello" />
    <wsdl:output message="ns0:sayHelloResponse" wsaw:Action="urn:sayHelloResponse" />
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="sayHelloSOAP11Binding" type="ns0:sayHelloPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sayHello">
    <soap:operation soapAction="urn:sayHello" style="document"/>
    <wsdl:input>
    <soap:body use="literal" />
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal" />
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="sayHello">
    <wsdl:port name="sayHelloPort" binding="ns0:sayHelloSOAP11Binding">
    <soap:address location="http://localhost:8082/ode/processes/sayHello" />
    </wsdl:port>
    </wsdl:service>
    <plnk:partnerLinkType name="sayHelloPLT">
    <plnk:role name="me" portType="ns0:sayHelloPortType"/>
    <plnk:role name="you" portType="ns0:sayHelloPortType"/>
    </plnk:partnerLinkType>
    </wsdl:definitions>

    Hi,
    Yes, it very much is possible.
    Xpath query provides a lot many data type conversion functions(string to int, string to date etc), which can be used in copying variables.
    thanks
    Saurabh

  • Retrieve xml attribute value of nth xml node using xpath query

    I have an xml with following stucture...
    <xml>
    <header>
     <DocumentReference OrderId="order001">
     <DocumentReference OrderId="order002">
     <DocumentReference OrderId="order003">
    I have to loop through this xml and retrieve the orderId values inside Biztalk orchestration.
    In the expression shape, I get the count of 'DocumentReference' nodes using an xpath query and then
    Added a loopshape to make sure it loops thru all nodes
    Loop condition:   n<=nodeCount     (where n is an integer variable, n=0 to begin with, incremented by 1 thru each loop, nodeCount is # of DocumentReference nodes)
     I try retrieve to the orderId in the following expression shape using the below xpath query
      xpathQuery = System.String.Format("//*[local-name()='OrderReference'][{0}]/@orderID)",n);
      sOrderId = xpath(MsgSingleInvoice,xpathQuery);
    And I get the following exception:
    Inner exception: '//*[local-name()='OrderReference'][1]/@orderID)' has an invalid token.
    Exception type: XPathException
    Appreciate any help!   thanks!

    Thanks for the quick response. I got rid of it.
    And I see a different error:
    Inner exception: Specified cast is not valid. Exception type: InvalidCastException
    Source: Microsoft.XLANGs.Engine  
    Target Site: System.Object XPathLoad(Microsoft.XLANGs.Core.Part, System.String, System.Type)
    Since variable 'n' is of integer type, I suspected it and changed it to n.ToString() and tested again and still see the same error.

  • XPath Query

    Hi All,
    How to use Xpath query . I need a example of Xpath query activity in CPO.

    XPATH query is a pretty standard XML/web query language. You can review it in general @ http://www.w3schools.com/xpath/xpath_syntax.asp
    For CPO examples, I suggest you go check out the design center and/or my blog (which is public to all).
    The blog is called Pondering Automation and is @ https://supportforums.cisco.com/community/5811/intelligent-automation
    I do a ton of web service work with JSON, XML, Xpath queries , etc.
    Also here if you are more specific with your use-case about what you are doing it might be more easy for us to help and everyone to benefit from it.

  • XPath query must be an absolute path in BPEL2.0 or only BPEL4WS?

    Hi,
    The 1st version of the BPEL4WS specifies that "For XPath 1.0, the value of the query attribute MUST be an absolute locationPath (with '/' meaning the root of the document fragment representing the entire part)." (under 14.3)
    But in BPEL 2.0 I cannot find this rule. I wonder if it is different in this version. Especially, can people write something like this:
    //street[@name='blabla']
    in the xPath query of an assign activity? or are there any important restrictions on using xPath query for a copy selection?
    Please help
    Thank you very much

    Ok, I've realised i mixed up my partitions. sda1 is with windows, sda3 is the extended one. So i changed rootnoverify(hd0,2) to rootnoverify(hd0,0)
    And it shows something entirely different now. For a blink of about 0.5 seconds, it shows:
    Booting 'Windows 7'
    rootnoverify (hd0,0)
    chainloader +1
    GRUB loading stage2...
    After that 0.5 seconds GRUB goes back to the "system select" screen, the countdown to the default choice goes again, and this whole process loops to eternity...
    Problem solved! Frankly speaking, I can't really know why. Everything was solved after I reinstalled both systems. The only difference was that the line makeactive was commented out, not deleted... And I think it is that.
    Last edited by matnik (2010-11-20 14:55:04)

  • Human Workflow Task XPath query string returns multiple nodes.

    I am looking for trouble shooting help for this error. I am no sure if it is a server or jdev issue.
    I am running JDev version 10.1.3.3 and console version 10.1.3.1.0 locally.
    General information on the BPEL process:
    I have a temporary table in Oracle lite that I created items to be review by the user. I created a synchronous BPEL process. The first step in developing this process, I created the straight forward invoke the table to get the records, transform the records with a change the approve flag = "Y", and invoke the table to update the records. Works like a charm. I followed the online tutorial by dropping a human task after the transform, configured the parameters, setup the assignments, and moved the invoke to update table under the approved condition. If the table has only one record, the process runs great but if there are two records I get the following error message.
    <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"><part name="summary"><summary>XPath query string returns multiple nodes.
    According to BPEL4WS spec 1.1 section 14.3, The assign activity part and query /ns3:TempItemCollection/ns3:TempItem/ns3:ItemNbr should not return multipe nodes.
    Please check the BPEL source at line number "178" and verify the part and xpath query /ns3:TempItemCollection/ns3:TempItem/ns3:ItemNbr.
    </summary>
    </part></selectionFailure>
    =================
    The error occurs in the first assign of the Human task after the assign copies the fields for the title. I underlined line number 178.
    <correlationSets>
    <correlationSet name="WorkflowTaskIdCor"
    properties="taskservice:taskId"/>
    </correlationSets>
    <sequence>
    <assign name="HumanTask1_1_AssignTaskAttributes">
    <copy>
    <from expression="concat(ora:getProcessURL(), string('/HumanTask1/HumanTask1.task'))"/>
    <to variable="initiateTaskInput" part="payload"
    query="/taskservice:initiateTask/task:task/task:taskDefinitionURI"/>
    </copy>
    <copy>
    <from expression="number(3)"/>
    <to variable="initiateTaskInput" part="payload"
    query="/taskservice:initiateTask/task:task/task:priority"/>
    </copy>
    <copy>
    <from>
    <payload xmlns="http://xmlns.oracle.com/bpel/workflow/task">
    <Case xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <CourtDate xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <ErrorMessage xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <ItemName xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <Payment xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <Zip xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <ProcessFlag xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <LastUpdated xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <AddedDate xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <CityAttnyAmount xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <ApprovalFlag xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <ProlawKey xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    <ProcessKey xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    </payload>
    </from>
    <to variable="initiateTaskInput" part="payload"
    query="/taskservice:initiateTask/task:task/task:payload"/>
    </copy>
    <copy>
    <from expression="concat(string('Item Fee Approval '), bpws:getVariableData('Invoke_1_Select_RecordsSelect_OutputVariable','TempItemCollection','/ns3:TempItemCollection/ns3:TempItem/ns3:ItemName'))"/>
    <to variable="initiateTaskInput" part="payload"
    query="/taskservice:initiateTask/task:task/task:title"/>
    </copy>
    <copy>
    <from variable="Invoke_1_Select_RecordsSelect_OutputVariable"
    part="TempItemCollection"
    query="/ns3:TempItemCollection/ns3:TempItem/ns3:ItemNbr"/>
    <to variable="initiateTaskInput" part="payload"
    query="/taskservice:initiateTask/task:task/task:payload/task:Item"/>
    </copy>
    <copy>
    Thank you for any help you can give me.

    Here is how I solved this problem: I was told by the metalink folks that I should use the same verion of SOA console as jdev. So I went back to jdev 10.1.3.1. Rather than reading from the Oracle lite table, I dumped the table into a flat file. I read flat file and populated the workflow. Remember to set the 'messages in batch' flag in the file adapter to 1 and the number of records to skip to zero in the format builder for the flat file. The process now reads each record and creates an instance for that each record. In other words, if I have 8 records in my flat file, I will have 8 instances of the process running on the console. Thanks Jeremy for your help figuring this out.
    Edited by: user7725126 on Nov 19, 2009 3:56 PM

  • XPath query string returns zero node error

    I have created car loan bpel application. One is Citi Loan and another is Star Loan.
    I have created just like similar to sample loan demo.
    I have entered the SSN, email, carModel, carYear, loanAmount and creditRating value and submitted. It will initiated the following tasks successfully.
    StarLoan Instance
    CitiLoan Instance
    TaskManager Instance
    CreditRating Instance
    Root appln. instance
    I have created one user approval page for Approve/Reject (jsp). Through this page, I have approved the CitiLoan offer. I have faced the following errors.
    <output>
    <part name="payload" >
    <loanOffer>7.4</loanOffer>
    </part>
    </output>
    <loanOffer>7.4</loanOffer>
    <selectionFailure>
    <part name="summary" >
    <summary>XPath query string returns zero node. According to BPEL4WS spec 1.1 section 14.3, The assign activity <to> part query should not return zero node. Please check the BPEL source at line number "90" and verify the <to> part xpath query. </summary>
    </part>
    </selectionFailure>
    Please help me.
    Thanks in advance.
    Regards,
    Sara

    Let us know if you have customized SOA composite for user creation approval?
    -Vamsi.

  • XPath query with out namespace is possible ?

    Hi,
    our system reciving xml data using the datatype xsd[b] &lt;any/&gt; . am sure the system will receive the data in same format[node hierarchical] but the namespace of the root element may be differ..
    i want write xpath which should not be parse based on the namespace of element.
    like the method setNameSpaceAware(false) in java;
    will it be possible in bpel. if so how ?
    i would be appreciate any help.
    Thanks,
    Bogi

    Ahhhh - thank you for the clarification.
    Regarding the expansion of variable, is there anything further needed? Reason I ask is, when I use the variable which contains the same string as when I hard code the string in the XPATH query, I do not receive the desired results - I only receive the
    'VENDOR_ADVISORY' results.

  • Xpath query using ANE with AIR3.9 for iOS app

    we are building an app for iOS using AIR 3.9 where we have to load and parse the xml document so that we can read the images path and download the stuff on iOS device. To fix this issue we have found a solution using XCode via ANE where by using XPath Query classes such as "PerformXPathQuery", "PerformXMLXPathQuery", "xmlReadMemory" etc. The code is running well when build on simulator itself on mac machine. But when we are packaging the ANE with AIR 3.9, it gives us the error which says that:-
    Error occurred while packaging the application:
    Undefined symbols for architecture armv7:
      "_xmlReadMemory", referenced from:
          _PerformXMLXPathQuery in libnet.example.download.a(ExampleLib.o)
    ld: symbol(s) not found for architecture armv7
    Compilation failed while executing : ld64
    I have tried linking binary with libraries like "libxml2.dylib", "libxml2.2.dylib" and libz.dylib + added the libXML header files to the header search path in the build properties, but got no help.
    our AIR 3.9 platform xml looks like:-
    <platform xmlns="http://ns.adobe.com/air/extension/3.9">
        <sdkVersion>4.0.0</sdkVersion>
        <linkerOptions>
            <option>-ios_version_min 4.2</option>
            <option>-framework UIKit</option>
            <option>-framework Foundation</option>
            <option>-framework CoreText</option>
        </linkerOptions>
    </platform>
    can anyone suggest where we are going wrong!
    thanks in advance

    Found the solution, i was missing the framework related to xPath library in platform.xml
    follow the instuctions from the below link:-
    http://forums.adobe.com/thread/1037904
    thanks adobe team

  • Variable Picker generates invalid XPath query

    This one seems to be a bug:
    When declaring a variable of type "element" (not "messageType") and accessing the variable with the Variable Picker from within the assign assistant, i.e. the following line ist generated:
    bpws:getVariableData("testVar","","/tns:TaskMgrTestCaseRequest/tns:input")
    The BPEL process can be validated and deployed without an error.
    At runtime the following exception is generated:
    XPath expression failed to execute.
    Error while processing xpath expression, the expression is "bpws:getVariableData("testVar", "", "/tns:TaskMgrTestCaseRequest/tns:input")", the reason is XPath expression failed to execute.
    Error while processing xpath expression, the expression is "", the reason is Unexpected ''.
    Please verify the xpath query.
    Please verify the xpath query.
    When working with variables of type messageType, there is no problem. (So I declared a messageType to each element type ...)
    Wolfgang

    Thanks for the heads up. We will try to kill this bug in the 0.97 release. -Edwin

  • Help in Joining query

    Hi, How I can get desired result. I am joining two tables but if date timeline does't exist in #two table then should show hyphen (-). Please help on this query. Thanks.
    create table #one (code_p char(4), code_h char(2), code_date datetime)
    insert into #one values ('DEHG','2','2010-01-01')
    insert into #one values ('DEHG','2','2011-01-01')
    insert into #one values ('DEHC','2','2009-01-01')
    insert into #one values ('DEHG','2','2012-01-01')
    create table #two (code_p char(4), code_h char(2), code_date datetime)
    insert into #two values ('DEHG','2','2010-01-01')
    insert into #two values ('DEHC','2','2009-01-01')
    select p.code_p code_p_one, p.code_h code_h_one, p.code_date code_date_one,
    p.code_p code_p_two, p.code_h code_h_two, p.code_date code_date_two from #one p join #two a on p.code_p = a.code_p
    --Result from the above query
    code_p_one code_h_one code_date_one code_p_two code_h_two code_date_two
    DEHG     2    2010-01-01     DEHG     2     2010-01-01
    DEHG     2    2011-01-01     DEHG     2     2010-01-01
    DEHC     2    2009-01-01     DEHG     2     2009-01-01
    DEHC     2    2012-01-01     DEHG     2     2009-01-01
    --Desired result
    code_p_one code_h_one code_date_one code_p_two code_h_two code_date_two
    DEHG     2    2010-01-01     DEHG     2     2010-01-01
    DEHG     2    2011-01-01     DEHG     2     -
    DEHC     2    2009-01-01     DEHG     2     2009-01-01
    DEHC     2    2012-01-01     DEHG     2     -

    Try this:
    select p.code_p code_p_one, p.code_h code_h_one, p.code_date code_date_one,
    p.code_p code_p_two, p.code_h code_h_two, ISNULL(CONVERT(varchar(50),a.code_date,121),'-') code_date_two
    from #one p
    left join #two a on p.code_p = a.code_p and p.code_date=a.code_date
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • Help with my query

    Hello all,
    Total newbie to this pl/sql stuff. So, deseperately need help in my query.
    BOOKING_ID     BOOKING_STATUS     BOOKING_DATE     BOOKING_TIME     BOOKING_DATE_TIME
    1234567     CANCELLED     20090301     37252     5/1/2010 10:20
    1234567     CANCELLED 20090301     44229     5/1/2010 12:17
    1234567     BOOKED     20090301     39462     5/1/2010 10:57
    1234567     CANCELLED     20090301     43549     5/1/2010 12:05
    9671111     BOOKED     20090301     68124     5/1/2010 12:57
    9671111     CANCELLED     20090301     45001     5/1/2010 12:05
    How do I write my query such that I would get the following results:
    BOOKING_ID     BOOKING_STATUS     BOOKING_DATE     BOOKING_TIME     BOOKING_DATE_TIME
    9671111     BOOKED     20090301     68124     2/4/2010 12:17
    Basically, I am looking at the latest BOOKING_TIME and making sure the BOOKING_STATUS=BOOKED, if not, don't even bother bring back the result. Hence, you see that BOOKING_ID=1234567 is not required since at the latest BOOKING_TIME=44229, the BOOKING_STATUS=CANCELLED.
    Any help is greatly appreciated.
    Thank you in advance for your help.
    Stanley Ho

    Hi, Stanley,
    Welcome to the forum!
    Whenever you have a question, please post your sample data in a form that people can actually use. CREATE TABLE and INSERT statements are perfect.
    For example:
    CREATE TABLE     booking
    (     booking_id          NUMBER (8)
    ,     booking_status          VARCHAR2 (10)
    ,     booking_date_time     DATE
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (1234567,        'CANCELLED',        TO_DATE ('5/1/2010 10:20', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (1234567,        'CANCELLED',        TO_DATE ('5/1/2010 12:17', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (1234567,        'BOOKED',        TO_DATE ('5/1/2010 10:57', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (1234567,        'CANCELLED',        TO_DATE ('5/1/2010 12:05', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (9671111,        'BOOKED',        TO_DATE ('5/1/2010 12:57', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (9671111,        'CANCELLED',        TO_DATE ('5/1/2010 12:05', 'MM/DD/YYYY HH24:MI'));What you want is called a Top-N Query .
    Here's one way to do it:
    WITH     got_rnum  AS
         SELECT     booking.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  booking_id
                                   ORDER BY          booking_date_time     DESC
                           ) AS rnum
         FROM    booking
    SELECT     booking_id
    ,     booking_status
    ,     TO_CHAR (booking_date_time, 'YYYYMMDD')               AS booking_date
    ,     TO_CHAR (booking_date_time, 'SSSSS')               AS booking_time
    ,     TO_CHAR (booking_date_time, 'MM/DD/YYYY HH24:MI')     AS booking_date_time
    FROM     got_rnum
    WHERE     rnum          = 1
    AND     booking_status     = 'BOOKED'
    ;Notice that you don't need PL/SQL to do this; plain old SQL is good enough.
    Of course, if you're using PL/SQL for other reasons, you can use a query like this within PL/SQL.
    Dates (including time of day) should always be stored in DATE columns.
    If you have a DATE column, like booking_date_time, then there's no need for redundant date and time columns.
    You can always display just the year-month-day, or just the time, in any format, as I did above.
    The output from the query above, with the data above, is:
    BOOKING_ID BOOKING_ST BOOKING_ BOOKI BOOKING_DATE_TIM
       9671111 BOOKED     20100501 46620 05/01/2010 12:57I realize the booking_date and booking_time columns aren't quite what you posted. If they are not derivable from booking_date_time, then you probably do need separate columns for them, and those columns can easily be added to the query above.
    Edited by: Frank Kulash on Feb 5, 2010 4:41 PM
    KEEP (DENSE_RANK ...) , like Max used below, is a great tool to have in your kit. The problem with it is that you have to repeat a lot of stuff for every column, so the more columns you have in your output, the more tedious it gets. ROW_NUMBER sclaes much better, and is adaptable to more situations. I suggest you master ROW_NUMBER first, and look into KEEP (DENSE_RANK ...) later.

  • Please help with tricky query

    I need help with SQL query (if it can be accomplished with query at all).
    I'm going to create a table with structure similar to:
    Article_Name varchar2(30), Author_Name varchar2(30), Position varchar2(2). Position field is basicly position of an article author in the author list, e.g. if there is one author, his/her position is 0, if 2, then 1st author is 0, second is 1, etc.
    Article_Name Author_Name Position
    Outer Space Smith 0
    Outer Space Blake 1
    How can I automate creation of Position, based on number of authors on the fly? Let's say I have original table without Position, but I want to create a new table that will have this information.
    Regards

    If you have an existing table whose structure doesn't tell you what position the author is in, what's the algorithm you'd use to determine who was the first author, the second author, etc? If you issue a select query on a table without providing an "order by" clause, Oracle makes no guarantees about the order in which it retrieves rows.
    As an aside, why would you store position number in a varchar2 field? If it's a number, it ought to be stored as a number.
    Justin

Maybe you are looking for