I want to get multiple output from a single XML input message.
<List>
<type>mailbox</type>
<Docs>
<DocID>38ghjk</DocID>
</Docs>
<Docs>
<DocID>39ghjk</DocID>
</Docs>
This is how my XML looks it contains more DocID. My requirement is I want separate output messages for each DocID. I tried with while loop but I'm not getting separate messages for each DocIDs. I can fetch all DocIDs but I'm not able to get Separate Output each DocID.
Please suggest any way or solution to do it and please comment for any queries.
DECLARE I INTEGER;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.XMLNSC.List.Docs[]);
SET I = 1;
WHILE I < J DO
SET OutputRoot.XMLNSC.LIST.DocId[K] = InputRoot.XMLNSC.List.Docs[I].DocId;
PROPAGATE TO TERMINAL 'out' delete none;
SET I = I + 1;
END WHILE;
Earlier I was not using propagate statement so I was getting single output but now I'm getting different output for all docid.
CARDINALITY is not the Best way to do that, you can do something like:
DECLARE refInDocument REFERENCE TO InputRoot.XMLNSC.List.Docs;
WHILE LASTMOVE(refInDocument) DO
SET OutputRoot.XMLNSC.Docs.DocId = refInDocument.DocId;
PROPAGATE TO TERMINAL 'out' delete none;
MOVE refInDocument NEXTSIBLING;
END WHILE;
You can read more about that at IBM documentation in this link:
https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/bj28653_.htm
Related
I have an xml
<family>
<child_one>ROY</child_one>
<child_two>VIC</child_two>
</family>
I want to fetch the value from the XML based on the dynamic tag in ESQL. I have tried like this
SET dynamicTag = 'child_'||num;
SET value = InputRoot.XMLNSC.parent.(XML.Element)dynamicTag;
Here num is the value received from the input it can be one or two. The result should be value = ROY if num is one and value is VIC if num is two.
The chapter ESQL field reference overview describes this use case:
Because the names of the fields appear in the ESQL program, they must be known when the program is written. This limitation can be avoided by using the alternative syntax that uses braces ( { ... } ).
So can change your code like this:
SET value = InputRoot.XMLNSC.parent.(XMLNSC.Element){dynamicTag};
Notice the change of the element type as well, see comment of #kimbert.
Below is the code which i have been trying to address the below UseCase in JMETER.Quick help is appreciated.
Usecase:
A particular text like "History" in a page response needs to be validated and the if the text counts is more than 50 a random selection of the options within the page needs to be made.And if the text counts is less than 50 1st option needs to be selected.
I am new to Jmeter and trying to solve this usingJSR223 POST processor but somehow stuck at vars.put function where i am unable to see the desired number being populated within the V paramter.
Using a boundary extractor where match no 1 should suffice the 1st selection and 0 should suffice the random selection.
def TotalInstanceAvailable = vars.get("sCount_matchNr").toInteger()
log.info("Total Instance Available = ${TotalInstanceAvailable}");
def boundary_analyzer =50;
def DesiredNumber,V
if (TotalInstanceAvailable < boundary_analyzer)
{
log.info("I am inside the loop")
DesiredNumber = 0;
log.info("DesiredNumber= ${DesiredNumber}");
vars.put("V", DesiredNumber)
log.info("v= ${V}");
}
else{
DesiredNumber=1;
log.info("DesiredNumber=${DesiredNumber}");
vars.put("V", "DesiredNumber")
log.info("v= ${V}");
}
def sCount = vars.get("sCount")
log.info("Text matching number is ${sCount_matchNr}")
You cannot store an integer in JMeter Variables using vars.put() function, you either need to cast it to String first, to wit change this line:
vars.put("V", DesiredNumber)
to this one
vars.put("V", DesiredNumber as String)
alternatively you can use vars.putObject() function which can store literally everything however you will be able to use the value only in JSR223 Elements by calling vars.getObject()
Whenever you face a problem with your JMeter script get used to look at jmeter.log file or toggle Log Viewer window - in absolute majority of cases you will find the root cause of your problem in the log file:
I populate a DOMDocumentFragment, with the aim of copying its contents to a number of locations in a target DOMDocument.
I have tried pretty much everything I can think of to achieve this but it's a case of epic fail. The following simplified working code illustrates one method I have tried that I would expect to work:
declare
vTargetDoc dbms_xmldom.DOMDocument;
vFragDoc dbms_xmldom.DOMDocument;
vFrag dbms_xmldom.DOMDocumentFragment;
vAttachPointNodes dbms_xmldom.DOMNodeList;
vElt dbms_xmldom.DOMElement;
vTmpN dbms_xmldom.DOMNode;
begin
-- create the target document
vTargetDoc := dbms_xmldom.newDOMDocument(xmltype('<TargetDoc><AttachPoint></AttachPoint><AttachPoint></AttachPoint></TargetDoc>'));
-- create the source document to contain the fragment to be attached repeatedly
vFragDoc := dbms_xmldom.newDOMDocument();
-- create the fragment
vFrag := dbms_xmldom.createDocumentFragment(vFragDoc);
-- append element "A" to the fragment
vElt := dbms_xmldom.createElement(vFragDoc,'A');
vTmpN := dbms_xmldom.appendChild(dbms_xmldom.makeNode(vFrag),dbms_xmldom.makeNode(vElt));
-- identify all the attach points in the target document
vAttachPointNodes := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(dbms_xmldom.getDocumentElement(vTargetDoc))
,'/TargetDoc/AttachPoint'
);
-- iterate through the attachpoints
for i in 0 .. dbms_xmldom.getLength(vAttachPointNodes) - 1 loop
-- import and attach the fragment to the current attachpoint
vTmpN := dbms_xmldom.appendChild(dbms_xmldom.item(vAttachPointNodes,i)
,dbms_xmldom.importNode(vTargetDoc
,dbms_xmldom.makeNode(vFrag)
,true
)
);
end loop;
-- print out the resultant target document XML
dbms_output.put_line(dbms_xmldom.getxmltype(vTargetDoc).getclobval());
end;
The noteworthy items in the code above are:
I create the fragment in a different document
On each attach point I import the fragment as a node (with deep = true)
The aim in this approach is to use importNode to copy the contents of the fragment from the source document as many times as I need to attach it in the target document.
The good news is that it does successfully copy the contents of the imported fragment to each required attach point.
The bad news is that it also appends a copy of the imported fragment at the end of the document as shown in the following illustrative output:
<TargetDoc>
<AttachPoint>
<A/> EXPECTED
</AttachPoint>
<AttachPoint>
<A/> EXPECTED
</AttachPoint>
</TargetDoc>
<A/> UNEXPECTED
<A/> UNEXPECTED
(the 2 FragmentContents duplicates appended on the end of the document are unexpected)
I can't figure out why it is creating the duplicates using this method, and neither can I find any other method that works.
Any help would be greatly appreciated. Thanks!
The problem seems to be the repeated calls to dbms_xmldom.makeNode(vFrag); you're doing that again each time round the loop, which creates another new node, and as at that point you aren't calling appendChild() it seems to stick it somewhere that looks a bit random.
You can refer to the result of your first call, vTmpN, instead:
for i in 0 .. dbms_xmldom.getLength(vAttachPointNodes) - 1 loop
-- import and attach the fragment to the current attachpoint
vTmpN := dbms_xmldom.appendChild(dbms_xmldom.item(vAttachPointNodes,i)
,dbms_xmldom.importNode(vTargetDoc
--,dbms_xmldom.makeNode(vFrag)
,vTmpN
,true
)
);
end loop;
which produces:
<TargetDoc>
<AttachPoint>
<A/>
</AttachPoint>
<AttachPoint>
<A/>
</AttachPoint>
</TargetDoc>
In this example it doesn't seem to matter that you're reassigning vTmpN - the next time round the loop that's still holding the node you want. You may prefer to have a separate variable to be safe (or clearer) though.
Is there a way to get the current error count of the current test case in Boost UTF?
I'd like to execute code in the case that at least one check in my test case failed. Something like:
if (BOOST_ERROR_COUNT > 0) { ... }
(This macro does not exist.)
You can access information about the current test case via the boost::unit_test::results_collector
e.g.
using boost::unit_test::results_collector;
using boost::unit_test::framework::current_test_case;
using boost::unit_test::test_case;
using boost::unit_test::test_results;
const test_results& theResults = results_collector.results( current_test_case().p_id );
This gets you a boost::unit_test::test_results which contains all of the information you are after.
See Also boost/test/results_collector.hpp
I have a cursor which is returning certain value. I would like to assign this value to a text field. When I compile trigger it returns error: "bad bind variable" for new_dr.textitem43. Any help greatly appreciated.
declare
EMP_ID_VALUE number :='NEW_EMP.ID_FIELD';
pcv_no pcv%TYPE;
cursor cursor_dr IS
select pcv FROM drivers
where drivers.eno = EMP_ID_VALUE;
begin
IF EMP_ID_VALUE < 1000 THEN
open cursor_dr;
fetch cursor_dr into pcv_no;
:new_dr.textitem43 := 'pcv_no';
exit when cursor_dr%NOTFOUND;
CLOSE cursor_dr;
ELSIF
...
END IF;
end;
That would indicate to me that either there is no block named new_dr or there is no field named textitem43 in that block. Are you sure you don't really mean :new_emp.textitem43?