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.
Thanks
i 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
Similar Messages
-
How to create xml nodes based on a value
Dear friends,
I've a question about graphical mapping in SAP PI...
How can I create XML nodes on the target side based on a value in a XML field on the source side.
For example:
This XML field on the source:
<NO_OF_LINES>4</NO_OF_LINES>
Must result on 4 Lines on the Target:
<LINE></LINES>
<LINE></LINES>
<LINE></LINES>
<LINE></LINES>
So it's actually the opposite of the Count function...
I appreciate your help,
Thank you in Advance,
Kind regards,
JohnHi ,
Try this
NO_OF_LINES---> count---> UDF---> LINE
example :
UDF Code :
for (int i=0;i<var1[0];i++)
result.addValue(""); -
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.
ThanksYou 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. -
Counting of XML nodes based on a condition
Hello,
I have following XML with me:
<?xml version="1.0" encoding="utf-8" ?>
<Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">
<Rowset>
<Columns>
<Column Description="Material Number" MaxRange="1" MinRange="0" Name="MAT" SQLDataType="1" SourceColumn="MAT"/>
<Column Description="Plant" MaxRange="1" MinRange="0" Name="WER" SQLDataType="1" SourceColumn="WER"/>
<Column Description="Storage Location" MaxRange="1" MinRange="0" Name="LGO" SQLDataType="1" SourceColumn="LGO"/>
<Column Description="" MaxRange="1" MinRange="0" Name="TANK" SQLDataType="1" SourceColumn="TANK"/>
<Column Description="Batch Number" MaxRange="1" MinRange="0" Name="BATCH" SQLDataType="1" SourceColumn="BATCH"/>
<Column Description="Valuated Unrestricted-Use Stock" MaxRange="1" MinRange="0" Name="CLABS" SQLDataType="8" SourceColumn="CLABS"/>
<Column Description="Quality Stock" MaxRange="1" MinRange="0" Name="CINSM" SQLDataType="8" SourceColumn="CINSM"/>
</Columns>
<Row>
<MAT>111</MAT>
<WER>US</WER>
<LGO>T1</LGO>
<TANK>T100</TANK>
<BATCH>2020</BATCH>
<CLABS>0</CLABS>
<CINSM>19.000</CINSM>
</Row>
<Row>
<MAT>222</MAT>
<WER>US</WER>
<LGO>T1</LGO>
<TANK>T100</TANK>
<BATCH>1010</BATCH>
<CLABS>1000000.000</CLABS>
<CINSM>0</CINSM>
</Row>
<Row>
<MAT>333</MAT>
<WER>US</WER>
<LGO>T1</LGO>
<TANK>T100</TANK>
<BATCH>1010</BATCH>
<CLABS>1000000.000</CLABS>
<CINSM>0</CINSM>
</Row>
<Row>
<MAT>444</MAT>
<WER>US</WER>
<LGO>T1</LGO>
<TANK>T100</TANK>
<BATCH>1010</BATCH>
<CLABS>1000000.000</CLABS>
<CINSM>0</CINSM>
</Row>
<Row>
<MAT>555</MAT>
<WER>US</WER>
<LGO>T1</LGO>
<TANK>T100</TANK>
<BATCH>1010</BATCH>
<CLABS>1000000.000</CLABS>
<CINSM>0</CINSM>
</Row>
<Row>
<MAT>666</MAT>
<WER>US</WER>
<LGO>T1</LGO>
<TANK>T100</TANK>
<BATCH>1010</BATCH>
<CLABS>1000000.000</CLABS>
<CINSM>0</CINSM>
</Row>
</Rowset>
</Rowsets>
Now, I want my select statement to return following based on a count of XML node:
select
If count(/Rowsets/Rowset/Row[CLABS > 0]/BATCH) > 1 then 'Mixing'
else if count(/Rowsets/Rowset/Row[MAT = "Parameter Value"]/MAT) = 0 then 'None'
else 'Other'
from Tablename TT where TANK = something and Plant = something
How can I achive this using Oracle query? I can do it using SQL server but not getting the correct syntax for Oracle :(I got the answer on my own :)
SELECT CASE WHEN count(RW."CountofBATCH") > 1 then 'Mixing'
WHEN count(RW."CountofMAT") = 0 then 'None'
ELSE 'Other'
END
FROM TABLENAME TT, XMLTable('/Rowsets/Rowset/Row' PASSING TT.XMLCOL
COLUMNS
"CountofBATCH" PATH '/Row[CLABS > 0]/BATCH',
"CountofMAT" PATH '/Row[MAT = "[Parameter Value]"]/MAT'
) AS RW
where
some condition -
Removing empty node created by Value Mapping Functoid
If the first input parameter to Value Mapping functoid is not true, it creates an empty element in the destination which I don't want, how can I get rid of this empty element, if it's empty I do not want it to created in the destination document.
Do let me know how can I achive this within a Map.You can get rid of the empty nodes in your map by using a custom functoid and use XSLT script (also given below) and mentioned in this article
Remove empty nodes in BizTalk by using XSLT
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="@@ YOUR NAMESPACE @@" version="1.0" xmlns:ns0="http://Stater.Isvcs.Iface.BO.GetLoanData.ElfV2">
<xsl:output method="xml" indent="yes" />
<xsl:template match="node()">
<xsl:if test="count(descendant::text()[string-length(normalize-space(.))>0]|@*)">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:if>
</xsl:template>
<xsl:template match="@*">
<xsl:copy />
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="normalize-space(.)" />
</xsl:template>
</xsl:stylesheet>
Abdul Rafay - MVP & MCTS BizTalk Server
blog: http://abdulrafaysbiztalk.wordpress.com/
Please mark this as answer if it helps. -
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 -
Format XML doc based on values in another xml doc
Database version : Oracle 10g
I have an XML "data" file and an associated error file that is also XML. I want to take the XML data file and highlight visually in a html file only those fields and contents that are there in the "error" file.
There are many fields in the data file so the error could be just about anywhere. Can someone please tell me what I should read or give me some direction on how I should proceed?
I built a style sheet for the "data" file - but obviously that is static. Do i need 2 stylesheets and apply them both somehow? I was also thinking that I would use the "error" xml doc and just rewrite the error nodes in the "data" file and then use the style sheet to mark up the data file based on what i rewrite.
eg
if the data is say
<field1>content of field 1</field1>
and the error file has field1 in it, I would rewrite the data file to have say <error>content of field 1</error> and just mark up the <error> using the stylesheet. Is that a sensible solution? Even then I need help on the actual xml/sql functions i need to rewrite the xml data.
I am a rank beginner in this and I apologize - This seems such a newbie question that must have been asked before - I just wish I could find it in the forum.
Thank you!
Edited by: user13112667 on Oct 15, 2010 12:38 PMThanks for the samples.
A couple of options I can think of :
- XSL transformation (as you first thought of too)
- XQuery
Below is a test script that implements both solutions :
DECLARE
datadoc xmltype := xmltype(
'<HII>
<HII_SEQ_NUM>6084997</HII_SEQ_NUM>
<HII_RECORD_ID>HII</HII_RECORD_ID>
<HII_DOC_TYPE>INV</HII_DOC_TYPE>
<HII_WSLR_ID>XXXXX</HII_WSLR_ID>
<HII_WSLR_ABBR>COM</HII_WSLR_ABBR>
<HII_CUST_NBR>096636</HII_CUST_NBR>
<HII_INV_DATE>100203</HII_INV_DATE>
<HII_INV_NUMB>829608-1102</HII_INV_NUMB>
<HII_ORD_NUMB>830412</HII_ORD_NUMB>
<HII_TP_ID>007839602</HII_TP_ID>
<HII_WSLR_DUNS>000073669</HII_WSLR_DUNS>
<HII_TRANS_TYPE>DI</HII_TRANS_TYPE>
<HII_CAVN_ID>77873</HII_CAVN_ID>
<HII_VER_NUM>22</HII_VER_NUM>
</HII>'
errordoc xmltype := xmltype(
'<document>
<error>
<segment>HII</segment>
<element>HII_INV_DATE(Inv Date)</element>
<msg>Invoice date must be in the format yyyymmdd</msg>
<data>100203</data>
</error>
<error>
<segment>HII</segment>
<element>HII_TP_ID(TP ID)</element>
<msg>Data must be 12 digits long</msg>
<data>007839602</data>
</error>
</document>'
xsldoc xmltype := xmltype(
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" version="4.0"/>
<xsl:template match="/">
<HTML>
<BODY>
<STYLE type="text/css">
<![CDATA[
TR.err { background-color: red }
TD { border: 1px solid }
TABLE { border-collapse: collapse }
]]>
</STYLE>
<TABLE>
<xsl:apply-templates select="root/datafile/HII/*"/>
</TABLE>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="HII/*">
<xsl:variable name="msg" select="/root/errorfile/document/error[segment=name(current()/..) and substring-before(element,''('')=name(current())]/msg"/>
<TR>
<xsl:if test="$msg"><xsl:attribute name="class">err</xsl:attribute></xsl:if>
<TD><xsl:value-of select="name(.)"/></TD>
<TD><xsl:value-of select="."/></TD>
<TD><xsl:value-of select="$msg"/></TD>
</TR>
</xsl:template>
</xsl:stylesheet>'
html_res1 clob;
html_res2 clob;
BEGIN
-- XSL Transformation
SELECT XMLTransform(
xmlelement("root",
xmlconcat( xmlelement("datafile",datadoc),
xmlelement("errorfile",errordoc) )
xsldoc
).getClobVal()
INTO html_res1
FROM dual;
-- XQuery
SELECT XMLQuery(
'<HTML>
<BODY>
<STYLE type="text/css">
TR.err {{ background-color: red }}
TD {{ border: 1px solid }}
TABLE {{ border-collapse: collapse }}
</STYLE>
<TABLE>
for $i in $d/HII/*
let $n := name($i)
let $v := $i/text()
let $msg := xs:string($e/document/error[segment=name($i/..) and substring-before(element,"(")=$n]/msg)
return
element TR {
if ($msg) then
attribute class {"err"}
else (),
<TD>{$n}</TD>,
<TD>{$v}</TD>,
<TD>{ $msg }</TD>
</TABLE>
</BODY>
</HTML>'
passing datadoc as "d",
errordoc as "e"
returning content
).getClobVal()
INTO html_res2
FROM dual;
END;
/Same principle for the two methods : looping through the data document and searching for a matching occurrence in the error document using XPath.
It produces an HTML document (html_res1 and html_res2) like this :
<HTML>
<BODY>
<STYLE type="text/css">
TR.err { background-color: red }
TD { border: 1px solid }
TABLE { border-collapse: collapse }
</STYLE>
<TABLE>
<TR>
<TD>HII_SEQ_NUM</TD>
<TD>6084997</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_RECORD_ID</TD>
<TD>HII</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_DOC_TYPE</TD>
<TD>INV</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_WSLR_ID</TD>
<TD>XXXXX</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_WSLR_ABBR</TD>
<TD>COM</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_CUST_NBR</TD>
<TD>096636</TD>
<TD></TD>
</TR>
<TR class="err">
<TD>HII_INV_DATE</TD>
<TD>100203</TD>
<TD>Invoice date must be in the format yyyymmdd</TD>
</TR>
<TR>
<TD>HII_INV_NUMB</TD>
<TD>829608-1102</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_ORD_NUMB</TD>
<TD>830412</TD>
<TD></TD>
</TR>
<TR class="err">
<TD>HII_TP_ID</TD>
<TD>007839602</TD>
<TD>Data must be 12 digits long</TD>
</TR>
<TR>
<TD>HII_WSLR_DUNS</TD>
<TD>000073669</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_TRANS_TYPE</TD>
<TD>DI</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_CAVN_ID</TD>
<TD>77873</TD>
<TD></TD>
</TR>
<TR>
<TD>HII_VER_NUM</TD>
<TD>22</TD>
<TD></TD>
</TR>
</TABLE>
</BODY>
</HTML>Performance-wise, you'll have to test on real documents, but I think XSLT is better. -
Query - Remove duplicate records based on value of one field
Hi,
Pleae see the data below,
how to remove records when its count 0
AND those records (name ) repeat with count > 0
existing data
name loc count
aaa a1 10
aaa a1 0
bbb b1 0
ccc c1 0
dcc d1 11
dcc d1 0
required output
name loc count
aaa a1 10
bbb b1 0
ccc c1 0
dcc d1 11
remove these records -
aaa a1 0
dcc d1 0Thanks.i 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 -
Xml in JTree: how to not collpase JTree node, when renaming XML Node.
Hi.
I'm writing some kind of XML editor. I want to view my XML document in JTree and make user able to edit contents of XML. I made my own TreeModel for JTree, which straight accesses XML DOM, produced by Xerces. Using DOM Events, I made good-looking JTree updates without collapsing JTree on inserting or removing XML nodes.
But there is a problem. I need to produce to user some method of renaming nodes. As I know, there is no way to rename node in w3c DOM. So I create new one with new name and copy all children and attributes to it. But in this way I got a new object of XML Node instead of renamed one. And I need to initiate rebuilding (treeStructureChanged event) of JTree structure. Renamed node collapses. If I use treeNodesChanged event (no rebuilding, just changes string view of JTree node), then when I try to operate with renamed node again, exception will be throwed.
Is there some way to rename nodes in my program without collpasing JTree?
I'am new to Java. Maybe there is a method in Xerces DOM implementation to rename nodes without recreating?
Thanks in advance.I assume that "rename" means to change the element name? Anyway your question seems to be "When I add a node to a JTree, how do I make sure it is expanded?" This is completely concerned with Swing, so it might have been better to post it in the Swing forum, but if it were me I would do this:
1. Copy the XML document into a JTree.
2. Allow the user to edit the document. Don't attempt to keep an XML document or DOM synchronized with the contents of the JTree.
3. On request of the user, copy the JTree back to a new XML document.
This way you can "rename" things to the user's heart's content without having the problem you described. -
How to remove a node from a xml
Hi All,
I want to remove a node from my xml output. Can anyone suggest me how to get that? I want to implement this by using the ASSIGN activity.
My sample output is
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>
<wsa:MessageID>urn:4EF1A350677C11E1BFA7794ED76B03EF</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
</env:Header>
<env:Body>
<SiebelOrderQueryByExample_Output xmlns="http://siebel.com/asi/">
<ListOfOrderInterface xmlns="http://www.siebel.com/xml/Siebel%20Order">
<Orders>
<Id>1-15IXJ</Id>
<AccountId>1-2EE</AccountId>
<OrderNumber>1012-1234</OrderNumber>
<ListOfLineItems>
<LineItems>
<Id>1-15IYN</Id>
<LineNumber>303</LineNumber>
<OrderNumber>1012-1234</OrderNumber>
<OrderHeaderId>1-15IXJ</OrderHeaderId>
</LineItems>
</ListOfLineItems>
</Orders>
</ListOfOrderInterface>
</SiebelOrderQueryByExample_Output>
</env:Body>
</env:Envelope>
I want to delete the <ListOfLineItems>node from the xml above so that my resultant would be,
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>
<wsa:MessageID>urn:4EF1A350677C11E1BFA7794ED76B03EF</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
</env:Header>
<env:Body>
<SiebelOrderQueryByExample_Output xmlns="http://siebel.com/asi/">
<ListOfOrderInterface xmlns="http://www.siebel.com/xml/Siebel%20Order">
<Orders>
<Id>1-15IXJ</Id>
<AccountId>1-2EE</AccountId>
<OrderNumber>1012-1234</OrderNumber>
</Orders>
</ListOfOrderInterface>
</SiebelOrderQueryByExample_Output>
</env:Body>
</env:Envelope>
Please suggest something Its urgent.
Thanks in Advance.It goes something like this, taken from the above blog entry:
Removing a node from node-list
With the bpelx: extensions in BPEL you are able to insert and update nodes in a node list. A node-list is an XML message that contains a set of records. In this article I use the following example:
<BookList xmlns="http://message.vijfhuizen.com">
<Book>
<title>The Lord Of The Rings</title>
<author>J.R.R. Tolkien</author>
</Book>
<Book>
<title>Harry Potter</title>
<author>J.R.R. Tolkien</author>
</Book>
<Book>
<title>The Hobbit</title>
<author>J.R.R. Tolkien</author>
</Book>
<Book>
<title>Storm; Chronicals of Pandarve</title>
<author>Don Lawrence</author>
</Book>
</BookList>
For creating and updating node lists the bpelx: functions are enough to handle this. But when you want to remove a particular node, you can use the bpelx:remove function. But this function can only remove a node from a particular position. For example removing the second node you code:
<bpel:assign>
<bpelx:remove>
<bpelx:target variable="VarBookList" query="/Booklist/Book[2]" />
</bpelx:append>
</bpel:assign>
It is hard to code the bpelx:remove to create a xpath to dynamicly remove node. You would like to remove the second node based on the xpath:
/Booklist/Book[title="Harry Potter" and author="J.R.R. Tolkien"]
You can add the above xpath in the bpelx:remove, but you are not able to make this dynamically.
There is a solution. The trick is to create a stylesheet that copies the data into a new message, but removing that particular records. Create a stylesheet that does the normal copy of the XML message. Then add a <choose> element in the stylsheet to filter that particular record.
<xsl:template match="/">
<BookList>
<xsl:for-each select="/BookList/Book">
<xsl:choose>
<xsl:when test="title='Harry Potter' and author='J.R.R. Tolkien'"/>
<xsl:otherwise>
<Book>
<title>
<xsl:value-of select="title"/>
</title>
<author>
<xsl:value-of select="author"/>
</author>
</Book>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</BookList>
Now we have a XSL stylesheet that removes a particular record, but this is not variable. This can be done via XSLT parameters.
<xsl:param name="pTitle"/>
<xsl:param name="pAuthor"/>
<xsl:template match="/">
<BookList>
<xsl:for-each select="/BookList/Book">
<xsl:choose>
<xsl:when test="title=$pTitle and author=$pAuthor"/>
<xsl:otherwise>
<Book>
<title>
<xsl:value-of select="title"/>
</title>
<author>
<xsl:value-of select="author"/>
</author>
</Book>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</BookList>
</xsl:template>
Now we are able to use this stylesheet in BPEL. In general BPEL create the following code:
<assign name="Transform">
<bpelx:annotation>
<bpelx:pattern>transformation</bpelx:pattern>
</bpelx:annotation>
<copy>
<from expression="ora:processXSLT('RemoveNode.xsl'
, bpws:getVariableData('Variable_BookList','payload')" />
<to variable="Variable_BookListTemp" part="payload"/>
</copy>
</assign>
But this code does not pass parameters to the stylesheet. The ora:processXSLT() can do this it has an additional parameter in this function:
<assign name="Transform">
<bpelx:annotation>
<bpelx:pattern>transformation</bpelx:pattern>
</bpelx:annotation>
<copy>
<from expression="ora:processXSLT('RemoveNode.xsl'
, bpws:getVariableData('Variable_BookList','payload')" />
, bpws:getVariableData('BPELxslparameters'))"/>
<to variable="Variable_BookListTemp" part="payload"/>
</copy>
</assign>
Now only you have to create the BPELxslparameters variable and assign it with the correct name/value pairs. The structure of the this variable is as follows:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.oracle.com/service/bpel/common"
targetNamespace="http://schemas.oracle.com/service/bpel/common"
elementFormDefault="qualified">
<xsd:element name="parameters">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="value" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Create in BPEL the variable BPELxslparameters and let it point to this strucure:
<process ....
xmlns:common="http://schemas.oracle.com/service/bpel/common"
.../>
<variable name="BPELparameters" element="common:parameters"/>
Now we can in BPEL create an empty XML message, based on this strcuture and assign the values to these parameters and then call the processXSLT function.
<bpelx:assign name="Assign_GenerateEmptyParameterSet">
<copy>
<from>
<parameters xmlns="http://schemas.oracle.com/service/bpel/common">
<item>
<name>pTitle</name>
<value/>
</item>
<item>
<name>pAutor</name>
<value/>
</item>
</parameters>
</from>
<to variable="BPELparameters" query="/common:parameters"/>
</copy>
</bpelx:assign>
<assign name="Assign_setXSLTParameters">
<copy>
<from expression="'Harry Potter'"/>
<to variable="BPELparameters" query="/common:parameters/common:item[1]/common:value"/>
</copy>
<copy>
<from expression="'J.R.R. Tolkien'"/>
<to variable="BPELparameters" query="/common:parameters/common:item[1]/common:value"/>
</copy>
</assign>
Posted by Marc Kelderman SOA Blog at 1/16/2008 09:20:00 PM -
How to remove target node if source field value is empty SAP PI Mapping
Hello,
how to remove target node if source field value is empty in graphical Mapping.
Like if
MIddle name in source filed is empty, I would like to eliminate target field from out put XML.
Thank you
JohnHi Jhon,
If you want to remove all empty tags and you dont to complicate your message mapping, you can use a XSL, after the message mapping, to remove all the empty tags:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(@*|*|comment()|processing-instruction())
and normalize-space()='' ]"/>
</xsl:stylesheet>
Regards -
Hi,
We are using file adapter to generate XML files based on XSD.
We have a requirement were we need to remove to xml namespace value from the XML file generated by BPEL file adapter.
Following is the snippet of the xml file generated :
<?xml version="1.0" ?>
<Consignment xmlns="http://targetnamespace.com/RSA/Consignment">
<Details xmlns="">
<Client>RENZA</Client>
</Details>
</Consignment>
I dont want the xmlns="http://targetnamespace.com/RSA/Consignment".
or atleast it should be just xmlns="" similar to what i have got in Details tag
Thanks in advance
SatishI tried removing the target namespace as well in the XSD, but the compiler complains.
Tried removing it before deployment and it also failed.
Is there any other place where i can specific some values to suppress this namespace generation ?
Thanks
Satish -
Sum on child nodes based on attribute value in xslt
Hi all,
Any one can post helpful code to calculate the sum of child nodes based on the attribute value of other child node.
Let's say for example.
I have one child element has attribute value let's say Tax so I have to put condition on child element having value of "Tax" I need to calcualte sum of Invoice amount that element is also child node
After calculating sum I have to apply that sum at the header level of the Invoice. For each Invoice I have calculate sum and apply at the header level.It isn't working :(.Got the following error:
An error was reported compiling the XPath expression: error: XPath expression invalid, not a selection: declare namespace ws = 'http://www.bea.com/wli/sb/transports/ws';
declare namespace tuxedo = 'http://www.bea.com/wli/sb/transports/tuxedo';
declare namespace wsa = 'http://schemas.xmlsoap.org/ws/2004/08/addressing';
declare namespace http = 'http://www.bea.com/wli/sb/transports/http';
declare namespace xsi = 'http://www.w3.org/2001/XMLSchema-instance';
declare namespace wsp = 'http://schemas.xmlsoap.org/ws/2004/09/policy';
declare namespace file = 'http://www.bea.com/wli/sb/transports/file';
declare namespace xsd = 'http://www.w3.org/2001/XMLSchema';
declare namespace soap12-env = 'http://www.w3.org/2003/05/soap-envelope';
declare namespace flow = 'http://www.bea.com/alsb/flow/transport';
declare namespace sftp = 'http://www.bea.com/wli/sb/transports/sftp';
declare namespace sb = 'http://www.bea.com/wli/sb/transports/sb';
declare namespace soap-enc = 'http://schemas.xmlsoap.org/soap/encoding/';
declare namespace ejb = 'http://www.bea.com/wli/sb/transports/ejb';
declare namespace soap-env = 'http://schemas.xmlsoap.org/soap/envelope/';
declare namespace jpd = 'http://www.bea.com/wli/sb/transports/jpd';
declare namespace email = 'http://www.bea.com/wli/sb/transports/email';
declare namespace tp = 'http://www.bea.com/wli/sb/transports';
declare namespace dsp = 'http://www.bea.com/dsp/transport/sb';
declare namespace ctx = 'http://www.bea.com/wli/sb/context';
declare namespace soap12-enc = 'http://www.w3.org/2003/05/soap-encoding';
declare namespace wsu = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
declare namespace jms = 'http://www.bea.com/wli/sb/transports/jms';
declare namespace ftp = 'http://www.bea.com/wli/sb/transports/ftp';
fn:string(./xml-fragment/@IntObjectName). -
Using XSLT to extract value of a XML node with namespace
I have a XML source code here.
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:job="http://www.pageuppeople.com">
<channel>
<title>SMH Jobs</title>
<link>internalrecruitment.smhgroup.com.au/jobsrss.ashx?stp=di</link>
<description>A listing of jobs available here</description>
<item>
<title>eCommerce Optimisation Advisor</title>
<description>A new and exciting opportunity exists for an experienced eCommerce Advisor to join</description>
<job:location PUReferenceID="3711">Sydney - Inner Suburbs & CBD</job:location>
</item>
</channel>
</rss>
I want to use XSLT to extract value of a XML node with namespace <job:location>, and the returned value should be string 'Sydney - Inner Suburbs & CBD'. I tried a few XSL code below, but failed with error or nothing was returned.
<xsl:value-of select="job:location" disable-output-escaping="yes"/>
<xsl:value-of select="job/location" disable-output-escaping="yes"/>
<xsl:value-of select="job\location" disable-output-escaping="yes"/>
<xsl:value-of select="location" disable-output-escaping="yes"/>
This might be an easy question for you, but I would appreciate if anyone can help.Hi Suncorp IT Learner,
We need to tell the XSLT that some elements are in another namespace. Copy the xmls declarations for the prefixes you need to use. Then use the xsl format as:
<xsl: value-of select=”job:location/@PUReferenceID”/>
In following issue, Chriztian has a good explanation:
http://our.umbraco.org/forum/developers/xslt/33353-XSLT-reading-XML-attribute-value
Thanks,
Qiao Wei
TechNet Community Support -
How to remove a node from a target xml payload in reciever file channel
i have a scenario where i have to remove a node from my target xml file in receiver file channel and want xml as the output file. I don't want a fixed length file. How to do that in receiver channel? Do we need to use file content conversion for that?
that will result in giving you a fixed file or a separator defined file.
it will not give you an XML file.
In case you want a XML file, instead of using variable substitution, use Dynamic configuration and adapter specific properties.
Some ref:
/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm
Maybe you are looking for
-
Matrox MXO or Blackmagic Intensity Pro?
I just bought the Dell 2408 monitor, which I like thus far, and am looking to use it as both a second computer monitor and also an NTSC preview monitor in conjunction with FCP. Playing via S-video on my DSR-11 looks positively terrible- so what's the
-
Transaction audit report concurrent program error with signal 4
My EBS is 11.5.10.2 on AIX 5.3 with DB 10.2.0.4 When i run a customized transaction audit report in production getting " program completed with error signal 4" can any one kindly provide a quick solution as iam facing this in my production thanks in
-
Cisco ISE with EAP-FAST and PAC provisioning
Hi, I have search with no result on this topic. So, Does anyone have implemented Cisco ISE authentication with EAP-FAST and PAC provisioning ? Since I have an issue with internal proxy, user required to authenticate with an internal proxy before gran
-
No way to connect subcircuit with HB (10.0.343
Hi, I'm trying to learn Multisim 10.0 I am wiring a sub circuit to be used in a heirarchical block. After the whole thing is ready, I want to wire it back to my supercircuit, so I go to the place menu as it says in the instructions - but lo and beho
-
When I load a List/Menu control, this first item in the list in always displayed. I'd like to have nothing displayed, forcing the customer to select an item from the list. Other then adding "<option></option>" as the first item in the list, is there