auriemma 00/11/06 11:49:19
Added: c/src/XPath FunctionBoolean.cpp FunctionCeiling.cpp
FunctionConcat.cpp FunctionContains.cpp
FunctionCount.cpp FunctionFalse.cpp
FunctionFloor.cpp FunctionID.cpp FunctionLang.cpp
FunctionLast.cpp FunctionLocalName.cpp
FunctionName.cpp FunctionNamespaceURI.cpp
FunctionNormalizeSpace.cpp FunctionNot.cpp
FunctionNumber.cpp FunctionPosition.cpp
FunctionRound.cpp FunctionStartsWith.cpp
FunctionString.cpp FunctionStringLength.cpp
FunctionSubstring.cpp FunctionSubstringAfter.cpp
FunctionSubstringBefore.cpp FunctionSum.cpp
FunctionTranslate.cpp FunctionTrue.cpp
Log:
Implementation files for XPath Functions so they are called with a specific
number of arguments.
Revision Changes Path
1.1 xml-xalan/c/src/XPath/FunctionBoolean.cpp
Index: FunctionBoolean.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionBoolean.hpp>
FunctionBoolean::FunctionBoolean()
{
}
FunctionBoolean::~FunctionBoolean()
{
}
XObject*
FunctionBoolean::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
return
executionContext.getXObjectFactory().createBoolean(arg1->boolean());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionBoolean*
#endif
FunctionBoolean::clone() const
{
return new FunctionBoolean(*this);
}
const XalanDOMString
FunctionBoolean::getError() const
{
return "The boolean() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionCeiling.cpp
Index: FunctionCeiling.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionCeiling.hpp>
FunctionCeiling::FunctionCeiling()
{
}
FunctionCeiling::~FunctionCeiling()
{
}
XObject*
FunctionCeiling::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
return
executionContext.getXObjectFactory().createNumber(ceil(arg1->num()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionCeiling*
#endif
FunctionCeiling::clone() const
{
return new FunctionCeiling(*this);
}
const XalanDOMString
FunctionCeiling::getError() const
{
return "The ceiling() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionConcat.cpp
Index: FunctionConcat.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionConcat.hpp>
FunctionConcat::FunctionConcat()
{
}
FunctionConcat::~FunctionConcat()
{
}
XObject*
FunctionConcat::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1,
const XObject* arg2,
const XObject* arg3)
{
assert(arg1 != 0 || arg2 != 0 || arg3 != 0);
XalanDOMString theResult;
theResult += arg1->str();
theResult += arg2->str();
theResult += arg3->str();
return executionContext.getXObjectFactory().createString(theResult);
}
XObject*
FunctionConcat::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1,
const XObject* arg2)
{
assert(arg1 != 0 || arg2 != 0);
XalanDOMString theResult;
theResult += arg1->str();
theResult += arg2->str();
return executionContext.getXObjectFactory().createString(theResult);
}
XObject*
FunctionConcat::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
int
/* opPos */,
const XObjectArgVectorType& args)
{
const XObjectArgVectorType::size_type theArgCount = args.size();
XalanDOMString theResult;
for(XObjectArgVectorType::size_type i = 0; i < theArgCount; i++)
{
theResult += args[i]->str();
}
return executionContext.getXObjectFactory().createString(theResult);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionConcat*
#endif
FunctionConcat::clone() const
{
return new FunctionConcat(*this);
}
const XalanDOMString
FunctionConcat::getError() const
{
return "The concat() function takes at least two arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionContains.cpp
Index: FunctionContains.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionContains.hpp>
FunctionContains::FunctionContains()
{
}
FunctionContains::~FunctionContains()
{
}
XObject*
FunctionContains::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1,
const XObject* arg2)
{
assert(arg1 != 0 || arg2 != 0);
const XalanDOMString& str1 = arg1->str();
const XalanDOMString& str2 = arg2->str();
bool fResult = true;
// If str2 is empty, then don't bother to check anything.
if (isEmpty(str2) == false)
{
// Is str1 empty?
if (isEmpty(str1) == true)
{
fResult = false;
}
else
{
// OK, both strings have some data, so look for
// the index...
const unsigned int theIndex =
indexOf(str1, str2);
fResult = theIndex < length(str1) ? true : false;
}
}
return executionContext.getXObjectFactory().createBoolean(fResult);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionContains*
#endif
FunctionContains::clone() const
{
return new FunctionContains(*this);
}
const XalanDOMString
FunctionContains::getError() const
{
return "The contains() function takes two arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionCount.cpp
Index: FunctionCount.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionCount.hpp>
FunctionCount::FunctionCount()
{
}
FunctionCount::~FunctionCount()
{
}
XObject*
FunctionCount::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
const NodeRefListBase& theNodeList = arg1->nodeset();
return
executionContext.getXObjectFactory().createNumber(theNodeList.getLength());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionCount*
#endif
FunctionCount::clone() const
{
return new FunctionCount(*this);
}
const XalanDOMString
FunctionCount::getError() const
{
return "The count() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionFalse.cpp
Index: FunctionFalse.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionFalse.hpp>
FunctionFalse::FunctionFalse()
{
}
FunctionFalse::~FunctionFalse()
{
}
XObject*
FunctionFalse::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */)
{
return executionContext.getXObjectFactory().createBoolean(false);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionFalse*
#endif
FunctionFalse::clone() const
{
return new FunctionFalse(*this);
}
const XalanDOMString
FunctionFalse::getError() const
{
return "The false() function does not accept arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionFloor.cpp
Index: FunctionFloor.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionFloor.hpp>
FunctionFloor::FunctionFloor()
{
}
FunctionFloor::~FunctionFloor()
{
}
XObject*
FunctionFloor::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
return
executionContext.getXObjectFactory().createNumber(floor(arg1->num()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionFloor*
#endif
FunctionFloor::clone() const
{
return new FunctionFloor(*this);
}
const XalanDOMString
FunctionFloor::getError() const
{
return "The floor() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionID.cpp
Index: FunctionID.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionID.hpp>
FunctionID::FunctionID()
{
}
FunctionID::~FunctionID()
{
}
XObject*
FunctionID::execute(
XPathExecutionContext& executionContext,
XalanNode*
context,
const XObject* arg1)
{
assert(arg1 != 0);
if (context == 0)
{
executionContext.error("The id() function requires a non-null
context node!",
context);
}
// Do the callback to get the data.
FunctionIDXObjectTypeCallback theCallback(executionContext);
const XalanDOMString theResultString =
theCallback.processCallback(*arg1);
// Get the context document, so we can search for nodes.
const XalanDocument* const theDocContext = context->getNodeType()
== XalanNode::DOCUMENT_NODE ?
#if defined(XALAN_OLD_STYLE_CASTS)
(const
XalanDocument*)context :
#else
static_cast<const XalanDocument*>(context) :
#endif
context->getOwnerDocument();
assert(theDocContext != 0);
typedef XPathExecutionContext::BorrowReturnMutableNodeRefList
BorrowReturnMutableNodeRefList;
// This list will hold the nodes we find.
BorrowReturnMutableNodeRefList theNodeList(executionContext);
// If there is no context, we cannot continue.
if(0 == theDocContext)
{
executionContext.error("The context node does not have an owner
document!",
context);
}
else if (length(theResultString) > 0)
{
#if defined(XALAN_NO_NAMESPACES)
typedef set<XalanDOMString, less<XalanDOMString> >
TokenSetType;
#else
typedef std::set<XalanDOMString> TokenSetType;
#endif
// This set will hold tokens that we've previously found, so
// we can avoid looking more than once.
TokenSetType thePreviousTokens;
StringTokenizer theTokenizer(theResultString);
// Parse the result string...
while(theTokenizer.hasMoreTokens() == true)
{
const XalanDOMString theToken =
theTokenizer.nextToken();
if (length(theToken) > 0)
{
// See if we've already seen this one...
TokenSetType::const_iterator i =
thePreviousTokens.find(theToken);
if (i == thePreviousTokens.end())
{
thePreviousTokens.insert(theToken);
XalanNode* const theNode =
executionContext.getElementByID(theToken, *theDocContext);
if (theNode != 0)
{
theNodeList->addNodeInDocOrder(theNode, executionContext);
}
}
}
} //while
}
return executionContext.getXObjectFactory().createNodeSet(theNodeList);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionID*
#endif
FunctionID::clone() const
{
return new FunctionID(*this);
}
const XalanDOMString
FunctionID::getError() const
{
return "The id() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionLang.cpp
Index: FunctionLang.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionLang.hpp>
FunctionLang::FunctionLang()
{
}
FunctionLang::~FunctionLang()
{
}
XObject*
FunctionLang::execute(
XPathExecutionContext& executionContext,
XalanNode*
context,
const XObject* arg1)
{
assert(arg1 != 0);
const XalanNode* parent = context;
bool fMatch = false;
const XalanDOMString& lang = arg1->str();
while(0 != parent)
{
if(XalanNode::ELEMENT_NODE == parent->getNodeType())
{
const XalanElement* const theElementNode =
#if defined(XALAN_OLD_STYLE_CASTS)
(const XalanElement*)parent;
#else
static_cast<const XalanElement*>(parent);
#endif
const XalanDOMString langVal =
theElementNode->getAttribute(StaticStringToDOMString(
XALAN_STATIC_UCODE_STRING("xml:lang")));
if(0 != length(langVal))
{
if(startsWith(toLowerCase(langVal),
toLowerCase(lang)))
{
const unsigned int valLen =
length(lang);
if(length(langVal) == valLen ||
charAt(langVal, valLen) ==
XalanUnicode::charHyphenMinus)
{
fMatch = true;
break;
}
}
}
}
parent = executionContext.getParentOfNode(*parent);
}
return executionContext.getXObjectFactory().createBoolean(fMatch);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionLang*
#endif
FunctionLang::clone() const
{
return new FunctionLang(*this);
}
const XalanDOMString
FunctionLang::getError() const
{
return "The lang() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionLast.cpp
Index: FunctionLast.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionLast.hpp>
FunctionLast::FunctionLast()
{
}
FunctionLast::~FunctionLast()
{
}
XObject*
FunctionLast::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */)
{
const unsigned int theValue =
executionContext.getContextNodeListLength();
return executionContext.getXObjectFactory().createNumber(theValue);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionLast*
#endif
FunctionLast::clone() const
{
return new FunctionLast(*this);
}
const XalanDOMString
FunctionLast::getError() const
{
return "The last() function does not accept arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionLocalName.cpp
Index: FunctionLocalName.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionLocalName.hpp>
FunctionLocalName::FunctionLocalName()
{
}
FunctionLocalName::~FunctionLocalName()
{
}
XObject*
FunctionLocalName::execute(
XPathExecutionContext& executionContext,
XalanNode*
context,
const XObject* arg1)
{
assert(arg1 != 0);
const NodeRefListBase& theNodeList = arg1->nodeset();
if (theNodeList.getLength() > 0)
{
context = theNodeList.item(0);
}
else
{
context = 0;
}
return execute(executionContext, context);
}
XObject*
FunctionLocalName::execute(
XPathExecutionContext& executionContext,
XalanNode* context)
{
XalanDOMString theData;
if (context == 0)
{
executionContext.error("The local-name() function requires a
non-null context node!");
}
else
{
const XalanNode::NodeType theType =
context->getNodeType();
if(theType == XalanNode::ATTRIBUTE_NODE ||
theType == XalanNode::ELEMENT_NODE ||
theType == XalanNode::PROCESSING_INSTRUCTION_NODE)
{
theData = executionContext.getLocalNameOfNode(*context);
}
}
return executionContext.getXObjectFactory().createString(theData);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionLocalName*
#endif
FunctionLocalName::clone() const
{
return new FunctionLocalName(*this);
}
const XalanDOMString
FunctionLocalName::getError() const
{
return "The local-name() function takes zero or one arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionName.cpp
Index: FunctionName.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionName.hpp>
FunctionName::FunctionName()
{
}
FunctionName::~FunctionName()
{
}
XObject*
FunctionName::execute(
XPathExecutionContext& executionContext,
XalanNode*
context,
const XObject* arg1)
{
assert(arg1 != 0);
XalanDOMString theData;
XalanNode* theContext = 0;
const NodeRefListBase& theNodeList = arg1->nodeset();
if (theNodeList.getLength() > 0)
{
assert(theNodeList.item(0) != 0);
theData = executionContext.getNameOfNode(*theNodeList.item(0));
}
return executionContext.getXObjectFactory().createString(theData);
}
XObject*
FunctionName::execute(
XPathExecutionContext& executionContext,
XalanNode* context)
{
XalanDOMString theData;
if (context == 0)
{
executionContext.error("The name() function requires a non-null
context node!");
}
else
{
theData = executionContext.getNameOfNode(*context);
}
return executionContext.getXObjectFactory().createString(theData);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionName*
#endif
FunctionName::clone() const
{
return new FunctionName(*this);
}
const XalanDOMString
FunctionName::getError() const
{
return "The name() function takes zero or one arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionNamespaceURI.cpp
Index: FunctionNamespaceURI.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionNamespaceURI.hpp>
FunctionNamespaceURI::FunctionNamespaceURI()
{
}
FunctionNamespaceURI::~FunctionNamespaceURI()
{
}
XObject*
FunctionNamespaceURI::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
XalanDOMString theNamespace;
theNamespace = getNamespaceFromNodeSet(*arg1, executionContext);
return executionContext.getXObjectFactory().createString(theNamespace);
}
XObject*
FunctionNamespaceURI::execute(
XPathExecutionContext& executionContext,
XalanNode* context)
{
XalanDOMString theNamespace;
if (context == 0)
{
executionContext.error("The namespace-uri() function requires a
non-null context node!");
}
else
{
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
// as the only member.
// So we have to create an XObject with the context node as
// the only member.
// We shroud the temporary getNamespaceFromNodeSet( in a
// FactoryObjectAutoPointer because it can be deleted once
// we're done.
// An XObject that contains the context node.
XObjectGuard theXObject(executionContext.getXObjectFactory(),
executionContext.createNodeSet(*context));
theNamespace = getNamespaceFromNodeSet(*theXObject.get(),
executionContext);
}
return executionContext.getXObjectFactory().createString(theNamespace);
}
XalanDOMString
FunctionNamespaceURI::getNamespaceFromNodeSet(const XObject&
theXObject,
XPathExecutionContext&
theContext)
{
XalanDOMString theNamespace;
const NodeRefListBase& theList = theXObject.nodeset();
if (theList.getLength() > 0)
{
theNamespace = theContext.getNamespaceOfNode(*theList.item(0));
}
return theNamespace;
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionNamespaceURI*
#endif
FunctionNamespaceURI::clone() const
{
return new FunctionNamespaceURI(*this);
}
const XalanDOMString
FunctionNamespaceURI::getError() const
{
return "The namespace-uri() function takes zero arguments or one
argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionNormalizeSpace.cpp
Index: FunctionNormalizeSpace.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionNormalizeSpace.hpp>
FunctionNormalizeSpace::FunctionNormalizeSpace()
{
}
FunctionNormalizeSpace::~FunctionNormalizeSpace()
{
}
XObject*
FunctionNormalizeSpace::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
XalanDOMString theSourceString;
theSourceString = arg1->str();
return
executionContext.getXObjectFactory().createString(NormalizeSpace(theSourceString));
}
XObject*
FunctionNormalizeSpace::execute(
XPathExecutionContext& executionContext,
XalanNode* context)
{
XalanDOMString theSourceString;
if (context == 0)
{
executionContext.error("The normalize-space() function requires
a non-null context node!",
context);
}
else
{
// The XPath standard says that if there
// are no arguments, the default is to turn the contextNode
// into a string-value, which really means using FunctionString,
// but we don't need to do that, since our XObject classes
// do the real work in turning themselves into strings.
// A node set that contains the context node.
XObjectGuard theXObject(executionContext.getXObjectFactory(),
executionContext.createNodeSet(*context));
// Now, get the string from the XObject.
theSourceString = theXObject->str();
}
return
executionContext.getXObjectFactory().createString(NormalizeSpace(theSourceString));
}
const XalanDOMString
FunctionNormalizeSpace::NormalizeSpace(const XalanDOMString& theSourceString)
const
{
const unsigned int theSourceStringLength =
length(theSourceString);
XalanDOMChar thePreviousChar = 0;
// A vector to contain the new characters. We'll use it to construct
// the result string.
#if !defined(XALAN_NO_NAMESPACES)
using std::vector;
#endif
vector<XalanDOMChar> theVector;
// The result string can only be as large as the source string, so
// just reserve the space now. Also reserve a space for the
// terminating 0.
theVector.reserve(theSourceStringLength + 1);
// OK, strip out any multiple spaces...
for (unsigned int i = 0; i < theSourceStringLength; i++)
{
const XalanDOMChar theCurrentChar =
charAt(theSourceString, i);
if (isXMLWhitespace(theCurrentChar) == true)
{
// If the previous character wasn't a space, and we've
// encountered some non-space characters, then push the
// space.
if (isXMLWhitespace(thePreviousChar) == false &&
theVector.size() > 0)
{
theVector.push_back(XalanDOMChar(XalanUnicode::charSpace));
}
}
else
{
theVector.push_back(theCurrentChar);
}
thePreviousChar = theCurrentChar;
}
if (theVector.empty() == false && isXMLWhitespace(theVector.back()) ==
true)
{
// The last character is a space, so remove it
theVector.pop_back();
}
return XalanDOMString(theVector.begin(), theVector.size());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionNormalizeSpace*
#endif
FunctionNormalizeSpace::clone() const
{
return new FunctionNormalizeSpace(*this);
}
const XalanDOMString
FunctionNormalizeSpace::getError() const
{
return "The normalize-space() function takes zero arguments or one
argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionNot.cpp
Index: FunctionNot.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionNot.hpp>
FunctionNot::FunctionNot()
{
}
FunctionNot::~FunctionNot()
{
}
XObject*
FunctionNot::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
return
executionContext.getXObjectFactory().createBoolean(!arg1->boolean());
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionNot*
#endif
FunctionNot::clone() const
{
return new FunctionNot(*this);
}
const XalanDOMString
FunctionNot::getError() const
{
return "The not() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionNumber.cpp
Index: FunctionNumber.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionNumber.hpp>
FunctionNumber::FunctionNumber()
{
}
FunctionNumber::~FunctionNumber()
{
}
XObject*
FunctionNumber::execute(
XPathExecutionContext& executionContext,
XalanNode*
context,
const XObject* arg1)
{
assert(arg1 != 0);
double theValue = 0.0L;
theValue = arg1->num();
return executionContext.getXObjectFactory().createNumber(theValue);
}
XObject*
FunctionNumber::execute(
XPathExecutionContext& executionContext,
XalanNode* context)
{
double theValue = 0.0L;
if (context == 0)
{
executionContext.error("The number() function requires a
non-null context node!");
}
else
{
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
// as the only member.
// So we have to create an XNodeList with the context node as
// the only member and call the num() function on it. We shroud
// the temporary XNodeList in an XObjectGuard because it can be
// deleted once we've converted the context node to a number.
// An XObject that contains the context node.
XObjectGuard theXObject(executionContext.getXObjectFactory(),
executionContext.createNodeSet(*context));
// Get the numeric value of the theXObject...
theValue = theXObject->num();
}
return executionContext.getXObjectFactory().createNumber(theValue);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionNumber*
#endif
FunctionNumber::clone() const
{
return new FunctionNumber(*this);
}
const XalanDOMString
FunctionNumber::getError() const
{
return "The number() function takes zero arguments or one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionPosition.cpp
Index: FunctionPosition.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionPosition.hpp>
FunctionPosition::FunctionPosition()
{
}
FunctionPosition::~FunctionPosition()
{
}
XObject*
FunctionPosition::execute(
XPathExecutionContext& executionContext,
XalanNode* context)
{
if (context == 0)
{
executionContext.error("The position() function requires a
non-null context node!",
context);
}
const unsigned int theValue =
executionContext.getContextNodeListPosition(*context);
return executionContext.getXObjectFactory().createNumber(theValue);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionPosition*
#endif
FunctionPosition::clone() const
{
return new FunctionPosition(*this);
}
const XalanDOMString
FunctionPosition::getError() const
{
return "The position() function does not accept arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionRound.cpp
Index: FunctionRound.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionRound.hpp>
#include <PlatformSupport/DoubleSupport.hpp>
FunctionRound::FunctionRound()
{
}
FunctionRound::~FunctionRound()
{
}
XObject*
FunctionRound::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
return
executionContext.getXObjectFactory().createNumber(getRoundedValue(arg1->num()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionRound*
#endif
FunctionRound::clone() const
{
return new FunctionRound(*this);
}
double
FunctionRound::getRoundedValue(double theValue)
{
if (DoubleSupport::isNaN(theValue))
{
return DoubleSupport::getNaN();
}
else if (DoubleSupport::isPositiveInfinity(theValue))
{
return DoubleSupport::getPositiveInfinity();
}
if (DoubleSupport::isNegativeInfinity(theValue))
{
return DoubleSupport::getNegativeInfinity();
}
else if (theValue == 0)
{
return 0.0;
}
else if (theValue > 0)
{
return long(theValue + 0.5);
}
else
{
// Negative numbers are a special case. Any time we
// have -0.5 as the fractional part, we have to
// round up (toward 0), rather than down.
double intPart = 0;
const double fracPart = modf(theValue, &intPart);
if (fracPart == -0.5)
{
// special case -- we have have to round toward 0...
return long(theValue + 0.5);
}
else
{
return long(theValue - 0.5);
}
}
}
const XalanDOMString
FunctionRound::getError() const
{
return "The round() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionStartsWith.cpp
Index: FunctionStartsWith.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionStartsWith.hpp>
FunctionStartsWith::FunctionStartsWith()
{
}
FunctionStartsWith::~FunctionStartsWith()
{
}
XObject*
FunctionStartsWith::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1,
const XObject* arg2)
{
assert(arg1 != 0 || arg2 != 0);
const bool fStartsWith = startsWith(arg1->str(),
arg2->str());
return executionContext.getXObjectFactory().createBoolean(fStartsWith);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionStartsWith*
#endif
FunctionStartsWith::clone() const
{
return new FunctionStartsWith(*this);
}
const XalanDOMString
FunctionStartsWith::getError() const
{
return "The starts-with() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionString.cpp
Index: FunctionString.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionString.hpp>
FunctionString::FunctionString()
{
}
FunctionString::~FunctionString()
{
}
XObject*
FunctionString::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
return executionContext.getXObjectFactory().createString(arg1->str());
}
XObject*
FunctionString::execute(
XPathExecutionContext& executionContext,
XalanNode* context)
{
XalanDOMString theValue;
if (context == 0)
{
executionContext.error("The string() function requires a
non-null context node!");
}
else
{
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
// as the only member.
// So we have to create an XNodeList with the context node as
// the only member and call the str() function on it. We shroud
// the temporary XNodeList in an XObjectGuard because it can be
// deleted once we've converted the context node to a string.
// An XObject that contains the context node.
XObjectGuard theXObject(executionContext.getXObjectFactory(),
executionContext.createNodeSet(*context));
// Get the value of the theXObject...
theValue = theXObject->str();
}
return executionContext.getXObjectFactory().createString(theValue);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionString*
#endif
FunctionString::clone() const
{
return new FunctionString(*this);
}
const XalanDOMString
FunctionString::getError() const
{
return "The string() function takes zero or one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionStringLength.cpp
Index: FunctionStringLength.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionStringLength.hpp>
FunctionStringLength::FunctionStringLength()
{
}
FunctionStringLength::~FunctionStringLength()
{
}
XObject*
FunctionStringLength::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
unsigned int theLength = length(arg1->str());
return executionContext.getXObjectFactory().createNumber(theLength);
}
XObject*
FunctionStringLength::execute(
XPathExecutionContext& executionContext,
XalanNode* context)
{
unsigned int theLength = 0;
if (context == 0)
{
executionContext.error("The string-length() function requires a
non-null context node!");
}
else
{
XalanDOMString theValue;
// The XPath standard says that if there are no arguments,
// the argument defaults to a node set with the context node
// as the only member.
// So we have to create an XNodeList with the context node as
// the only member and call the str() function on it. We shroud
// the temporary XNodeList in an XObjectGuard because it can be
// deleted once we've converted the context node to a string.
// An XObject that contains the context node.
XObjectGuard theXObject(executionContext.getXObjectFactory(),
executionContext.createNodeSet(*context));
// Get the value of the theXObject...
theValue = theXObject->str();
theLength = length(theValue);
}
return executionContext.getXObjectFactory().createNumber(theLength);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionStringLength*
#endif
FunctionStringLength::clone() const
{
return new FunctionStringLength(*this);
}
const XalanDOMString
FunctionStringLength::getError() const
{
return "The string-length() function takes zero or one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionSubstring.cpp
Index: FunctionSubstring.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionSubstring.hpp>
FunctionSubstring::FunctionSubstring()
{
}
FunctionSubstring::~FunctionSubstring()
{
}
XObject*
FunctionSubstring::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1,
const XObject* arg2,
const XObject* arg3)
{
assert(arg1 != 0 || arg2 != 0);
const XalanDOMString& theSourceString = arg1->str();
const unsigned int theSourceStringLength =
length(theSourceString);
#if !defined(XALAN_NO_NAMESPACES)
using std::vector;
#endif
// This buffer will hold the output characters.
vector<XalanDOMChar> theBuffer;
if (theSourceStringLength > 0)
{
// The substring can only be as long as the source string,
// so reserve enough space now. Also reserve space for
// the terminating 0.
theBuffer.reserve(theSourceStringLength);
// $$$ ToDo: Add support for NaN.
// Get the value of the second argument...
const double theSecondArgValue =
FunctionRound::getRoundedValue(arg2->num());
// Now, total the second and third arguments. If
// the third argument is missing, make the total
// DBL_MAX.
const double theTotal =
arg3 == 0 ? DBL_MAX :
FunctionRound::getRoundedValue(
theSecondArgValue + arg3->num());
if (DoubleSupport::isNaN(theSecondArgValue) == false &&
DoubleSupport::isNaN(theTotal) == false &&
DoubleSupport::isNegativeInfinity(theTotal) == false)
{
// Start with 1, since strings are index from 1 in the
XPath spec,
for (unsigned int i = 1; i <= theSourceStringLength;
i++)
{
// Is the index greater than or equal to the
second argument?
if (i >= theSecondArgValue)
{
// Is it less than the sum of the
second and
// third arguments?
if (i < theTotal)
{
// It is, so include the
character.
theBuffer.push_back(charAt(theSourceString, i - 1));
}
else
{
// It's not, so stop.
break;
}
}
}
}
}
return executionContext.getXObjectFactory().createString(
XalanDOMString(theBuffer.begin(), theBuffer.size()));
}
XObject*
FunctionSubstring::execute(
XPathExecutionContext& executionContext,
XalanNode*
context,
const XObject* arg1,
const XObject* arg2)
{
assert(arg1 != 0 || arg2 != 0);
return execute(executionContext, context, arg1, arg2, 0);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionSubstring*
#endif
FunctionSubstring::clone() const
{
return new FunctionSubstring(*this);
}
const XalanDOMString
FunctionSubstring::getError() const
{
return "The substring() function takes two or three arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp
Index: FunctionSubstringAfter.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionSubstringAfter.hpp>
FunctionSubstringAfter::FunctionSubstringAfter()
{
}
FunctionSubstringAfter::~FunctionSubstringAfter()
{
}
XObject*
FunctionSubstringAfter::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1,
const XObject* arg2)
{
assert(arg1 != 0 || arg2 != 0);
const XalanDOMString& theFirstString = arg1->str();
const XalanDOMString& theSecondString = arg2->str();
const unsigned int theIndex = indexOf(theFirstString,
theSecondString);
const unsigned int theFirstStringLength =
length(theFirstString);
#if !defined(XALAN_NO_NAMESPACES)
using std::vector;
#endif
// This buffer will hold the output characters.
vector<XalanDOMChar> theBuffer;
if (theIndex < theFirstStringLength)
{
unsigned int theStartIndex = theIndex +
length(theSecondString);
// The result string can only be as large as the source string,
so
// just reserve the space now. Also reserve a space for the
// terminating 0.
theBuffer.reserve(theFirstStringLength - theStartIndex + 1);
for (; theStartIndex < theFirstStringLength; theStartIndex++)
{
theBuffer.push_back(charAt(theFirstString,
theStartIndex));
}
}
return executionContext.getXObjectFactory().createString(
XalanDOMString(theBuffer.begin(), theBuffer.size()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionSubstringAfter*
#endif
FunctionSubstringAfter::clone() const
{
return new FunctionSubstringAfter(*this);
}
const XalanDOMString
FunctionSubstringAfter::getError() const
{
return "The substring-after() function takes two arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp
Index: FunctionSubstringBefore.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionSubstringBefore.hpp>
FunctionSubstringBefore::FunctionSubstringBefore()
{
}
FunctionSubstringBefore::~FunctionSubstringBefore()
{
}
XObject*
FunctionSubstringBefore::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1,
const XObject* arg2)
{
assert(arg1 != 0 || arg2 != 0);
const XalanDOMString& theFirstString = arg1->str();
const XalanDOMString& theSecondString = arg2->str();
const unsigned int theIndex = indexOf(theFirstString,
theSecondString);
#if !defined(XALAN_NO_NAMESPACES)
using std::vector;
#endif
// This buffer will hold the output characters.
vector<XalanDOMChar> theBuffer;
if (theIndex < length(theFirstString))
{
// The result string can only be as large as the source string,
so
// just reserve the space now. Also reserve a space for the
// terminating 0.
theBuffer.reserve(theIndex + 2);
// Stop with the last character before the index.
for (unsigned int i = 0; i < theIndex; i++)
{
theBuffer.push_back(charAt(theFirstString, i));
}
}
return executionContext.getXObjectFactory().createString(
XalanDOMString(theBuffer.begin(), theBuffer.size()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionSubstringBefore*
#endif
FunctionSubstringBefore::clone() const
{
return new FunctionSubstringBefore(*this);
}
const XalanDOMString
FunctionSubstringBefore::getError() const
{
return "The substring-before() function takes two arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionSum.cpp
Index: FunctionSum.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionSum.hpp>
FunctionSum::FunctionSum()
{
}
FunctionSum::~FunctionSum()
{
}
XObject*
FunctionSum::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1)
{
assert(arg1 != 0);
const NodeRefListBase& nl = arg1->nodeset();
double sum = 0.0;
const unsigned int count = nl.getLength();
for (unsigned int i = 0; i < count; i++)
{
XalanDOMString theData;
executionContext.getNodeData(*nl.item(i), theData);
sum += DoubleSupport::toDouble(theData);
}
return executionContext.getXObjectFactory().createNumber(sum);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionSum*
#endif
FunctionSum::clone() const
{
return new FunctionSum(*this);
}
const XalanDOMString
FunctionSum::getError() const
{
return "The sum() function takes one argument!";
}
1.1 xml-xalan/c/src/XPath/FunctionTranslate.cpp
Index: FunctionTranslate.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionTranslate.hpp>
FunctionTranslate::FunctionTranslate()
{
}
FunctionTranslate::~FunctionTranslate()
{
}
XObject*
FunctionTranslate::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */,
const XObject* arg1,
const XObject* arg2,
const XObject* arg3)
{
assert(arg1 != 0 || arg2 != 0 || arg3 != 0);
const XalanDOMString& theFirstString = arg1->str();
const XalanDOMString& theSecondString = arg2->str();
const XalanDOMString& theThirdString = arg3->str();
const unsigned int theFirstStringLength =
length(theFirstString);
const unsigned int theSecondStringLength =
length(theSecondString);
const unsigned int theThirdStringLength =
length(theThirdString);
#if !defined(XALAN_NO_NAMESPACES)
using std::vector;
#endif
// A vector to contain the new characters. We'll use it to construct
// the result string.
vector<XalanDOMChar> theBuffer;
// The result string can only be as large as the first string, so
// just reserve the space now. Also reserve space for the
// terminating 0.
theBuffer.reserve(theFirstStringLength + 1);
for (unsigned int i = 0; i < theFirstStringLength; i++)
{
const XalanDOMChar theCurrentChar =
charAt(theFirstString, i);
const unsigned int theIndex =
indexOf(theSecondString, theCurrentChar);
if (theIndex >= theSecondStringLength)
{
// Didn't find the character in the second string, so it
// is not translated.
theBuffer.push_back(theCurrentChar);
}
else if (theIndex < theThirdStringLength)
{
// OK, there's a corresponding character in the
// third string, so do the translation...
theBuffer.push_back(charAt(theThirdString, theIndex));
}
else
{
// There's no corresponding character in the
// third string, since it's shorter than the
// second string. In this case, the character
// is removed from the output string, so don't
// do anything.
}
}
return executionContext.getXObjectFactory().createString(
XalanDOMString(theBuffer.begin(), theBuffer.size()));
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionTranslate*
#endif
FunctionTranslate::clone() const
{
return new FunctionTranslate(*this);
}
const XalanDOMString
FunctionTranslate::getError() const
{
return "The translate() function takes three arguments!";
}
1.1 xml-xalan/c/src/XPath/FunctionTrue.cpp
Index: FunctionTrue.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include <XPath/FunctionTrue.hpp>
FunctionTrue::FunctionTrue()
{
}
FunctionTrue::~FunctionTrue()
{
}
XObject*
FunctionTrue::execute(
XPathExecutionContext& executionContext,
XalanNode* /*
context */)
{
return executionContext.getXObjectFactory().createBoolean(true);
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
Function*
#else
FunctionTrue*
#endif
FunctionTrue::clone() const
{
return new FunctionTrue(*this);
}
const XalanDOMString
FunctionTrue::getError() const
{
return "The true() function does not accept arguments!";
}