I try to validate data in my page.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:item="http://www.myspace.com/item"
xmlns:shop="xalan://my.app.xslt.model.Shop" xmlns:valid="xalan://my.app.xslt.validation.ShopValidator"
xmlns:exsl="http://exslt.org/common">
I have a model with field, and class validator with methods for checking every field.
And in row
<xsl:if test="valid:isNotEmptyData(shop:getOwner($item)) != true()">
<error message="The field OWNER is empty." />
</xsl:if>
I get NoSuchMethodExtension although I have in model
public class Shop{
private String owner;
public String getOwner(){
return owner;
}
}
And in validator class
public static boolean isNotEmptyData(String model){
retutn model.isEmpty();
}
Can you help me?
Your method
Shop.getOwner()has no arguments, whereas in the XSLT you call it asshop:getOwner($item))with one argument – the XSLT processor looks for a method with one argument and cannot find it, hence the error.I am not sure what
getOwner()is supposed to do – possibly to extract some value from its arguments..? In such a case you should modify it to accept an argument and process it.By the way,
can be written using standard XPath functions as
(a string is considered true if it is non-empty), or as