I want to test the input with 2 conditions.
I tried with below statement,
<xsl:when test="(string-lenght(/ns0:PostalCode) < 9) and (string-lenght(/ns0:InoutCode/ns0:PostalCode) > 5)">
but when I am testing the service it's getting below error
The XPath expression failed to execute; the reason was: javax.xml.transform.TransformerException.
Please help me on this issue. How write exact condition?
Do two things:
(a) check the spelling of your function names
(b) find out why you aren't getting any proper diagnostics. You're either using an XPath engine with particularly bad diagnostics, or you aren't running it properly.
Related
I am getting an error asking if I am trying to type a formula, but I am not sure what the issue is
=IF(AND(K74="yes",J74">"&S3,J74"<="&S4),$I$74,0)
Condition 1: K74=Yes
Condition 2: J74 between two dates
If true
=I74
PLEASE HELP?!
I tried making it an ifs function but then I dont have enough arguments
I think the issue that there are 3 conditions not two and the solutions I found online focus on two conditions only.
I also tried putting the commas in different places and using semi colons.
You have to build two conditions for the between-check without joing them as text:
=IF(AND(K74="yes",J74>S3,J74<=S4),$I$74,0)
I'm currently facing an issue with a software i'm working with , this software receives from an external sofware several Xmls that we do need to process , now our issue is that those Xml files contain a lot of nodes which are totally useless and also make the files (xmls) really heavy because of that , in result out program runs very slow to process each one of the xmls , this should be changed in the future and i'd like to prove that by removing those nodes we would improve our processing time a lot , now i'd like as first step to do this manually , using a sample xml and applying a regex syntax to remove all the nodes with value property empty , this is the syntax that i'm using now and through the replace function in notepad i'm able to remove those rows and then remove the empty lines :
<.*(\s\w+?[^=]*?="[^"]*?")*?\s+?value="[""]*?".*?>
Example
<TEST_NODE value="1"/>
<TEST_NODE value=""/>
<TEST_NODE value="0"/>
In my case nodes can be named differently and can have different properties , but the one that i should care for are the ones that contain something in the value property , therefore in this case i should remove the second row
This looks to be working fine , however with very large files (10 mb) the replace notepad++ function seems to have issues and it stop working properly breaking a lot of tags...
I've tried using another software called "Ultraedit" , but there the syntax i guess it's different as i can use regular Expressions but need to select one of those options : Perl , Unix , Ultraedit ; only using "Perl" i'm able to do this replacement but also there , for big files this is not working and i get the following error:
The complexity of matching the expression has exceeded available resources..
Can anyone help me out with this? unfortunately i'm not even that good with Regex and i'm not sure if the above code is good or bad..
Try this:
<(?=[^><]*?value\s*=\s*"")[^><]*>
Replace with nothing.
This might be a case of catastrophic backtracking when the regex runs caused by too many quantifiers applied to too many wide character classes like .
The quantifiers in this answer are only applied to not < or > class which should stop the expression backtracking through XML tags.
You're using the wrong tool for the job. If you're going to be manipulating XML then you need to add XSLT and/or XQuery to your tool kit. Using regular expressions for the job is slow and error-prone.
For example, here are just a few of the bugs in the answer that you accepted:
Elements that use single quotes (value='') won't be matched
Element with whitespace around the equals sign won't be matched
Elements with an attribute whose name ends in value (e.g. xvalue="") will be matched
value="" will be matched inside comment and CDATA nodes
value="" can be matched inside text nodes: <x>value=""</x>
Elements split across multiple lines won't be matched (I suspect)
In XSLT 3.0 this is simply
<xsl:transform version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="*[#value='']"/>
</xsl:transform>
Try this regular expression in Notepad++
<[^<]+value=""[^>]*>
i really tried to find an answer but i couldn't.
I try to use the regex reference_matchNr to increment a user defined variable.
But i get always the following error msg:
${__intSum(${summe},${count1},summe)};
jmeter.assertions.BeanShellAssertion: java.lang.NumberFormatException: For input string: "${count1}"
or
${__intSum(${summe},"${count1}",summe)};
jmeter.assertions.BeanShellAssertion: java.lang.NumberFormatException: For input string: ""${count1}""
or
${__intSum(${summe},count1,summe)};
jmeter.assertions.BeanShellAssertion: java.lang.NumberFormatException: For input string: "count1"
I used the following code to get the matchNr value:
int count1 = Integer.parseInt(vars.get("status_matchNr"));
The strange thing is i'm able to write the value in the jmeter log(log.info) or in a file.
Thanks in advance.
My expectation is that you're using __intSum() function inside the Beanshell Assertion to add 2 values.
This is not gonna work as the function gets interpreted before the assertion hence your count1 variable is not defined by the moment of function execution.
So workarounds are:
Use "Parameters" input for function evaluation prior interpreting the assertion. You ain't gonna need to convert your "status_matchNr" variable to integer, intSum function will do it for you. So if you put the following line to "Parameters"
${__intSum(${summe},${status_matchNr},summe)};
It assumes that "summe" variable is defined and can be cast to an integer
Go the "code only" way - perform sum of 2 integers purely in Beanshell code like:
int count1 = Integer.parseInt(vars.get("status_matchNr"));
int summe = Integer.parseInt(vars.get("summe"));
summe += count1;
vars.put("summe", String.valueOf(summe));
//your assertion logic here
May I also recommend considering switching from Beanshell to JSR223 Assertion and groovy language as Beanshell has performance problems and may become a bottleneck if your load is high. See Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! guide for details, groovy scripting engine installation instructions and different scripting approaches benchmark.
i am quite confused about how the Criteria API does build the final query.
Here's some code :
someCriteria.add(
Restrictions.and(
Restrictions.or(Restrictions.gt(a,b),Restrictions.isNull(a)),
Restrictions.ge(d,e)
)
I was expecting something like
SELECT.. FROM...
WHERE (A > B or A IS NULL) AND (D > E)
But when I inspect my criteria entries, I see instead something like :
SELECT.. FROM...
WHERE A > B or A IS NULL AND D > E
thus leading in unexpected result.
I am quite sure I could rewrite the query so that it is no more a problem, but since the application I am about to develop for is based on such queries, I need to understand the problem.
So, anyone could explain why I dot not get expected parentheses around the part of the query generated by the "Restrictions.or(...)"?
Thanks in advance.
PS : Hibernate core 4.3.4.Final
So the problem was not with "Criteria", but with my excessive trust in the debugging tools : the Criteria does actually match the first solution, ie adds parentheses around each generated restriction.
But when I tried to log or watch the criterion entries inside the Criteria object, some parentheses were just not displayed, leading me into misinterpreting my problem.
So the solution to understand the problem was to log the actual request (eg using property "show_sql" in the sessionFactoryBean and setting log4j.logger.org.hibernate.sql to TRACE level).
I'm new to XSLT, and I'm carrying out a few tests using w3schools "Try it yourself" pages. I'm using the following demo:
http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=tryxsl_choose
This contains the following line:
<xsl:for-each select="catalog/cd">
I'm testing filtering the HTML rendered by position() but I'm having issues when using the < operand.
I've tried the following:
<xsl:for-each select="catalog/cd[position()=1]">
And this returns the first item from the XML data (as expected).
I then tried:
<xsl:for-each select="catalog/cd[position()<5]">
I was expecting this to return the first 4 items, but instead I get no results.
My guess is that perhaps position()=1 is doing a string comparison, which is why it returns the first item, but it cannot understand position()<5 as a string cannot be compared in this way?
Why is this happening, and what would be the correct syntax to get the results I wish to achieve?
Update: After reading #joocer's response, and testing this myself, using the > operand does work, for the opposite result:
<xsl:for-each select="catalog/cd[(position()>5)]">
It looks very much like a bug in the version of libxslt that w3schools is using.
Even inside quotes, you must type < as < so it won't be confused for the start of an element tag. I think this was done to make it easier for tolerant parsers to recover from errors and streaming parsers skip content faster. They can always look for < outside CDATA and know that is an element start or end tag.
I don't know why, but inverting the condition works, so instead of looking for less than 5, look for not more than 4
<xsl:for-each select="catalog/cd[not(position()>4)]">