XslFunctions.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #if 0 //this is just a sample Xalan (XSLT) external function
  14. #include "XslFunctions.hpp"
  15. #include "XPath/XObjectFactory.hpp"
  16. FunctionSample::FunctionSample()
  17. {
  18. }
  19. FunctionSample::~FunctionSample()
  20. {
  21. }
  22. XObjectPtr
  23. FunctionSample::execute(
  24. XPathExecutionContext& executionContext,
  25. XalanNode* /* context */,
  26. const XObjectPtr arg1,
  27. const XObjectPtr arg2,
  28. const Locator* /* locator */) const
  29. {
  30. assert(arg1.null() == false);
  31. assert(arg2.null() == false);
  32. XalanDOMString path;
  33. arg1->str(path);
  34. const bool bLinux = arg2->boolean();
  35. XalanDOMChar dchOld;
  36. XalanDOMChar dchNew;
  37. if (bLinux)
  38. {
  39. dchOld = '\\';
  40. dchNew = '/';
  41. }
  42. else
  43. {
  44. dchOld = '/';
  45. dchOld = '\\';
  46. }
  47. int len = path.length();
  48. for (int i=0; i<len; i++)
  49. if (path[i] == dchOld)
  50. path[i] = dchNew;
  51. return executionContext.getXObjectFactory().createString(path);
  52. }
  53. #if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
  54. Function*
  55. #else
  56. FunctionSample*
  57. #endif
  58. FunctionSample::clone() const
  59. {
  60. return new FunctionSample(*this);
  61. }
  62. const XalanDOMString
  63. FunctionSample::getError() const
  64. {
  65. return StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("The boolean() function takes one argument!"));
  66. }
  67. #endif //0