Index: xml-xalan/c/src/xalanc/NLS/en_US/XalanMsg_en_US.xlf
===================================================================
--- xml-xalan.orig/c/src/xalanc/NLS/en_US/XalanMsg_en_US.xlf
+++ xml-xalan/c/src/xalanc/NLS/en_US/XalanMsg_en_US.xlf
@@ -762,6 +762,11 @@ On<trans-unit id="FunctionDoesNotAcceptA
 		<target>The EXSLT function '{0}' does not accept any arguments.</target>
 </trans-unit>
 
+<trans-unit id="EXSLTFunctionAccepts0Or1Or2Arguments_1Param">
+	<source>The EXSLT function '{0}' accepts zero, one or two arguments.</source>
+	<target>The EXSLT function '{0}' accepts zero, one or two arguments.</target>
+</trans-unit>
+		
 <trans-unit id="EXSLTFunctionAcceptsTwoArguments_1Param">
 		<source>The EXSLT function '{0}' accepts two arguments.</source>
 		<target>The EXSLT function '{0}' accepts two arguments.</target>
Index: xml-xalan/c/src/xalanc/XalanEXSLT/XalanEXSLTRandom.cpp
===================================================================
--- /dev/null
+++ xml-xalan/c/src/xalanc/XalanEXSLT/XalanEXSLTRandom.cpp
@@ -0,0 +1,315 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "XalanEXSLTRandom.hpp"
+#include "XalanEXSLTRandomImpl.hpp"
+
+
+
+#include <ctime>
+
+
+
+#include <xalanc/PlatformSupport/AttributesImpl.hpp>
+#include <xalanc/PlatformSupport/XalanUnicode.hpp>
+
+
+
+#include <xalanc/XPath/XObjectFactory.hpp>
+#include <xalanc/XPath/XPathEnvSupportDefault.hpp>
+
+
+
+#include <xalanc/XalanTransformer/XalanDocumentBuilder.hpp>
+
+
+
+#include <xercesc/sax2/ContentHandler.hpp>
+
+
+
+#if !defined(XALAN_NO_STD_NUMERIC_LIMITS)
+#include <limits>
+#else
+#include <limits.h>
+#endif
+
+
+
+#if defined(XALAN_STRICT_ANSI_HEADERS)
+using std::time;
+using std::time_t;
+#endif
+
+
+
+XALAN_CPP_NAMESPACE_BEGIN
+
+
+
+XALAN_USING_XERCES(ContentHandler)
+
+
+
+#if !defined(XALAN_NO_STD_NUMERIC_LIMITS)
+static const long s_longMax = 
+	XALAN_STD_QUALIFIER numeric_limits<long>::max();
+#else
+static const long s_longMax =
+	LONG_MAX;
+#endif
+
+
+
+static const XalanDOMChar	s_rootNodeName[] =
+{
+    XalanUnicode::charLetter_r,
+    XalanUnicode::charLetter_o,
+    XalanUnicode::charLetter_o,
+    XalanUnicode::charLetter_t,
+    0
+};
+
+
+
+static const XalanDOMChar	s_randomNodeName[] =
+{
+	XalanUnicode::charLetter_r,
+	XalanUnicode::charLetter_a,
+	XalanUnicode::charLetter_n,
+	XalanUnicode::charLetter_d,
+	XalanUnicode::charLetter_o,
+	XalanUnicode::charLetter_m,
+	0
+};
+
+
+
+static const XalanDOMChar	s_emptyCharArray[] =
+{
+	0
+};
+
+
+
+static const AttributesImpl s_emptyAttributes(XalanMemMgrs::getDummyMemMgr());
+
+
+// RNG constants
+static const long M = 2147483647;
+static const long A = 16807;
+static const long Q = M / A;
+static const long R = M % A;
+
+
+
+XObjectPtr
+XalanEXSLTFunctionRandomSequence::execute(
+			XPathExecutionContext&			executionContext,
+			XalanNode*						context,
+			const XObjectArgVectorType&		args,
+			const LocatorType*				locator) const
+{
+	const XObjectArgVectorType::size_type   theSize = args.size();
+
+	if (theSize != 0 && theSize != 1 && theSize != 2)
+	{
+		XPathExecutionContext::GetAndReleaseCachedString theString(executionContext);
+
+		executionContext.error(getError(theString.get()), context, locator);
+	}
+
+	// Get the number of items required
+	long numItems = 1;
+	if (theSize > 0)
+	{
+		double desiredItems = args[0]->num();
+		if (desiredItems > s_longMax)
+		{
+			numItems = s_longMax;
+		}
+		else if (desiredItems > 0)
+		{
+			numItems = (long)desiredItems;
+		}
+	}
+
+	// Get the seed
+	bool	haveSeed = false;
+	long	seed = 0;
+	if (theSize > 1)
+	{
+		double desiredSeed = args[1]->num();
+		if (desiredSeed > 0 && desiredSeed <= s_longMax)
+		{
+			seed = (long)desiredSeed;
+			haveSeed = true;
+		}
+	}
+	// If no seed yet, use current time
+	if (!haveSeed)
+	{
+		time_t long_time;
+		time(&long_time);
+
+		// Flibble bits to be portable (time_t cannot be 
+		// portably cast to an integer)
+		const unsigned char *p = (const unsigned char *)&long_time;
+		for (size_t i = 0; i < sizeof(time_t); ++i)
+			seed = seed * 257 + p[i];
+		if (seed < 0)
+			seed += M;
+	}
+
+	// Create a document to hold the output numbers
+	XalanDocumentBuilder *theBuilder = executionContext.createDocumentBuilder();
+	ContentHandler *theContentHandler = theBuilder->getContentHandler();
+
+	theContentHandler->startDocument();
+	theContentHandler->startElement(s_emptyCharArray, s_emptyCharArray, s_rootNodeName, s_emptyAttributes);
+
+	// Generate N random numbers using about the oldest algorithm in the book
+	for (long i = 0; i < numItems; ++i)
+	{
+		seed = A * (seed % Q) - R * (seed / Q);
+		if (seed <= 0)
+			seed += M;
+
+		XPathExecutionContext::GetAndReleaseCachedString theFormattedNumberData(executionContext);
+		XalanDOMString& theFormattedNumber = theFormattedNumberData.get();
+		XObject::string((double)seed / (double)M, theFormattedNumber);
+
+		theContentHandler->startElement(s_emptyCharArray, s_emptyCharArray, s_randomNodeName, s_emptyAttributes);
+		theContentHandler->characters(theFormattedNumber.data(), theFormattedNumber.length());
+		theContentHandler->endElement(s_emptyCharArray, s_emptyCharArray, s_randomNodeName);
+	}
+
+	// Put the numbers in a nodeset
+	theContentHandler->endElement(s_emptyCharArray, s_emptyCharArray, s_rootNodeName);
+	theContentHandler->endDocument();
+	XPathExecutionContext::BorrowReturnMutableNodeRefList mnl(executionContext);
+	XalanDocument *theDocument = theBuilder->getDocument();
+	for (XalanNode *randomNode = theDocument->getFirstChild()->getFirstChild();
+		 randomNode;
+		 randomNode = randomNode->getNextSibling())
+	{
+		mnl->addNodeInDocOrder(randomNode, executionContext);
+	}
+	assert(mnl->checkForDuplicates(executionContext.getMemoryManager()) == false);
+	mnl->setDocumentOrder();
+	return executionContext.getXObjectFactory().createNodeSet(mnl);
+}
+
+
+
+static const XalanDOMChar	s_randomNamespace[] =
+{
+	XalanUnicode::charLetter_h,
+	XalanUnicode::charLetter_t,
+	XalanUnicode::charLetter_t,
+	XalanUnicode::charLetter_p,
+	XalanUnicode::charColon,
+	XalanUnicode::charSolidus,
+	XalanUnicode::charSolidus,
+	XalanUnicode::charLetter_e,
+	XalanUnicode::charLetter_x,
+	XalanUnicode::charLetter_s,
+	XalanUnicode::charLetter_l,
+	XalanUnicode::charLetter_t,
+	XalanUnicode::charFullStop,
+	XalanUnicode::charLetter_o,
+	XalanUnicode::charLetter_r,
+	XalanUnicode::charLetter_g,
+	XalanUnicode::charSolidus,
+	XalanUnicode::charLetter_r,
+	XalanUnicode::charLetter_a,
+	XalanUnicode::charLetter_n,
+	XalanUnicode::charLetter_d,
+	XalanUnicode::charLetter_o,
+	XalanUnicode::charLetter_m,
+	0
+};
+
+
+
+static const XalanDOMChar	s_randomSequenceFunctionName[] =
+{
+	XalanUnicode::charLetter_r,
+	XalanUnicode::charLetter_a,
+	XalanUnicode::charLetter_n,
+	XalanUnicode::charLetter_d,
+	XalanUnicode::charLetter_o,
+	XalanUnicode::charLetter_m,
+	XalanUnicode::charHyphenMinus,
+	XalanUnicode::charLetter_s,
+	XalanUnicode::charLetter_e,
+	XalanUnicode::charLetter_q,
+	XalanUnicode::charLetter_u,
+	XalanUnicode::charLetter_e,
+	XalanUnicode::charLetter_n,
+	XalanUnicode::charLetter_c,
+	XalanUnicode::charLetter_e,
+	0
+};
+
+
+
+static const XalanEXSLTFunctionRandomSequence	s_randomSequenceFunction;
+
+
+
+static const XalanEXSLTRandomFunctionsInstaller::FunctionTableEntry	theFunctionTable[] =
+{
+	{ s_randomSequenceFunctionName, &s_randomSequenceFunction},
+	{ 0, 0 }
+};
+
+
+
+void
+XalanEXSLTRandomFunctionsInstaller::installLocal(XPathEnvSupportDefault&	theSupport)
+{
+	doInstallLocal(s_randomNamespace, theFunctionTable, theSupport);
+}
+
+
+
+void
+XalanEXSLTRandomFunctionsInstaller::installGlobal(MemoryManagerType& theManager)
+{
+	doInstallGlobal(theManager, s_randomNamespace, theFunctionTable);
+
+}
+
+
+
+void
+XalanEXSLTRandomFunctionsInstaller::uninstallLocal(XPathEnvSupportDefault&	theSupport)
+{
+	doUninstallLocal(s_randomNamespace, theFunctionTable, theSupport);
+}
+
+
+
+void
+XalanEXSLTRandomFunctionsInstaller::uninstallGlobal(MemoryManagerType& theManager)
+{
+	doUninstallGlobal(theManager, s_randomNamespace, theFunctionTable);
+
+}
+
+
+
+XALAN_CPP_NAMESPACE_END
Index: xml-xalan/c/src/xalanc/XalanEXSLT/XalanEXSLTRandom.hpp
===================================================================
--- /dev/null
+++ xml-xalan/c/src/xalanc/XalanEXSLT/XalanEXSLTRandom.hpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#if !defined(EXSLT_RANDOM_HEADER_GUARD_1357924680)
+#define EXSLT_RANDOM_HEADER_GUARD_1357924680
+
+
+
+#include <xalanc/XalanEXSLT/XalanEXSLTDefinitions.hpp>
+
+
+
+#include <xalanc/XalanExtensions/XalanExtensions.hpp>
+
+
+
+XALAN_CPP_NAMESPACE_BEGIN
+
+
+
+class XALAN_EXSLT_EXPORT XalanEXSLTRandomFunctionsInstaller : public XalanExtensionsInstaller
+{
+public:
+
+	static void
+	installLocal(XPathEnvSupportDefault&	theSupport);
+
+	static void
+	installGlobal(MemoryManagerType& theManager);
+
+	static void
+	uninstallLocal(XPathEnvSupportDefault&	theSupport);
+
+	static void
+	uninstallGlobal(MemoryManagerType& theManager);
+
+private:
+
+};
+
+
+
+XALAN_CPP_NAMESPACE_END
+
+
+
+#endif	// EXSLT_RANDOM_HEADER_GUARD_1357924680
Index: xml-xalan/c/src/xalanc/XalanEXSLT/XalanEXSLTRandomImpl.hpp
===================================================================
--- /dev/null
+++ xml-xalan/c/src/xalanc/XalanEXSLT/XalanEXSLTRandomImpl.hpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#if !defined(EXSLT_RANDOMIMPL_HEADER_GUARD_1357924680)
+#define EXSLT_RANDOMIMPL_HEADER_GUARD_1357924680
+
+
+
+#include "XalanEXSLTDefinitions.hpp"
+
+
+
+#include <xalanc/PlatformSupport/XalanMessageLoader.hpp>
+
+
+
+#include <xalanc/XPath/Function.hpp>
+
+
+
+XALAN_CPP_NAMESPACE_BEGIN
+
+
+
+class XALAN_EXSLT_EXPORT XalanEXSLTFunctionRandomSequence : public Function
+{
+public:
+
+    XalanEXSLTFunctionRandomSequence()
+    {
+    }
+
+    virtual
+    ~XalanEXSLTFunctionRandomSequence()
+    {
+    }
+
+    virtual XObjectPtr
+    execute(
+            XPathExecutionContext&          executionContext,
+            XalanNode*                      context,
+            const XObjectArgVectorType&     args,
+            const LocatorType*              locator) const;
+
+#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
+    virtual Function*
+#else
+    virtual XalanEXSLTFunctionRandomSequence*
+#endif
+    clone(MemoryManagerType&    theManager) const
+    {
+        return XalanCopyConstruct(theManager, *this);
+    }
+
+protected:
+
+    virtual const XalanDOMString&
+    getError(XalanDOMString&    theResult) const
+    {
+        return XalanMessageLoader::getMessage(
+                    theResult,
+                    XalanMessages::EXSLTFunctionAccepts0Or1Or2Arguments_1Param,
+                    "random-sequence");
+    }
+
+private:
+
+    // Not implemented...
+    XalanEXSLTFunctionRandomSequence&
+    operator=(const XalanEXSLTFunctionRandomSequence&);
+
+    bool
+    operator==(const XalanEXSLTFunctionRandomSequence&) const;
+};
+
+
+
+XALAN_CPP_NAMESPACE_END
+
+
+
+#endif  // EXSLT_RANDOMIMPL_HEADER_GUARD_1357924680
Index: xml-xalan/c/src/xalanc/XalanTransformer/XalanTransformer.cpp
===================================================================
--- xml-xalan.orig/c/src/xalanc/XalanTransformer/XalanTransformer.cpp
+++ xml-xalan/c/src/xalanc/XalanTransformer/XalanTransformer.cpp
@@ -72,6 +72,7 @@
 #include <xalanc/XalanEXSLT/XalanEXSLTSet.hpp>
 #include <xalanc/XalanEXSLT/XalanEXSLTString.hpp>
 #include <xalanc/XalanEXSLT/XalanEXSLTDateTime.hpp>
+#include <xalanc/XalanEXSLT/XalanEXSLTRandom.hpp>
 
 
 
@@ -1464,6 +1465,7 @@ XalanTransformer::EnsureFunctionsInstall
     XalanEXSLTSetFunctionsInstaller::installGlobal(m_memoryManagement);
     XalanEXSLTStringFunctionsInstaller::installGlobal(m_memoryManagement);
     XalanEXSLTDateTimeFunctionsInstaller::installGlobal(m_memoryManagement);
+	XalanEXSLTRandomFunctionsInstaller::installGlobal(m_memoryManagement);
 }
 
 XalanTransformer::EnsureFunctionsInstallation::~EnsureFunctionsInstallation()
@@ -1477,6 +1479,7 @@ XalanTransformer::EnsureFunctionsInstall
         XalanEXSLTSetFunctionsInstaller::uninstallGlobal(m_memoryManagement);
         XalanEXSLTStringFunctionsInstaller::uninstallGlobal(m_memoryManagement);
         XalanEXSLTDateTimeFunctionsInstaller::uninstallGlobal(m_memoryManagement);
+		XalanEXSLTRandomFunctionsInstaller::uninstallGlobal(m_memoryManagement);
 
 #if defined(XALAN_USE_ICU)
         XPath::uninstallFunction(XPathFunctionTable::s_formatNumber);

