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

Similar Messages

  • SSMS 2012:FOR XML PATH Using XPath Node Tests-Columnn name 'test()' contains an invalid XML identifier as required by FOR XML?

    Hi all,
    I am learning XPATH and XQUERY from the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles, (published by apress). I copied the Code Listing 12-8 FOR XML PATH Using XPath Node Tests (listed below) and executed it in my
    SQL Server 2012 Management Studio:
    --Coles12_8.sql // saved in C:/Documemnts/SQL Server Management Studio
    -- Coles Listing 12-8 FOR XML PATH Using XPATH Node Tests
    -- Retrieving Name and E-mail Addresses with FOR XML PATH in AdvantureWorks
    -- 16 March 2015 0935 AM
    USE AdventureWorks;
    GO
    SELECT
    p.NameStyle AS "processing-instruction(nameStyle)",
    p.BusinessEntityID AS "Person/@ID",
    p.ModifiedDate AS "comment()",
    pp.PhoneNumber AS "test()",
    FirstName AS "Person/Name/First",
    MiddleName AS "Person/Name/Middle",
    LastName AS "Person/Name/Last",
    EmailAddress AS "Person/Email"
    FROM Person.Person p
    INNER JOIN Person.EmailAddress e
    ON p.BusinessEntityID = e.BusinessEntityID
    INNER JOIN Person.PersonPhone pp
    ON p.BusinessEntityID = pp.BusinessEntityID
    FOR XML PATH;
    I got the following error message:
    Msg 6850, Level 16, State 1, Line 2
    Column name 'test()' contains an invalid XML identifier as required by FOR XML; '('(0x0028) is the first character at fault.
    I have no ideas why I got this error message.  Please kindly help and advise me how to resolve this error.
    Thanks in advance,  Scott Chang

    Hi Michelle, Thanks for your nice response.
    I corrected the mistake and executed the revised code. It worked nicely.
    I just have one question to ask you about the appearance of the xml output of my Co;les12_8.sql:
    <row>
    <?nameStyle 0?>
    <Person ID="1" />
    <!--2003-02-08T00:00:00-->697-555-0142<Person><Name><First>Ken</First><Middle>J</Middle><Last>Sánchez</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="2" />
    <!--2002-02-24T00:00:00-->819-555-0175<Person><Name><First>Terri</First><Middle>Lee</Middle><Last>Duffy</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="3" />
    <!--2001-12-05T00:00:00-->212-555-0187<Person><Name><First>Roberto</First><Last>Tamburello</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="4" />
    <!--2001-12-29T00:00:00-->612-555-0100<Person><Name><First>Rob</First><Last>Walters</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="5" />
    <!--2002-01-30T00:00:00-->849-555-0139<Person><Name><First>Gail</First><Middle>A</Middle><Last>Erickson</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="6" />
    <!--2002-02-17T00:00:00-->122-555-0189<Person><Name><First>Jossef</First><Middle>H</Middle><Last>Goldberg</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="7" />
    <!--2003-03-05T00:00:00-->181-555-0156<Person><Name><First>Dylan</First><Middle>A</Middle><Last>Miller</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="8" />
    <!--2003-01-23T00:00:00-->815-555-0138<Person><Name><First>Diane</First><Middle>L</Middle><Last>Margheim</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="9" />
    <!--2003-02-10T00:00:00-->185-555-0186<Person><Name><First>Gigi</First><Middle>N</Middle><Last>Matthew</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="10" />
    <!--2003-05-28T00:00:00-->330-555-2568<Person><Name><First>Michael</First><Last>Raheem</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="11" />
    <!--2004-12-29T00:00:00-->719-555-0181<Person><Name><First>Ovidiu</First><Middle>V</Middle><Last>Cracium</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    I feel this xml output is not like the regular xml output.  Do you know why it is diffrent from the regular xml xml output?  Please comment on this matter.
    Thanks,
    Scott Chang
    What do you mean by regular xml document? Are you referring to fact that its missing a root element? if yes it can be added as below
    USE AdventureWorks;
    GO
    SELECT
    p.NameStyle AS "processing-instruction(nameStyle)",
    p.BusinessEntityID AS "Person/@ID",
    p.ModifiedDate AS "comment()",
    pp.PhoneNumber AS "text()",
    FirstName AS "Person/Name/First",
    MiddleName AS "Person/Name/Middle",
    LastName AS "Person/Name/Last",
    EmailAddress AS "Person/Email"
    FROM Person.Person p
    INNER JOIN Person.EmailAddress e
    ON p.BusinessEntityID = e.BusinessEntityID
    INNER JOIN Person.PersonPhone pp
    ON p.BusinessEntityID = pp.BusinessEntityID
    FOR XML PATH('ElementName'),ROOT('RootName');
    replace ElementName and RootName with whatever name you need to set for element as well as the root element
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • XML load using PL/SQL (XSU) problem with dtd file.

    Hi,
    I'm trying to load a xml file and receives this errormassage:
    SQL> exec loadxml;
    In Exception
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.xml.sql.OracleXMLSQLException: Error opening external DTD
    'Businesscard.DTD'.
    Any idea what I can change? Below is the things I've done and also how the xml file looks
    and the dtd file.
    Regards
    Jorgen
    CREATE DIRECTORY XML_DIR AS 'C:\XML';
    CREATE TABLE XML_TEMP (key NUMBER, f_lob BFILE);
    INSERT INTO XML_TEMP VALUES (1,BFILENAME('XML_DIR','TeleAdressVKI0209021728.xml'));
    CREATE TABLE XML_DOC (
    Key1 VARCHAR2(32),
    Key2     VARCHAR2(32),
    Key3 VARCHAR2(32),
    Terminate     VARCHAR2(3),
    LegalName     VARCHAR2(420),
    PopName          VARCHAR2(420),
    StreetName     VARCHAR2(60),
    StreetNumber     VARCHAR2(10),
    PostNumber     VARCHAR2(10),
    PostAdress VARCHAR2(30),
    CordinateLevel     VARCHAR2(32),
    xCor          VARCHAR2(10),
    yCor VARCHAR2(10),
    PoiCategory VARCHAR2(32),
    Telephone VARCHAR2(30));
    CREATE OR REPLACE PROCEDURE loadxml AS
    fil BFILE;
    buffer RAW(32767);
    len INTEGER;
    insrow INTEGER;
    BEGIN
    SELECT f_lob INTO fil FROM xml_temp WHERE key = 1;
    DBMS_LOB.FILEOPEN(fil,DBMS_LOB.FILE_READONLY);
    len := DBMS_LOB.GETLENGTH(fil);
    DBMS_LOB.READ(fil,len,1,buffer);
    xmlgen.resetOptions;
    insrow := xmlgen.insertXML('xml_doc',UTL_RAW.CAST_TO_VARCHAR2(buffer));
    DBMS_OUTPUT.PUT_LINE(insrow);
    IF DBMS_LOB.FILEISOPEN(fil) = 1 THEN
    DBMS_LOB.FILECLOSE(fil);
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('In Exception');
    DBMS_OUTPUT.PUT_LINE(SQLERRM(SQLCODE));
    IF DBMS_LOB.FILEISOPEN(fil) = 1 THEN
    DBMS_LOB.FILECLOSE(fil);
    END IF;
    end;
    The xml file look like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE Cards SYSTEM 'Businesscard.DTD'>
    <Cards>
    <Comment>TeleAdress initial</Comment>
    <OldFile>xxxx</OldFile>
    <NewFile>xxxx</NewFile>
    <Card>
    <Key1>95352</Key1>
    <Key2>159651</Key2>
    <Key3>3807868</Key3>
    <Terminate>no</Terminate>
    <Cardholder>
    <LegalName>
    <Name>
    <Full>AXFOOD DIREKT AB</Full>
    </Name>
    </LegalName>
    <PopName>
    <Name>
    <Full>WILLYS LEGPRIS AB</Full>
    </Name>
    </PopName>
    </Cardholder>
    <Location>
    <Address>
    <StreetInfo>
    <StreetName>BAGARBYVDGEN</StreetName>
    <StreetNumber>61</StreetNumber>
    </StreetInfo>
    <ZipCode>19134</ZipCode>
    <City>SOLLENTUNA</City>
    <Coordinate>
    <Level>1</Level>
    <xCor>1620480</xCor>
    <yCor>6592717</yCor>
    </Coordinate>
    </Address>
    <Business>
    <POI>
    <POIId>46</POIId>
    <POIId>84</POIId>
    </POI>
    <InfoRow>
    <Subscriptions>
    <TelAddress>08 6234540</TelAddress>
    </Subscriptions>
    </InfoRow>
    </Business>
    </Location>
    </Card>
    <Card_Count>1</Card_Count>
    </Cards>
    the dtd file looks like this:
    <!-- BusinessCard.dtd -->
    <!-- History:          See end of this file -->
    <!-- Description:      This DTD is used for transferring business cards-->
    <!--               from TeleAdress Information AB to its customers. -->
    <!--===================== Root Element ===========================-->
    <!ELEMENT     Cards     (Comment,OldFile?,NewFile,Card*,Card_Count)>
         <!ELEMENT     Comment                         (#PCDATA)>
         <!ELEMENT     OldFile                         (#PCDATA)>
         <!ELEMENT     NewFile                         (#PCDATA)>
    <!--===================== Card ============================-->
    <!ELEMENT     Card     (Key1, Key2, Key3, Terminate, (RegNo?, Cardholder, Row*)?)>
         <!ELEMENT     Key1          (#PCDATA)>
         <!ELEMENT     Key2          (#PCDATA)>
         <!ELEMENT     Key3          (#PCDATA)>
         <!ELEMENT     Terminate     (#PCDATA)> <!-- Values can be yes or no-->
    <!--====================== Cardholder ============================-->
    <!ELEMENT     Cardholder     (RegNo, OrgType, LegalName, PopName?, Location)     >
         <!ELEMENT     RegNo          (#PCDATA)>
         <!ELEMENT     OrgType          (#PCDATA) >
    <!--====================== RegName ==================================-->
    <!ELEMENT     LegalName          (Name)>
    <!--====================== PopName ==================================-->
    <!ELEMENT     PopName          (Name+)>
    <!--====================== Location ==================================-->
    <!ELEMENT     Location          (Adress+, Unit*, Business)>
    <!--====================== Unit ==================================-->
    <!ELEMENT     Unit          (UnitNo, UnitName?, Status, HQ, SNI1?, SNI2?, SNI3?, WorkPlaceNo, WorkPlaceName?)>
         <!ELEMENT     UnitNo          (#PCDATA)>
         <!ELEMENT     UnitName     (#PCDATA)>
         <!ELEMENT     Status          (#PCDATA)>
         <!ELEMENT     HQ          (#PCDATA)> <!-- Values can be yes or no-->
         <!ELEMENT     SNI1          (#PCDATA)>
         <!ELEMENT     SNI2          (#PCDATA)>
         <!ELEMENT     SNI3          (#PCDATA)>
         <!ELEMENT     WorkPlaceNo     (#PCDATA)>
         <!ELEMENT     WorkPlaceName     (#PCDATA)>
    <!--====================== Business ==================================-->
    <!ELEMENT     Business          (POI?, InfoRow*)>
    <!--====================== POI =======================================-->
    <!ELEMENT     POI          (POIId+)>
         <!ELEMENT     POIId          (#PCDATA)>
    <!--====================== InfoRow ===================================-->
    <!ELEMENT     InfoRow          (Number,Heading*,Name?, Address?, Text?, HomePageAddresses?, EMailAddresses?, Subscriptions?)>
         <!ELEMENT     Number          (#PCDATA)>
    <!--====================== Heading =================================-->
    <!ELEMENT     Heading          (LevelNo, LevelName)>
         <!ELEMENT      LevelNo          (#PCDATA)>
         <!ELEMENT     LevelName     (#PCDATA)>
    <!--====================== Name =================================-->
    <!ELEMENT     Name          (Full,First?,Middle?,Last?)>
         <!ELEMENT      Full          (#PCDATA)>
         <!ELEMENT     First          (#PCDATA)>
         <!ELEMENT     Middle          (#PCDATA)>
         <!ELEMENT     Last          (#PCDATA)>
    <!--====================== Address ==============================-->
    <!ELEMENT     Address               (Type, StreetInfo?,TextBeforeZipCode?,ZipCode?,City?,AReg?,
                             Municipality?,County?,Country?,Coordinate?)>
         <!ELEMENT     Type               (#PCDATA)>     
         <!--====================== StreetInfo ==============================-->
         <!ELEMENT     StreetInfo          (PostBox?, StreetName?,StreetNumber?,Entrance?, CO?)>
              <!ELEMENT     PostBox               (#PCDATA)>
              <!ELEMENT     StreetName          (#PCDATA)>
              <!ELEMENT     StreetNumber          (#PCDATA)>
              <!ELEMENT     Entrance          (#PCDATA)>
              <!ELEMENT     Co               (#PCDATA)>
         <!ELEMENT     TextBeforeZipCode     (#PCDATA)>
         <!ELEMENT     ZipCode               (#PCDATA)>
         <!ELEMENT     City               (#PCDATA)>
         <!ELEMENT     AReg               (#PCDATA)>     
         <!ELEMENT     Municipality          (#PCDATA)>
         <!ELEMENT     County               (#PCDATA)>
         <!ELEMENT     Country               (#PCDATA)>
         <!--====================== Coordinate ==============================-->
         <!ELEMENT     Coordinate          (Level, xCor,yCor)>
              <!ELEMENT     Level          (#PCDATA)>
              <!ELEMENT     xCor          (#PCDATA)>
              <!ELEMENT     yCor          (#PCDATA)>
    <!--====================== Text =================================-->
    <!ELEMENT     Text          (InfoText+)>
         <!ELEMENT     InfoText          (#PCDATA)>     
    <!--====================== HomePageAddresses =================================-->
    <!ELEMENT     HomePageAddresses          (HomePage+)>
         <!ELEMENT     HomePage          (#PCDATA)>     
    <!--====================== EMailAddresses =================================-->
    <!ELEMENT     EMailAddresses          (EMail+)>
         <!ELEMENT     EMail          (#PCDATA)>     
    <!--======================= Subscriptions ===========================-->
    <!ELEMENT     Subscriptions     (ClassifiedCode?, Type, TelAddress, TextAfter?)     >
         <!ELEMENT     TelAddress     (#PCDATA)>
         <!ELEMENT     TextAfter     (#PCDATA)>
    <!ELEMENT     Card_Count               (#PCDATA)>
    <!--==============================================================-->
    <!-- History:          2002-06-06 created this file -->
    <!--                2002-07-04 Added Source on Coordinates -->
    <!--               2002-08-15 Changed Source to Level -->
    <!--               2002-08-15 Changed RegName to LegalName-->

    I've got the same problem,
    How to define the directory in witch the DTD is????
    We need something like DBMS_XMLSave.setdirectoryDTD, that doesn't exist.
    ben
    ERREUR ` la ligne 1 :
    ORA-29532: appel Java arrjti par une exception Java non interceptie :
    oracle.xml.sql.OracleXMLSQLException: Error opening external DTD
    'annoncesv22.dtd'.
    ORA-06512: ` "SDEV.SIMPORT", ligne 205
    ORA-06512: ` ligne 1

  • Parsing an xml document using  XPATH

    Hello,
    I am pretty new to programming "Java and XML" and right now very confused with the range of available xml parsers,xpath engines and xslt processors.I need some guidance on how to parse a xpath expression with variables in it .
    Thanks,
    Chan.

    Gregory . Thank you so much for the insight into parsing and xpath expression evalaution . I downloaded the XpathExamples.java file , practical xml jar file and executed the program to see the output for various example functions that you have created .All of them worked perfectly without any issues.
    In the variablesExample() function , I added the following lines to check if it works :
    variables.put(new QName("myvar"), "foo");
    System.out.println("myvar bound as 'argle' = " + xpath.evaluate("/$foo/bar/baz", dom));
    I ran into exceptions like ..
    Exception in thread "main" javax.xml.transform.TransformerException: Extra illegal tokens: '$', 'foo', '/', 'bar', '/', 'baz'
    Can you please tell me what was I doing wrong ? I am also planning to use starts-with() function in xpath expression . Will it work ?
    Thank you for your reasoning.

  • 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.

  • Remove XML node using Xpath

    Hello,
    I'm using J Developer/SOA Suite 11.1.1.6.0 and BPEL 2.0
    I am trying to remove datetime nodes from xml, where the datetime value equals a certain value.  So far I have the following BPEL code:
      <assign name="RemoveEmptyDates">
          <extensionAssignOperation>
            <bpelx:remove>
              <bpelx:target>$GetNewHires_GetWrittenOffersReadyForUpload_OutputVariable.parameters//*[ . instance of xsd:dateTime and xsd:dateTime(.) = xsd:dateTime('0001-01-01T00:00:00')]</bpelx:target>
            </bpelx:remove>
          </extensionAssignOperation>
        </assign>
    I have tried multiple variations of the predicate, but I can't seem to figure it out.  Right now I am getting an error in J Developer that specifies it is expecting an "]" right after the "//*[." portion of the predicate.  Any ideas on this would be greatly appreciated.
    Thanks

    You can't use spaces.
    you have wrong this part of your text:
    [ . instance of xsd:dateTime and xsd:dateTime(.) = xsd:dateTime('0001-01-01T00:00:00')]
    check it.

  • How to Get and Update properties values from XML tag Using Xquery or PL Sql

    Hi
    I have this tag
    <Solicitud Pais = "1">
    How i can get Pais value?
    How i can update Pais Value?
    Y can use Xquery funtions or PL SQL for this?
    Thak's
    Angel

    How i can get Pais value? ExtractValue
    How i can update Pais Value?UpdateXML
    Y can use Xquery funtions or PL SQL for this?Yes
    Without knowing more about your requirements, where information resides, or even a version of Oracle, that is the best I'll do.

  • XML Signature using an XPath filter

    I want to sign an XML document, just based on the content of a particular element in the document. Based on the jwsdp docs it looked pretty simple, but I'm getting strange results. I'll get the same digest value in the SignedInfo for different Xpath filter strings.
    Anybody out there have good luck trying to sign XML documents using Xpath filters?
    I'm using JDK 1.5.05 and JWSDP 1.6.
    Here is my simple XML doc
    <?xml version="1.0" encoding="UTF-8"?>
    <myns:whole_doc xmlns:myns="http://namespace.myns.com/test"
    attr1="attr_one" attr2="attr_two" attr3="attr_three">
    <myns:part_one attr="attr_one">
    <myns:tag1>this is part_one tag_one</myns:tag1>
    <myns:tag2>this is part_one tag_two</myns:tag2>
    </myns:part_one>
    <myns:part_two attr="attr_two">
    <myns:tag1>this is part_two tag_one</myns:tag1>
    <myns:tag2>this is part_two tag_two</myns:tag2>
    </myns:part_two>
    <myns:part_three attr="attr_three">
    <myns:tag1>this is part_three tag_one</myns:tag1>
    <myns:tag2>this is part_three tag_two</myns:tag2>
    </myns:part_three>
    </myns:whole_doc>
    When I use an XPath filter = "/myns:whole_doc/myns:part_one" I get the same digest as when I use "/myns:whole_doc/myns:part_two", which is the same digest when I don't use XPath filtering. See example output below
    <?xml version="1.0" encoding="UTF-8" ?>
    - <myns:whole_doc xmlns:myns="http://namespace.myns.com/test" attr1="attr_one" attr2="attr_two" attr3="attr_three">
    - <myns:part_one attr="attr_one">
    </myns:part_three>
    - <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    - <SignedInfo>
    <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments" />
    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1" />
    - <Reference URI="">
    - <Transforms>
    <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
    - <Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
    <XPath>/myns:whole_doc/myns:part_two</XPath>
    </Transform>
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
    <DigestValue>9D5CFDkWd9bHx65txuHOeXWeTns=</DigestValue>
    </Reference>
    </SignedInfo>
    <SignatureValue>D686H//H5A0zDrlQx8+0fBNpVeJGgWdTXivlI8S/+WqB/E4oBYzeIQ==</SignatureValue>
    </Signature>
    </myns:whole_doc>

    It took me all day, but I did find the answer.
    When using XPath filters in references, you can't use XPath exactly the way you would use XPath to find nodes in a document. I can't exactly explain why, but it has to do with the fact that the XPath statement is acting as a filter.
    Anyway, to just include the part_one element from the following abbreviated XML
    <myns:whole_doc> .....
    <myns:part_one> ..... </myns:part_one>
    <myns:part_two> .... </myns:part_two>
    </myns:whole_doc>
    the XPath statement should be "ancestor-or-self::myns:part_one"
    to make sure that part_one was part of whole_doc you could use something like
    (ancestor-or-self::node() = /myns:whole_doc/myns:part_one)
    This allows me to sign a document, but still allow portions outside of whole_doc/part_one to change.

  • Set XML attribute from SetValue using Xpath

    Is there a trick to assigning a value to an attribute of an element in an XML variable using XPATH inside a setValue activity?  When I try something like
    Location
    /process_var/xml_var/test/@ID
    Expression:
    /process_var/test_value
    it complains about the @ sign in the location assignment.  I seem to be able to retrieve attributes just fine.

    Still having this issue.
    If I have an XML process variable which currently contains
    <Document>
        <Title />
        <Author />
        <Date />
    </Document>
    Try this, it fails.
    Location: /process_data/xml/Document/@ID
    Expression: 54
    Try this, it works.
    Location: /process_data/xml/Document/ID
    Expression: 54
    Now, alter the XML by adding an ID attribute
    <Document ID="">
        <Title />
        <Author />
        <Date />
    </Document>
    Try this, it works, where it failed earlier.
    Location: /process_data/xml/Document/@ID
    Expression: 54
    It appears to me, you can ADD a new node, but you can't ADD an attribute

  • Error while printing generated XML doc using DBMS_OUTPUT

    while generating XML document using XDK for PL/SQL i am getting " ORU-10027: buffer overflow, limit of 1000000 bytes " error even though i had set DBMS_OUTPUT to 1000000.
    Is there any way to getrid of this problem .
    i am using this code ..
    CREATE OR REPLACE procedure SQLToXML1 is
    queryCtx DBMS_XMLquery.ctxType;
    result CLOB;
    begin
    DBMS_OUTPUT.ENABLE (1000000);
    queryCtx := DBMS_XMLQuery.newContext ('select * from depolib_library' )
    result := DBMS_XMLQuery.getXML(queryCtx);
    printClobOut(result);
    DBMS_XMLQuery.closeContext(queryCtx);
    exception
    when others then
    dbms_output.put_line(sqlerrm);
    end;
    urgent help is needed
    Thanks
    null

    No, It is a PO Print only. Only for changes to PO that do not affect the value of the PO,this error occurs. When i select the entry for the PO and click on Output message, the output message fails. On clicking Display Message, it shows the message - No schedules exist for the Scheduling Agreement XXXXXX(the PO number".
    So,it is not for Scheduling Agreements but for PO only. I know it is weird to see such an error on the PO output message in ME9F.
    Pls help.

  • Using xpath expressions in Document-Builder

    Hi all
    we have re-designed our (existing) DDX-templates with the Document Builder in LC Workbench. The DDX templates are used to assemble PDFs with LC Assembler-Service.
    Now my question: Is it still possible to use XPath-expression in the DDX template? Please find our example below:
    The XPath expression works only if we copy&paste the DDX source code directly to the Assembler-Service property view (picture below). But referring the DDX-template doens't interpret the xpath path at run time (2nd picture below). Any help on that will be appreciated!
    Works (using DDX source code directly):
    Doesn't work (using DDX template):

    Hi,
    >
    I tried to get a portion of an XML by using XPath Expressions as follows:
    String xPathExpression =
    "declare namespace xq='http://inti.notariado.org/indices' " +
    "$this/xq:RULES/xq:RULE[@disabled]";
    I think any XPath expressions which use [] are not supported in stand alone
    version, but as this is not documented I could be wrong.
    Regards
    Arek

  • How do I retrive date field using Xpath

    How do I retrive data,which is in date format in XML file using XPath query.
    If this is not possible, Is there any other alternative?
    Bye

    Hi,
    If suppose my xml file is like this,
    <Xml>
    <DataSet>
         <BirthDate>1-Sep-1980</BirthDate>
         <BirthDate>6-Aug-1982</BirthDate>
         <BirthDate>3-Sep-1981</BirthDate>
         <BirthDate>12-Jan-1985</BirthDate>
         <BirthDate>1-Sep-1979</BirthDate>
    </DataSet>
    </Xml>
    If I want to retrive Data,BirthDate between 1-Jan-1981 and 1-Jan-1984
    How do I do that?
    If it is not possible directly,Is there any other alternative?
    Bye

  • C++ sample code using XPATH

    Need to navigate an XML and extract xml nodes using XPATH expressions in C++ Application.
    Please send us a C++ code sample using Oracle 9.2.0.3 XPATH API functions to extract an XML using XPATH expression.
    Thanks
    Shiva

    Hi,
    Where i can find this path "$XDK_HOME\xdk\demo\c\xslt"
    thanks in advance
    shashi.

  • Parse xml document with xpath

    I would like to parse an xml document using xpath, see:
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    however, in the documentation (in the link above), it states that I need J2SE 5.0.
    Currently, I have:
    $ java -version
    java version "1.5.0_11"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)
    Does that mean that I really have to install J2SE 5.0 in order to use J2SE 5.0's XPath support? Does anybody know anything about getting started with XPath, and whether I can just use my existing version of Java? I've never used XPath.
    For more documentation, one can view:
    http://www.w3.org/TR/xpath20/
    Thank you.

    I have copied the code for the xpath tutorial on
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html
    exactly as it is on the tutorial, and imported the correct jars (I think).
    But still my code is giving lots of errors!
    Granted its my first shot but anyway here's the code and the errors...
    package test;
    import org.jdom.xpath.*;
    import java.io.*;
    import javax.xml.xpath.*;
    public class XPath {
         public static void main (String [] args){
              XPathFactory factory = XPathFactory.newInstance();
              XPath xPath=factory.newXPath();
              XPathExpression  xPathExpression=xPath.compile("/catalog/journal/article[@date='January-2004']/title");
              File xmlDocument = new File("/home/myrmen/workspace/Testing/test/catalog.xml");     
              //FileInputStream fis = new FileInputStream(xmldocument); 
              InputSource inputSource = new InputSource(new FileInputStream(xmlDocument));
              String title = xPathExpression.evaluate(inputSource);
              String publisher = xPath.evaluate("/catalog/journal/@publisher", inputSource);
              String expression="/catalog/journal/article";
              NodeSet nodes = (NodeSet) xPath.evaluate(expression, inputSource, XPathConstants.NODESET);
              NodeList nodeList=(NodeList)nodes;
              SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
              org.jdom.Document jdomDocument = saxBuilder.build(xmlDocument);
              org.jdom.Attribute levelNode = (org.jdom.Attribute)(XPath.selectSingleNode(jdomDocument,"/catalog//journal[@title='JavaTechnology']" + "//article[@date='January-2004']/@level"));
              levelNode.setValue("Intermediate");
              org.jdom.Element titleNode = (org.jdom.Element) XPath.selectSingleNode( jdomDocument,"/catalog//journal//article[@date='January-2004']/title");
              titleNode.setText("Service Oriented Architecture Frameworks");
              java.util.List nodeList = XPath.selectNodes(jdomDocument,"/catalog//journal[@title='Java Technology']//article");
              Iterator iter=nodeList.iterator();
              while(iter.hasNext()) {
                   org.jdom.Element element = (org.jdom.Element) iter.next();
                   element.setAttribute("section", "Java Technology");
              XPath xpath = XPath.newInstance("/catalog//journal:journal//article/@journal:level");
              xpath.addNamespace("journal", "http://www.w3.org/2001/XMLSchema-Instance");
              levelNode = (org.jdom.Attribute) xpath.selectSingleNode(jdomDocument);
              levelNode.setValue("Advanced");
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         Type mismatch: cannot convert from XPath to XPath
         The method compile(String) is undefined for the type XPath
         InputSource cannot be resolved to a type
         InputSource cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeSet cannot be resolved to a type
         NodeList cannot be resolved to a type
         NodeList cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         SAXBuilder cannot be resolved to a type
         The method selectSingleNode(Document, String) is undefined for the type XPath
         The method selectSingleNode(Document, String) is undefined for the type XPath
         Duplicate local variable nodeList
         The method selectNodes(Document, String) is undefined for the type XPath
         Iterator cannot be resolved to a type
         The method newInstance(String) is undefined for the type XPath
         The method addNamespace(String, String) is undefined for the type XPath
         The method selectSingleNode(Document) is undefined for the type XPath
         at test.XPath.main(XPath.java:12)

  • How to? regarding adding xml parent tag in generated xml script using C# scripting

    Hi All,
    I have a set of transformations, which will generate xml data by reading rows from database
    here is my data flow https://social.msdn.microsoft.com/Forums/getfile/606619
    <Customer> 
    <CustomerId>1</CustomerId> 
    <Name></Name> 
    <Title></Title> 
    <Phone>1 (11) 500 555-0162</Phone> 
    <Gender>F</Gender> 
    <MaritalStatus>S</MaritalStatus> 
    <YearlyIncome>70000</YearlyIncome> 
    <BirthDate>15-02-1968 12:00:00</BirthDate> 
    <EmailAddress>[email protected]</EmailAddress> 
    <CustomerKey>11003</CustomerKey> 
    </Customer> 
    <Customer> 
    <CustomerId>2</CustomerId> 
    <Name></Name> 
    <Title></Title> 
    <Phone>1 (11) 500 555-0131</Phone> 
    <Gender>F</Gender> 
    <MaritalStatus>S</MaritalStatus> 
    <YearlyIncome>80000</YearlyIncome> 
    <BirthDate>08-08-1968 12:00:00</BirthDate> 
    <EmailAddress>[email protected]</EmailAddress> 
    <CustomerKey>11004</CustomerKey> 
    </Customer> 
    my problem is I am not able to add <?xml version="1.0" encoding="UTF-8"?> (xml tag) to output folder, which should be just at the beginning of xml file. 
    I am a beginner in SSIS, any help/hints will be appreciated.
    Regards,
    Mateen

    Why not do it in t-sql?
    http://visakhm.blogspot.in/2014/05/t-sql-tips-fun-with-for-xml-path.html
    http://visakhm.blogspot.in/2013/12/generating-nested-xml-structures-with.html
    If you want to do it in SSIS use this
    http://bicortex.com/how-to-create-an-xml-file-using-ssis-and-ms-sql-server/
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for

  • Print Layourt Designer how to migrate a report from one SBO to another

    I have written a report on my Test version of SBO and need to migrate it to the customers site but cant see a method of exporting/Importing a User Report (I am probably missing something obvious though.....) but would appreciate a prod in the right d

  • How to create dependent LOV based on procedure?

    Hi, There are two dependent list of values which i need to create. There is an existing package which returns the list. Can you suggest which approach should i use to create these list. Should i execute the procedure in the IMPL class and then bind t

  • How to convert a timestamp to date/time in CDS View?

    Dear experts, I would like to convert a timestamp to a date and time within a CDS view. This is what I tried to do: Cast (Cast(<timestamp> as abap.dec(8,0)) as abap.dats) as <date> I also thought about first converting the timestamp into a plain nume

  • Change pointers for PDS

    Hi Gurus, I am not able to transfer the changes to BOMs in ECC. I am using the transaction CURTO_CREATE_BOM. This transaction is not picking up the changes in BOM. Are there any SAP Standard change pointers that I need to activate to enable change tr

  • Case expression in SQL

    Hello every one, I am trying case it is giving me an error of missing expression, not sure what am i missing. It in the document. http://download-east.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90125/expressions5.htm#1033394 SQL> ed Wrote file