Mozilla/mozilla/extensions/transformiix/source/xslt/functions/SystemPropertyFunctionCall.cpp
peterv%netscape.com f21892e8db Landing TX_BRIDGE_1_1_BRANCH.
Rewrite pretty much all variable and parameter handling. Makes global and local variables be handled differently. Global variables are no longer part of the variables stack, and are lazily evaluated. Fixes bugs 117658, 92929 and some unfiled bugs and fixes remaining parts of bugs 83651 and 96802. Patch by sicking, r=Pike sr=bz.

Fix for bug 156464: fix rounding problems in module, allow patterns without any '0's in the integer part and fix problems with grouping for standalone. Patch by sicking, r=Pike sr=bz.

Fix for bug 157340 (Probable bugs in extensions/transformiix/source/base/txMozillaString.h). Patch by peterv, r=Pike, sr=bz.

Fix for bug 146967 (Clean up Transformiix strings). Patch by peterv, r=sicking, sr=jst.

Fix for bug 156464 (Remove static strings from Transformiix). Patch by peterv, r=Pike, sr=jst.


git-svn-id: svn://10.0.0.236/trunk@126495 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-06 12:28:27 +00:00

73 lines
2.3 KiB
C++

#include "txIXPathContext.h"
#include "txAtoms.h"
#include "XMLUtils.h"
#include "XSLTFunctions.h"
/*
Implementation of XSLT 1.0 extension function: system-property
*/
/**
* Creates a new system-property function call
* aNode is the Element in the stylesheet containing the
* Expr and is used for namespaceID resolution
**/
SystemPropertyFunctionCall::SystemPropertyFunctionCall(Node* aQNameResolveNode)
: mQNameResolveNode(aQNameResolveNode)
{
}
/**
* Evaluates this Expr based on the given context node and processor state
* @param context the context node for evaluation of this Expr
* @param cs the ContextState containing the stack information needed
* for evaluation
* @return the result of the evaluation
* @see FunctionCall.h
**/
ExprResult* SystemPropertyFunctionCall::evaluate(txIEvalContext* aContext)
{
ExprResult* result = NULL;
if (requireParams(1, 1, aContext)) {
txListIterator iter(&params);
Expr* param = (Expr*)iter.next();
ExprResult* exprResult = param->evaluate(aContext);
if (exprResult->getResultType() == ExprResult::STRING) {
String property;
exprResult->stringValue(property);
txExpandedName qname;
nsresult rv = qname.init(property, mQNameResolveNode, MB_TRUE);
if (NS_SUCCEEDED(rv) &&
qname.mNamespaceID == kNameSpaceID_XSLT) {
if (qname.mLocalName == txXSLTAtoms::version) {
result = new NumberResult(1.0);
}
else if (qname.mLocalName == txXSLTAtoms::vendor) {
result = new StringResult("Transformiix");
}
else if (qname.mLocalName == txXSLTAtoms::vendorUrl) {
result = new StringResult("http://www.mozilla.org/projects/xslt/");
}
}
}
else {
String err("Invalid argument passed to system-property(), expecting String");
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
result = new StringResult(err);
}
}
if (!result) {
result = new StringResult("");
}
return result;
}
nsresult SystemPropertyFunctionCall::getNameAtom(txAtom** aAtom)
{
*aAtom = txXSLTAtoms::systemProperty;
TX_ADDREF_ATOM(*aAtom);
return NS_OK;
}