dbertoni 02/05/29 11:21:52
Modified: c/src/XSLT ElemForEach.cpp ElemSort.cpp ElemSort.hpp
NodeSortKey.cpp NodeSortKey.hpp NodeSorter.cpp
StylesheetExecutionContext.hpp
StylesheetExecutionContextDefault.cpp
StylesheetExecutionContextDefault.hpp
Log:
Implemented "case-order" attribute of xsl:sort.
Revision Changes Path
1.24 +37 -6 xml-xalan/c/src/XSLT/ElemForEach.cpp
Index: ElemForEach.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemForEach.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ElemForEach.cpp 8 May 2002 21:02:14 -0000 1.23
+++ ElemForEach.cpp 29 May 2002 18:21:52 -0000 1.24
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -318,15 +318,46 @@
clear(scratchString);
+ avt = sort->getCaseOrderAVT();
+
+ if(0 != avt)
+ {
+ avt->evaluate(scratchString, sourceNodeContext,
*this, executionContext);
+ }
+
+ NodeSortKey::eCaseOrder caseOrder =
NodeSortKey::eDefault;
+
+ if (isEmpty(scratchString) == false)
+ {
+ if (equals(scratchString,
Constants::ATTRVAL_CASEORDER_UPPER) == true)
+ {
+ caseOrder = NodeSortKey::eUpperFirst;
+ }
+ else if (equals(scratchString,
Constants::ATTRVAL_CASEORDER_LOWER) == true)
+ {
+ caseOrder = NodeSortKey::eLowerFirst;
+ }
+ else
+ {
+ executionContext.error(
+ "xsl:sort case-order must be
'upper-first' or 'lower-first'",
+ sourceNodeContext,
+ sort->getLocator());
+ }
+ }
+
+ clear(scratchString);
+
assert(sort->getSelectPattern() != 0);
keys.push_back(
NodeSortKey(
- executionContext,
- *sort->getSelectPattern(),
- treatAsNumbers,
- descending,
- langString,
+ executionContext,
+ *sort->getSelectPattern(),
+ treatAsNumbers,
+ descending,
+ caseOrder,
+ langString,
*this));
}
1.13 +0 -2 xml-xalan/c/src/XSLT/ElemSort.cpp
Index: ElemSort.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemSort.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ElemSort.cpp 23 Feb 2002 04:23:16 -0000 1.12
+++ ElemSort.cpp 29 May 2002 18:21:52 -0000 1.13
@@ -116,8 +116,6 @@
}
else if(equals(aname, Constants::ATTRNAME_CASEORDER))
{
- constructionContext.warn("Xalan C++ does not yet handle
the 'case-order' attribute!");
-
m_caseOrderAVT = new AVT(getLocator(), aname,
atts.getType(i), atts.getValue(i),
*this, constructionContext);
}
1.8 +11 -0 xml-xalan/c/src/XSLT/ElemSort.hpp
Index: ElemSort.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemSort.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ElemSort.hpp 27 Feb 2001 22:00:07 -0000 1.7
+++ ElemSort.hpp 29 May 2002 18:21:52 -0000 1.8
@@ -124,6 +124,17 @@
}
/**
+ * Retrieve the case-order attribute value template(AVT)
+ *
+ * @return the case-order AVT
+ */
+ const AVT*
+ getCaseOrderAVT() const
+ {
+ return m_caseOrderAVT;
+ }
+
+ /**
* Retrieve the data type attribute value template(AVT)
*
* @return the data type AVT
1.7 +6 -6 xml-xalan/c/src/XSLT/NodeSortKey.cpp
Index: NodeSortKey.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/NodeSortKey.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NodeSortKey.cpp 29 Mar 2001 22:22:38 -0000 1.6
+++ NodeSortKey.cpp 29 May 2002 18:21:52 -0000 1.7
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -75,12 +75,14 @@
const XPath& selectPat,
bool treatAsNumbers,
bool descending,
+ eCaseOrder caseOrder,
const XalanDOMString& langValue,
const PrefixResolver& resolver) :
m_executionContext(&executionContext),
m_selectPat(&selectPat),
m_treatAsNumbers(treatAsNumbers),
m_descending(descending),
+ m_caseOrder(caseOrder),
m_prefixResolver(&resolver),
m_languageString(&langValue)
{
@@ -93,6 +95,7 @@
m_selectPat(0),
m_treatAsNumbers(false),
m_descending(false),
+ m_caseOrder(eDefault),
m_prefixResolver(0),
m_languageString(&s_emptyString)
{
@@ -105,6 +108,7 @@
m_selectPat(theSource.m_selectPat),
m_treatAsNumbers(theSource.m_treatAsNumbers),
m_descending(theSource.m_descending),
+ m_caseOrder(theSource.m_caseOrder),
m_prefixResolver(theSource.m_prefixResolver),
m_languageString(theSource.m_languageString)
{
@@ -127,6 +131,7 @@
m_selectPat = theRHS.m_selectPat;
m_treatAsNumbers = theRHS.m_treatAsNumbers;
m_descending = theRHS.m_descending;
+ m_caseOrder = theRHS.m_caseOrder;
m_prefixResolver = theRHS.m_prefixResolver;
m_languageString = theRHS.m_languageString;
@@ -135,8 +140,3 @@
return *this;
}
-
-
-/*
- * $ Log: $
- */
1.10 +19 -2 xml-xalan/c/src/XSLT/NodeSortKey.hpp
Index: NodeSortKey.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/NodeSortKey.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- NodeSortKey.hpp 29 Mar 2001 22:22:38 -0000 1.9
+++ NodeSortKey.hpp 29 May 2002 18:21:52 -0000 1.10
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -92,6 +92,8 @@
{
public:
+ enum eCaseOrder { eDefault, eLowerFirst, eUpperFirst };
+
/**
* Construct a node sort key.
*
@@ -99,6 +101,7 @@
* @param selectPat XPath for selection
* @param treatAsNumbers treat as numeric values if true
* @param descending sort in descending order if true
+ * @param caseOrder case sort order enum
* @param langValue language
* @param resolver resolver for namespace resolution
*/
@@ -107,6 +110,7 @@
const XPath& selectPat,
bool treatAsNumbers,
bool descending,
+ eCaseOrder caseOrder,
const XalanDOMString& langValue,
const PrefixResolver& resolver);
@@ -153,6 +157,17 @@
}
/**
+ * Get the enumeration value for the case order.
+ *
+ * @return sort upper case before lower case if true
+ */
+ eCaseOrder
+ getCaseOrder() const
+ {
+ return m_caseOrder;
+ }
+
+ /**
* Retrieve the resolver for namespaces.
*
* @return object for namespace resolution
@@ -176,7 +191,9 @@
const XPath* m_selectPat;
bool m_treatAsNumbers;
- bool m_descending;
+ bool m_descending;
+
+ eCaseOrder m_caseOrder;
const PrefixResolver* m_prefixResolver;
1.24 +50 -14 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.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- NodeSorter.cpp 26 Sep 2001 21:30:23 -0000 1.23
+++ NodeSorter.cpp 29 May 2002 18:21:52 -0000 1.24
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -168,25 +168,54 @@
+inline StylesheetExecutionContext::eCaseOrder
+caseOrderConvert(NodeSortKey::eCaseOrder theCaseOrder)
+{
+ switch(theCaseOrder)
+ {
+ case NodeSortKey::eLowerFirst:
+ return StylesheetExecutionContext::eLowerFirst;
+ break;
+
+ case NodeSortKey::eUpperFirst:
+ return StylesheetExecutionContext::eUpperFirst;
+ break;
+
+ case NodeSortKey::eDefault:
+ break;
+
+ default:
+ assert(false);
+ break;
+ }
+
+ return StylesheetExecutionContext::eDefault;
+}
+
+
+
static inline int
doCollationCompare(
StylesheetExecutionContext&
executionContext,
const XalanDOMString& theLHS,
const XalanDOMString& theRHS,
- const XalanDOMString& theLanguage)
+ const XalanDOMString& theLanguage,
+ NodeSortKey::eCaseOrder theCaseOrder)
{
if (length(theLanguage) == 0)
{
return executionContext.collationCompare(
theLHS,
- theRHS);
+ theRHS,
+ caseOrderConvert(theCaseOrder));
}
else
{
return executionContext.collationCompare(
theLHS,
theRHS,
- theLanguage);
+ theLanguage,
+ caseOrderConvert(theCaseOrder));
}
}
@@ -206,7 +235,23 @@
const NodeSortKey& theKey = m_nodeSortKeys[theKeyIndex];
// Compare as numbers
- if(theKey.getTreatAsNumbers() == true)
+ if(theKey.getTreatAsNumbers() == false)
+ {
+ // Compare as strings
+ const XalanDOMString& theLHSString =
+ getStringResult(theKey, theKeyIndex, theLHS)->str();
+
+ const XalanDOMString& theRHSString =
+ getStringResult(theKey, theKeyIndex, theRHS)->str();
+
+ theResult = doCollationCompare(
+ m_executionContext,
+ theLHSString,
+ theRHSString,
+ theKey.getLanguageString(),
+ theKey.getCaseOrder());
+ }
+ else
{
double n1Num = getNumberResult(theKey, theKeyIndex, theLHS);
double n2Num = getNumberResult(theKey, theKeyIndex, theRHS);
@@ -231,15 +276,6 @@
{
theResult = 1;
}
- }
- // Compare as strings
- else
- {
- theResult = doCollationCompare(
- m_executionContext,
- getStringResult(theKey, theKeyIndex,
theLHS)->str(),
- getStringResult(theKey, theKeyIndex,
theRHS)->str(),
- theKey.getLanguageString());
}
// If they're not equal, the flip things if the
1.73 +15 -5 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.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- StylesheetExecutionContext.hpp 16 Apr 2002 05:45:50 -0000 1.72
+++ StylesheetExecutionContext.hpp 29 May 2002 18:21:52 -0000 1.73
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1443,18 +1443,22 @@
const XalanElement& theTemplate,
const NodeRefListBase& nl) const = 0;
+ enum eCaseOrder { eDefault, eLowerFirst, eUpperFirst };
+
/**
* Compare two strings using the collation of the
* current locale.
*
* @param theLHS a string to compare
* @param theRHS a string to compare
+ * @param theCaseOrder the case order for the comparison
* @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) = 0;
+ const XalanDOMString& theRHS,
+ eCaseOrder theCaseOrder =
eDefault) = 0;
/**
* Compare two strings using the collation of the
@@ -1463,13 +1467,15 @@
* @param theLHS a string to compare
* @param theRHS a string to compare
* @param theLocal a string that specifies the locale
+ * @param theCaseOrder the case order for the comparison
* @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 XalanDOMString& theLocale) = 0;
+ const XalanDOMString& theLocale,
+ eCaseOrder theCaseOrder =
eDefault) = 0;
/**
* Compare two strings using the collation of the
@@ -1477,12 +1483,14 @@
*
* @param theLHS a string to compare
* @param theRHS a string to compare
+ * @param theCaseOrder the case order for the comparison
* @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) = 0;
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder =
eDefault) = 0;
/**
* Compare two strings using the collation of the
@@ -1491,13 +1499,15 @@
* @param theLHS a string to compare
* @param theRHS a string to compare
* @param theLocal a string that specifies the locale
+ * @param theCaseOrder the case order for the comparison
* @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 XalanDOMChar* theLocale) = 0;
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder =
eDefault) = 0;
/**
* Determine if a KeyDeclaration is being constructed.
1.91 +22 -16
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.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- StylesheetExecutionContextDefault.cpp 8 May 2002 01:39:57 -0000
1.90
+++ StylesheetExecutionContextDefault.cpp 29 May 2002 18:21:52 -0000
1.91
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1391,15 +1391,16 @@
int
StylesheetExecutionContextDefault::collationCompare(
const XalanDOMString& theLHS,
- const XalanDOMString& theRHS)
+ const XalanDOMString& theRHS,
+ eCaseOrder theCaseOrder)
{
if (m_collationCompareFunctor == 0)
{
- return s_defaultCollationFunctor(c_wstr(theLHS),
c_wstr(theRHS));
+ return s_defaultCollationFunctor(c_wstr(theLHS),
c_wstr(theRHS), theCaseOrder);
}
else
{
- return (*m_collationCompareFunctor)(c_wstr(theLHS),
c_wstr(theRHS));
+ return (*m_collationCompareFunctor)(c_wstr(theLHS),
c_wstr(theRHS), theCaseOrder);
}
}
@@ -1409,15 +1410,16 @@
StylesheetExecutionContextDefault::collationCompare(
const XalanDOMString& theLHS,
const XalanDOMString& theRHS,
- const XalanDOMString& theLocale)
+ const XalanDOMString& theLocale,
+ eCaseOrder theCaseOrder)
{
if (m_collationCompareFunctor == 0)
{
- return s_defaultCollationFunctor(c_wstr(theLHS),
c_wstr(theRHS), c_wstr(theLocale));
+ return s_defaultCollationFunctor(c_wstr(theLHS),
c_wstr(theRHS), c_wstr(theLocale), theCaseOrder);
}
else
{
- return (*m_collationCompareFunctor)(c_wstr(theLHS),
c_wstr(theRHS), c_wstr(theLocale));
+ return (*m_collationCompareFunctor)(c_wstr(theLHS),
c_wstr(theRHS), c_wstr(theLocale), theCaseOrder);
}
}
@@ -1426,17 +1428,18 @@
int
StylesheetExecutionContextDefault::collationCompare(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS)
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder)
{
assert(theLHS != 0 && theRHS != 0);
if (m_collationCompareFunctor == 0)
{
- return s_defaultCollationFunctor(theLHS, theRHS);
+ return s_defaultCollationFunctor(theLHS, theRHS, theCaseOrder);
}
else
{
- return (*m_collationCompareFunctor)(theLHS, theRHS);
+ return (*m_collationCompareFunctor)(theLHS, theRHS,
theCaseOrder);
}
}
@@ -1446,17 +1449,18 @@
StylesheetExecutionContextDefault::collationCompare(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* theLocale)
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder)
{
assert(theLHS != 0 && theRHS != 0);
if (m_collationCompareFunctor == 0)
{
- return s_defaultCollationFunctor(theLHS, theRHS, theLocale);
+ return s_defaultCollationFunctor(theLHS, theRHS, theLocale,
theCaseOrder);
}
else
{
- return (*m_collationCompareFunctor)(theLHS, theRHS, theLocale);
+ return (*m_collationCompareFunctor)(theLHS, theRHS, theLocale,
theCaseOrder);
}
}
@@ -1489,7 +1493,8 @@
int
StylesheetExecutionContextDefault::DefaultCollationCompareFunctor::operator()(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const
+ const XalanDOMChar* theRHS,
+ eCaseOrder /* theCaseOrder
*/) const
{
return ::collationCompare(theLHS, theRHS);
}
@@ -1500,9 +1505,10 @@
StylesheetExecutionContextDefault::DefaultCollationCompareFunctor::operator()(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* /* theLocale */) const
+ const XalanDOMChar* /* theLocale */,
+ eCaseOrder theCaseOrder)
const
{
- return (*this)(theLHS, theRHS);
+ return (*this)(theLHS, theRHS, theCaseOrder);
}
1.78 +17 -9
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.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- StylesheetExecutionContextDefault.hpp 18 Apr 2002 04:52:57 -0000
1.77
+++ StylesheetExecutionContextDefault.hpp 29 May 2002 18:21:52 -0000
1.78
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -658,24 +658,28 @@
virtual int
collationCompare(
const XalanDOMString& theLHS,
- const XalanDOMString& theRHS);
+ const XalanDOMString& theRHS,
+ eCaseOrder theCaseOrder =
eDefault);
virtual int
collationCompare(
const XalanDOMString& theLHS,
const XalanDOMString& theRHS,
- const XalanDOMString& theLocale);
+ const XalanDOMString& theLocale,
+ eCaseOrder theCaseOrder =
eDefault);
virtual int
collationCompare(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS);
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder =
eDefault);
virtual int
collationCompare(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* theLocale);
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder =
eDefault);
class XALAN_XSLT_EXPORT CollationCompareFunctor
{
@@ -691,7 +695,8 @@
virtual int
operator()(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const = 0;
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder =
eDefault) const = 0;
// Const version is suitable for use by
// multiple threads.
@@ -699,7 +704,8 @@
operator()(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* theLocale) const = 0;
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder =
eDefault) const = 0;
};
class XALAN_XSLT_EXPORT DefaultCollationCompareFunctor : public
CollationCompareFunctor
@@ -714,13 +720,15 @@
virtual int
operator()(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const;
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder =
eDefault) const;
virtual int
operator()(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* theLocale) const;
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder =
eDefault) const;
};
const CollationCompareFunctor*
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]