You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/07/10 03:06:55 UTC
cvs commit: xml-xalan/c/src/XSLT NodeSorter.cpp NodeSorter.hpp StylesheetExecutionContext.hpp StylesheetExecutionContextDefault.cpp StylesheetExecutionContextDefault.hpp
dbertoni 00/07/09 18:06:55
Modified: c/src/XSLT NodeSorter.cpp NodeSorter.hpp
StylesheetExecutionContext.hpp
StylesheetExecutionContextDefault.cpp
StylesheetExecutionContextDefault.hpp
Log:
New ICU collation integration.
Revision Changes Path
1.11 +6 -2 xml-xalan/c/src/XSLT/NodeSorter.cpp
Index: NodeSorter.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/NodeSorter.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- NodeSorter.cpp 2000/07/07 22:53:48 1.10
+++ NodeSorter.cpp 2000/07/10 01:06:54 1.11
@@ -77,7 +77,11 @@
-NodeSorter::NodeSorter(XPathExecutionContext& executionContext) :
+#include "StylesheetExecutionContext.hpp"
+
+
+
+NodeSorter::NodeSorter(StylesheetExecutionContext& executionContext) :
m_executionContext(executionContext),
m_keys()
{
@@ -207,7 +211,7 @@
// Compare as strings
else
{
- const int theCompareResult = collationCompare(
+ const int theCompareResult = m_executionContext.collationCompare(
getStringResult(theKey, theLHS),
getStringResult(theKey, theRHS));
1.7 +7 -7 xml-xalan/c/src/XSLT/NodeSorter.hpp
Index: NodeSorter.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/NodeSorter.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NodeSorter.hpp 2000/07/07 22:53:48 1.6
+++ NodeSorter.hpp 2000/07/10 01:06:54 1.7
@@ -79,10 +79,10 @@
-class XalanNode;
class MutableNodeRefList;
+class StylesheetExecutionContext;
+class XalanNode;
class XPath;
-class XPathExecutionContext;
@@ -108,7 +108,7 @@
*
* @param executionContext current execution context
*/
- NodeSorter(XPathExecutionContext& executionContext);
+ NodeSorter(StylesheetExecutionContext& executionContext);
~NodeSorter();
@@ -148,7 +148,7 @@
* @param theNodeSortKeys vector of keys upon which to sort
*/
NodeSortKeyCompare(
- XPathExecutionContext& executionContext,
+ StylesheetExecutionContext& executionContext,
const MutableNodeRefList& theList,
const NodeVectorType& theNodes,
const NodeSortKeyVectorType& theNodeSortKeys) :
@@ -192,7 +192,7 @@
private:
- XPathExecutionContext& m_executionContext;
+ StylesheetExecutionContext& m_executionContext;
const MutableNodeRefList& m_list;
const NodeVectorType& m_nodes;
const NodeSortKeyVectorType& m_nodeSortKeys;
@@ -231,9 +231,9 @@
NodeVectorType& v,
const NodeSortKeyVectorType& keys);
- XPathExecutionContext& m_executionContext;
+ StylesheetExecutionContext& m_executionContext;
- NodeSortKeyVectorType m_keys; // vector of NodeSortKeys
+ NodeSortKeyVectorType m_keys;
/**
* @@ TODO: Adjust this for locale.
1.21 +26 -0 xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp
Index: StylesheetExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- StylesheetExecutionContext.hpp 2000/07/06 20:19:25 1.20
+++ StylesheetExecutionContext.hpp 2000/07/10 01:06:54 1.21
@@ -1353,6 +1353,32 @@
const XalanElement& theTemplate,
const NodeRefListBase& nl) const = 0;
+ /**
+ * Compare two strings using the collation of the
+ * current locale.
+ *
+ * @param theLHS a string to compare
+ * @param theRHS a string to compare
+ * @return < 0 if theLHS is before theRHS, 0 if they are equal, or > 0 if theLHS is after theRHS
+ */
+ virtual int
+ collationCompare(
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS) const = 0;
+
+ /**
+ * Compare two strings using the collation of the
+ * current locale.
+ *
+ * @param theLHS a string to compare
+ * @param theRHS a string to compare
+ * @return < 0 if theLHS is before theRHS, 0 if they are equal, or > 0 if theLHS is after theRHS
+ */
+ virtual int
+ collationCompare(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS) const = 0;
+
// These interfaces are inherited from XPathExecutionContext...
1.20 +78 -3 xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
Index: StylesheetExecutionContextDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- StylesheetExecutionContextDefault.cpp 2000/07/06 20:19:25 1.19
+++ StylesheetExecutionContextDefault.cpp 2000/07/10 01:06:54 1.20
@@ -66,6 +66,7 @@
+#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/STLHelper.hpp>
#include <PlatformSupport/TextOutputStream.hpp>
#include <PlatformSupport/XalanNumberFormat.hpp>
@@ -101,13 +102,15 @@
-StylesheetExecutionContextDefault::XalanNumberFormatFactory StylesheetExecutionContextDefault::s_defaultXalanNumberFormatFactory;
+StylesheetExecutionContextDefault::XalanNumberFormatFactory StylesheetExecutionContextDefault::s_defaultXalanNumberFormatFactory;
-StylesheetExecutionContextDefault::XalanNumberFormatFactory* StylesheetExecutionContextDefault::s_xalanNumberFormatFactory =
+StylesheetExecutionContextDefault::XalanNumberFormatFactory* StylesheetExecutionContextDefault::s_xalanNumberFormatFactory =
&StylesheetExecutionContextDefault::getDefaultXalanNumberFormatFactory();
+const StylesheetExecutionContextDefault::DefaultCollationCompareFunctor StylesheetExecutionContextDefault::s_defaultFunctor;
+
StylesheetExecutionContextDefault::StylesheetExecutionContextDefault(
XSLTEngineImpl& xsltProcessor,
XPathEnvSupport& theXPathEnvSupport,
@@ -129,7 +132,8 @@
m_stylesheetRoot(0),
m_formatterListeners(),
m_printWriters(),
- m_textOutputStreams()
+ m_textOutputStreams(),
+ m_collationCompareFunctor(&s_defaultFunctor)
{
}
@@ -973,6 +977,77 @@
return theOldFactory;
}
+
+
+int
+StylesheetExecutionContextDefault::collationCompare(
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS) const
+{
+ assert(m_collationCompareFunctor != 0);
+
+ return (*m_collationCompareFunctor)(c_wstr(theLHS), c_wstr(theRHS));
+}
+
+
+
+int
+StylesheetExecutionContextDefault::collationCompare(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS) const
+{
+ assert(m_collationCompareFunctor != 0);
+
+ return (*m_collationCompareFunctor)(theLHS, theRHS);
+}
+
+
+
+StylesheetExecutionContextDefault::CollationCompareFunctor::CollationCompareFunctor()
+{
+}
+
+
+
+StylesheetExecutionContextDefault::CollationCompareFunctor::~CollationCompareFunctor()
+{
+}
+
+
+
+StylesheetExecutionContextDefault::DefaultCollationCompareFunctor::DefaultCollationCompareFunctor()
+{
+}
+
+
+
+StylesheetExecutionContextDefault::DefaultCollationCompareFunctor::~DefaultCollationCompareFunctor()
+{
+}
+
+
+
+int
+StylesheetExecutionContextDefault::DefaultCollationCompareFunctor::operator()(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS) const
+{
+ return ::collationCompare(theLHS, theRHS);
+}
+
+
+
+const StylesheetExecutionContextDefault::CollationCompareFunctor*
+StylesheetExecutionContextDefault::installCollationCompareFunctor(const CollationCompareFunctor* theFunctor)
+{
+ assert(theFunctor != 0);
+
+ const CollationCompareFunctor* const temp = m_collationCompareFunctor;
+
+ m_collationCompareFunctor = theFunctor;
+
+ return temp;
+}
1.18 +46 -0 xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
Index: StylesheetExecutionContextDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- StylesheetExecutionContextDefault.hpp 2000/07/06 20:19:25 1.17
+++ StylesheetExecutionContextDefault.hpp 2000/07/10 01:06:54 1.18
@@ -442,7 +442,49 @@
const XalanElement& theTemplate,
const NodeRefListBase& nl) const;
+ virtual int
+ collationCompare(
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS) const;
+
+ virtual int
+ collationCompare(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS) const;
+
+ class XALAN_XSLT_EXPORT CollationCompareFunctor
+ {
+ public:
+
+ CollationCompareFunctor();
+
+ virtual
+ ~CollationCompareFunctor();
+
+ virtual int
+ operator()(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS) const = 0;
+ };
+
+ class XALAN_XSLT_EXPORT DefaultCollationCompareFunctor : public CollationCompareFunctor
+ {
+ public:
+
+ DefaultCollationCompareFunctor();
+
+ virtual
+ ~DefaultCollationCompareFunctor();
+
+ virtual int
+ operator()(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS) const;
+ };
+ const CollationCompareFunctor*
+ installCollationCompareFunctor(const CollationCompareFunctor* theFunctor);
+
// These interfaces are inherited from XPathExecutionContext...
virtual XalanNode*
@@ -660,9 +702,13 @@
TextOutputStreamSetType m_textOutputStreams;
+ const CollationCompareFunctor* m_collationCompareFunctor;
+
static XalanNumberFormatFactory s_defaultXalanNumberFormatFactory;
static XalanNumberFormatFactory* s_xalanNumberFormatFactory;
+
+ const static DefaultCollationCompareFunctor s_defaultFunctor;
};