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.
Similar Messages
-
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. -
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 ChangHi 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 -
How to select a specific XML node with XPath
Hi,
I'm trying to a select a specific node from my XML data using the XPath Builder. For example, say I have a process variable 'xmlData' with the
following contents:
User 1
101
User 2
102
I can successfully use the following expression to retrieve the name of
a specific user:
(/process_data/xmlData/users/user[userid='102'])/name
The problem is I need to use another process variable for the selection
key. For Example:
(/process_data/xmlData/users/user[userid=/process_data/@userId])/name
But this always returns null. I've tried surrounding /process_data/@userId
with single quotes, double quotes, and event {$..$}.
Any help would be greatly appreciated.
Thanks.Hi,
Thanks for the quick replies. I gave a bit of a bad example, as the
userid in my data is really a string, not a number.
A better example is:
User 1
user1
User 2
user2
I can get the following to work perfectly:
(/process_data/xmlData/users/user[userid='user2'])/name
but I can't get it to work with
/process_data/@userId = "user2"
(/process_data/xmlData/users/user[userid=/process_data/@userId])/name
Thanks. -
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 -
How to retrieve a node using xpath in java
Hi,
I need to make an application in which on click of a button an xml is
displayed on the browser.
Now when a user selects a node in the xml then i need the xpath of the selected node for some processing.
How to retrieve the xpath.
I am using Struts framework.There is not a specific method for achieving this.
You can store the whole xml document into a defined
structure. And get the needed xpath by some index.Yes i know that i'll need to store the file.
But my XML is fixed and the same XML is used everytime.
Now the structure of the XML is like it has same named nodes inside the parent node.
example :
<Human>
<Person>
<Person></Person>
<Person>
<Person><name>fsfsdsdf</name></Person>
</Person>
</Person>
<Human>
Now if the user selects the person node which contains name node then how to get the XPATH.
Can u help regarding the same........ -
Hello,
i am using a scroll panel component with an instance name of
photoScroll on the stage. This scroll panel is linked to an xml
page which contains the names of the thumbnails and the jpgs.
When you click on the thumbnail it loads the corresponding
jpg beside the scroll panel. Also on the stage, there is a button
which moves the timeline along and also removes the scroll panel.
The problem is that the jpg which was loaded remains on the stage.
I can't figure out how to get rid of it. I really need help, i've
been on this for days!
Here is my code (the jpgs are found in the <data> node
of the xml page). "hor" is the button that must remove the scroll
panel and the lingering jpg.
thanks!
stop();
import flash.events.MouseEvent;
import com.afcomponents.scrollpanel.ScrollPanelEvent;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
import flash.net.navigateToURL;
photoScroll.addEventListener(ScrollPanelEvent.XML_LOAD_COMPLETE,
loadComplete);
function loadComplete(event:ScrollPanelEvent){
photoScroll.addGenericItemEventListener(MouseEvent.CLICK,
playOnClick);
function playOnClick(event:MouseEvent) {
var imageLoader:Loader = new Loader();
var myRequest:URLRequest = new
URLRequest(event.target.data);
imageLoader.load(myRequest);
addChild(imageLoader);
imageLoader.y = 117;
imageLoader.x = 435;
hor.buttonMode = true;
hor.addEventListener (MouseEvent.CLICK,funchor);
hor.addEventListener (MouseEvent.CLICK,removeScroll);
function funchor (e:MouseEvent):void
gotoAndPlay(currentFrame+1);
addFrameScript (currentFrame+5, skipFrame);
function skipFrame ()
gotoAndPlay (29);
function removeScroll(event:MouseEvent) {
removeChild(photoScroll);
}Hi,
Actually i have to process multiple purchase orders which is coming from IDOC and when i didn't use the parent node i am getting all the purchase orders and then purchase order header followed with details,
But i need the detials records and purchase order header corresponding to the purchase order, so for that i have define parent node, but at the output i dont require this parent node..
i mean the output shuld look like below by removing parent node.
mt_receiver
HeaderNode
--Field1
--Field2
PurchaseOrder
--Field1
--Field2
PurchaseHeader
--Field1
--Field2
Details
--Field1
--Field2
--Field3
PurchaseOrder
--Field1
--Field2
PurchaseHeader
--Field1
--Field2
Details
--Field1
--Field2
--Field3
i think you understand now..
regards,
sai -
Convertion of String to XML node using Xquery transformation in OSB
How to convert string to XML node elementusing a built in function using Xquery transformation in OSB?
check this out - http://www.javamonamour.org/2011/06/fn-beainlinedxml.html
if in SOA (BPEL & Mediator) you can use oraext:parseXML.
you should thoroughly analyse where to implement your requirement as some good practices advise to implement more complex logic in SOA and leave OSB to only connect to the services' endpoints.
Hope this helps,
A. -
Can't convert string element to XML node using XSL
We have a source XML with a node that contains another XML as string. Like this:
"<imp1:payload><?xml version = '1.0' encoding = 'ISO-8859-15' standalone = 'no'?>
<!-- Oracle eXtensible Markup Language Gateway Server --><!DOCTYPE PROCESS_PO_007 SYSTEM "003_process_po_007.dtd"><PROCESS_PO_007><CNTROLAREA>" etc
And we have a target XML that has the schema inside the string in the source file, like this:
"<PROCESS_PO_007>
<CNTROLAREA>"....etc.
How can we "parse" the string to a node using an XSL transformation file?Hi,
Can you tell me which code are you using currently for transferrring the data? It might help me to figure out what your problem is. -
Edit XML node using actionscript?
How would I go about editing an XML node from within
actionscript?
I load the XML from a file, and before I pass it to an
HTTPService I would like to set the field DateTime. The XML file
that I am using can be seen here:
XML Document
When I try doing something like
myXML.fiAPI.fiHeader.Service.DateTime="time here", it creates a new
fiAPI node with all new children. However, I wish to edit the
current DateTime field without creating a new one.
All help is appreciated.Thanks to both of you.
ctzn99: I tried that as well, after realizing my mistake.
However, it still does not work. I'm certain I have the path right,
but nothing is set (or in other cases, returned). Even when I use
myXML.fiHeader..., It creates a new fiHeader node and the
corresponding nodes underneath it.
ntsiii: That's a very complex example, like you said...
almost overkill for my problem?
Thanks though! -
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. -
Remove xml element using JS[CS3]
Hi, I have an xml structure where i want to remove some paritcular element named "extlink".
I do have one script with me but it doesn't wipe out all specific xml element from structure.
var myDoc = app.activeDocument;
var foundtext = 0
Query_Remove (myDoc);
alert ("You have removed " + foundtext + " " +" Link !!")
exit (0);
function Query_Remove(elm)
try
for(var i=elm.xmlElements.length-1; i>=0; i--)
if((elm.xmlElements[i].markupTag.name == "extlink") && (elm.xmlElements[i].xmlElements[0].markupTag.name == "http"))
var Store_CitAttri = elm.xmlElements[i].xmlElements[0].xmlAttributes.item("c_style").value;
if(Store_CitAttri == "URL")
elm.xmlElements[i].remove();
foundtext = foundtext + 1;
Query_Remove(elm.xmlElements[i]);
catch (e){
Some time it skip the element from all figure captions and some time from body text and some time it works perfectly
Could any one figure it out why this script behaviour is not consistent as i am new to scripting and not getting any idea about this.
Thanks
MacOkay, after peering over your code and trying a few things out I see one immediate problem and one possible improvement.
The problem lies in this:
1. if condition is true, remove item
2. check recursively
The problem is .. if an item is removed, the following recursive check will always fail. However, the entire loop is wrapped into a try..catch, so InDesign will not alert you that it failed. Instead, it will continue with what's after the loop, exactly because the try..catch is around the entire loop!
Change the loop code to this
if((elm.xmlElements[i].markupTag.name == "http") && (elm.xmlElements[i].parent.markupTag.name == "extlink"))
var Store_CitAttri = elm.xmlElements[i].xmlAttributes.item("c_style").value;
if(Store_CitAttri == "URL")
elm.xmlElements[i].remove();
foundtext = foundtext + 1;
continue;
Query_Remove(elm.xmlElements[i]);
so the recursive checking is skipped. You can also remove the entire try..catch block, as this may hide additional errors ...
The improvement is: as I started reading this thread from the top again, shouldn't you be removing the "extlink" items, rather than just the "http" ones inside?
If so, remove the parent of the found item (which is always the "extlink"):
elm.xmlElements[i].parent.remove();
-- and, as this will break the loop (because you just removed the set of elements it was working in!), replace 'continue' with 'return'.
Hope this helps -
Remove xml node based on value
Hi,
we have to remove elements bases on the value.
for example consider below xml
<htl:room>
<htl:ratePlan>
<htl:freeNights>12</htl:freeNights>
<htl:promoSavings>undefined</htl:promoSavings>
<htl:tax>undefined</htl:tax>
</htl:ratePlan>
<htl:guestAllocation>1,2</htl:guestAllocation>
</htl:room>
We have to remove elements with value undefined and should construct a new xml as below
<htl:room>
<htl:ratePlan>
<htl:freeNights>12</htl:freeNights>
</htl:ratePlan>
<htl:guestAllocation>1,2</htl:guestAllocation>
</htl:room>
please help.
Thanksi assume that loc always corresponds to name. So to find the rows to remain is just a simple group by
with data as(
select 'aaa' name,'a1' loc,10 count from dual union all
select 'aaa','a1',0 from dual union all
select 'bbb','b1',0 from dual union all
select 'ccc','c1',0 from dual union all
select 'dcc','d1',11 from dual union all
select 'dcc','d1',0 from dual )
select
name
, loc
, max(count) cnt
from data
group by
name
, loc
order by
name
, loc
NAME LOC CNT
aaa a1 10
bbb b1 0
ccc c1 0
dcc d1 11to find the other is just a minus
with data as(
select 'aaa' name,'a1' loc,10 count from dual union all
select 'aaa','a1',0 from dual union all
select 'bbb','b1',0 from dual union all
select 'ccc','c1',0 from dual union all
select 'dcc','d1',11 from dual union all
select 'dcc','d1',0 from dual )
select name,loc,count from data
minus
select
name
, loc
, max(count) cnt
from data
group by
name
, loc
order by
name
, loc
NAME LOC COUNT
aaa a1 0
dcc d1 0so a delete would be
delete from data
where
(name,loc,count)
in
(select name,loc,count from data
minus ..regards -
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
ShivaHi,
Where i can find this path "$XDK_HOME\xdk\demo\c\xslt"
thanks in advance
shashi. -
Convertion of XML node to string using Xquery transformation in OSB
How to convert XML node to string using a built in function using Xquery transformation in OSB? In BPEL we have the Xpath extension function ora:getContentAsString() to do the same.
fn:bea-serialize() function converts xml node to string. but it assigns namespace prefix in every xml node during the conversion. So is there any function to remove the namespace prefix from XML node using Xquery built in function?
Maybe you are looking for
-
dear can i configre a report using SOP and not run mrp only for running report and these are the fields which i require These are the parameters required in that report 1. sales forecast(this is done annually with the monthly break up) 2. sales forec
-
hi gurus, In return sales we need excise duties automaticallt through J1IH. Is it possible,if yes pls let me know. regards Rams
-
Can I install Solaris 8 against an NT4 DNS Server?
Does anyone know whether this is possible using a plain vanilla NT4 PDC installation, including DNS Server service and a standard Solaris 8 installation on an Ultra 5 Sun box? Both will be running on a class C IP address, 192.168.0.x Is there anythin
-
After loading the native library through System.loadLibrary , we were unable to unload the dll , i have tried entering the Registry Values of current windows version creating key alwaysunloaddll to 1 and also through c/c++ Wrapper Classes Using JNI b
-
How to "save encrypted files to disk" in Safari
I'm trying to use a web-based case management database software based on Access through a Portal managed by Venture Technologies and using Citrix. I can go to the portal home page but the login procedure isn't working properly. The company (Venture)