XPath function usage exceptions

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2211 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-01-26 01:39:38 +00:00
parent 0e7fda10a1
commit 2ff11e6114

View File

@@ -380,12 +380,11 @@ public class NodeServiceXPath extends BaseXPath
public Object call(Context context, List args) throws FunctionCallException
{
if (args.size() == 1)
if (args.size() != 1)
{
return evaluate(context.getNodeSet(), args.get(0), context.getNavigator());
throw new FunctionCallException("contains() usage: contains('pattern')");
}
throw new FunctionCallException("contains() requires one argument.");
return evaluate(context.getNodeSet(), args.get(0), context.getNavigator());
}
public Object evaluate(List nodes, Object pattern, Navigator nav)
@@ -403,8 +402,9 @@ public class NodeServiceXPath extends BaseXPath
}
else if (nav.isAttribute(nodes.get(0)))
{
qname = QName.createQName(nav.getAttributeNamespaceUri(nodes.get(0)), ISO9075.decode(nav
.getAttributeName(nodes.get(0))));
qname = QName.createQName(
nav.getAttributeNamespaceUri(nodes.get(0)),
ISO9075.decode(nav.getAttributeName(nodes.get(0))));
nodeRef = ((DocumentNavigator.Property) nodes.get(0)).parent;
}
@@ -463,7 +463,9 @@ public class NodeServiceXPath extends BaseXPath
}
else if (nav.isAttribute(target))
{
qname = QName.createQName(nav.getAttributeNamespaceUri(target), ISO9075.decode(nav.getAttributeName(target)));
qname = QName.createQName(
nav.getAttributeNamespaceUri(target),
ISO9075.decode(nav.getAttributeName(target)));
nodeRef = ((DocumentNavigator.Property) target).parent;
}