snehams
(snehams *)
December 10, 2010, 5:47pm
1
Hi ,
I have Input Document “order” and say value of "/order/orderItems/x/y" = 3
In flow service, at run time i am reading the xpath(/order/orderItems/x/y) from config file .
lets say i m assigning the output of config file value to A.
So now A = /order/orderItems/x/y
So at runtime , how do i extract the value of y(which is 3)
If i give {%A%}, i will get the whole Xpath ie /order/orderItems/x/y
But it should be “3”.
Please help me in resolving this.
Use the following code to build a java service.
Note: this will only support Documents if you have document list or string list in the input document it will on support that structure.
Create a variable type String with name “xPath” in input.
create a document type with name"input" in put.
Create a String type with name “value” in output.
map your required document to the input doument and provide the path for the variable to retrieve as input xPath.Ex: test/abc/xyz/variable1
for the above input the service will get the value of variable1 from test/abc/xyz
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String xPath = IDataUtil.getString( pipelineCursor, “xPath” );
String path=xPath.split(“/”);
String value=“”;
// input
IData input = IDataUtil.getIData( pipelineCursor, “input” );
if ( input != null)
{
IDataCursor inputCursor = input.getCursor();
if(path.length>1)
{
for(int i=1;i<path.length;i++)
{
if(i<path.length-1)
{
input = IDataUtil.getIData( inputCursor, path[i] );
if ( input != null)
{
inputCursor = input.getCursor();
}
}
else
{
value = IDataUtil.getString( inputCursor, path[i] );
inputCursor.destroy();
}
}
}
else
value = IDataUtil.getString( inputCursor, path[path.length] );
inputCursor.destroy();
}
pipelineCursor.destroy();
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “value”, value );
pipelineCursor_1.destroy();
D.C
(D.C.)
December 11, 2010, 4:47am
3
hi
try built in pub.xml.queryXMLNode, you can use either XQL query or WQL query.
-regards,
DC
snehams
(snehams *)
December 13, 2010, 7:29pm
4
Deepan,
Can you pls explain me with one example on how to use pub.xml.queryXMLNode in my case?
Thanks in advance!!
D.C
(D.C.)
December 13, 2010, 9:34pm
5
Hi,
sample code here… hope this helps.
I would suggest you to read the builtin services guide, you might get a better idea!
-regards
DC
XQeryPackage.zip (7.45 KB)
snehams
(snehams *)
December 17, 2010, 1:16pm
6
Thanks a lot…!! it works now:)