not part of build, code by axel@pike.org, r=peterv; code by peterv@netscape.com, r=me. Fixing 59937, xpath function lib complete, 59649, 60059, 47720; building windows standalone, 46640; general code cleanup, fixing warnings; XPathProcessor and XSLTProcessor available to JS (work in progress)
git-svn-id: svn://10.0.0.236/trunk@84878 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -24,14 +24,14 @@
|
||||
* Marina Mechtcheriakova, mmarina@mindspring.com
|
||||
* -- changed some behavoir to be more compliant with spec
|
||||
*
|
||||
* $Id: NodeSetFunctionCall.cpp,v 1.2 2000-04-20 10:12:05 kvisco%ziplink.net Exp $
|
||||
* $Id: NodeSetFunctionCall.cpp,v 1.3 2001-01-12 20:06:35 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* NodeSetFunctionCall
|
||||
* A representation of the XPath NodeSet funtions
|
||||
* @author <A HREF="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.2 $ $Date: 2000-04-20 10:12:05 $
|
||||
* @version $Revision: 1.3 $ $Date: 2001-01-12 20:06:35 $
|
||||
**/
|
||||
|
||||
#include "FunctionLib.h"
|
||||
@@ -53,6 +53,9 @@ NodeSetFunctionCall::NodeSetFunctionCall(short type) : FunctionCall() {
|
||||
case COUNT :
|
||||
FunctionCall::setName(XPathNames::COUNT_FN);
|
||||
break;
|
||||
case ID :
|
||||
FunctionCall::setName(XPathNames::ID_FN);
|
||||
break;
|
||||
case LAST :
|
||||
FunctionCall::setName(XPathNames::LAST_FN);
|
||||
break;
|
||||
@@ -105,6 +108,43 @@ ExprResult* NodeSetFunctionCall::evaluate(Node* context, ContextState* cs) {
|
||||
result = new NumberResult(0.0);
|
||||
}
|
||||
break;
|
||||
case ID :
|
||||
if ( requireParams(1, 1, cs) ) {
|
||||
NodeSet* resultSet = new NodeSet();
|
||||
param = (Expr*)iter->next();
|
||||
ExprResult* exprResult = param->evaluate(context, cs);
|
||||
String lIDList;
|
||||
if ( exprResult->getResultType() == ExprResult::NODESET ) {
|
||||
NodeSet *lNList = (NodeSet *)exprResult;
|
||||
NodeSet tmp;
|
||||
for (int i=0; i<lNList->size(); i++){
|
||||
tmp.add(0,lNList->get(i));
|
||||
tmp.stringValue(lIDList);
|
||||
lIDList.append(' ');
|
||||
};
|
||||
} else {
|
||||
exprResult->stringValue(lIDList);
|
||||
};
|
||||
lIDList.trim();
|
||||
Int32 start=0;
|
||||
MBool hasSpace = MB_FALSE, isSpace;
|
||||
UNICODE_CHAR cc;
|
||||
String thisID;
|
||||
for (Int32 end=0; end<lIDList.length(); end++){
|
||||
cc = lIDList.charAt(end);
|
||||
isSpace = (cc==' ' || cc=='\n' || cc=='\t'|| cc=='\r');
|
||||
if (isSpace && !hasSpace){
|
||||
hasSpace = MB_TRUE;
|
||||
lIDList.subString(start, end, thisID);
|
||||
resultSet->add(context->getOwnerDocument()->getElementById(thisID));
|
||||
} else if (!isSpace && hasSpace){
|
||||
start = end;
|
||||
hasSpace = MB_FALSE;
|
||||
};
|
||||
};
|
||||
result = resultSet;
|
||||
};
|
||||
break;
|
||||
case LAST :
|
||||
if ( nodeSet ) result = new NumberResult((double)nodeSet->size());
|
||||
else result = new NumberResult(0.0);
|
||||
|
||||
Reference in New Issue
Block a user