dbertoni 01/12/07 10:57:56
Modified: c/src/XSLT ElemNumber.cpp ElemNumber.hpp
Log:
Make sure to report an error for grouping separators that are not of length
1. Report an error if formatting a negative number as a roman numeral.
Revision Changes Path
1.50 +66 -24 xml-xalan/c/src/XSLT/ElemNumber.cpp
Index: ElemNumber.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- ElemNumber.cpp 2001/09/26 22:38:40 1.49
+++ ElemNumber.cpp 2001/12/07 18:57:56 1.50
@@ -701,8 +701,8 @@
if(0 == countMatchPattern)
executionContext.error(
"Programmer error! countMatchPattern should
never be 0!",
- 0,
- this);
+ node,
+ getLocator());
if(countMatchPattern->getMatchScore(node, *this,
executionContext) !=
XPath::eMatchScoreNone)
@@ -734,9 +734,16 @@
XalanDOMString& digitGroupSepValue =
theGuard1.get();
if (0 != m_groupingSeparator_avt)
- m_groupingSeparator_avt->evaluate(digitGroupSepValue,
contextNode,
+ m_groupingSeparator_avt->evaluate(digitGroupSepValue,
contextNode,
*this, executionContext);
+ if (length(digitGroupSepValue) != 1)
+ {
+ executionContext.error(
+ "The grouping-separator value must be one character in
length",
+ contextNode,
+ getLocator());
+ }
GetAndReleaseCachedString theGuard2(executionContext);
@@ -926,28 +933,23 @@
-bool
+void
ElemNumber::evaluateLetterValueAVT(
StylesheetExecutionContext&
executionContext,
XalanNode*
contextNode,
- const XalanDOMString& compareValue)
const
+ XalanDOMString& value)
const
{
if (m_lettervalue_avt == 0)
{
- return false;
+ clear(value);
}
else
{
- // A string to hold the result.
- StylesheetExecutionContext::GetAndReleaseCachedString
letterVal(executionContext);
-
m_lettervalue_avt->evaluate(
- letterVal.get(),
+ value,
contextNode,
*this,
executionContext);
-
- return equals(compareValue, letterVal.get());
}
}
@@ -1241,11 +1243,11 @@
break;
case XalanUnicode::charLetter_I:
- long2roman(listElement, true, theResult);
+ long2roman(executionContext, contextNode, listElement,
true, theResult);
break;
case XalanUnicode::charLetter_i:
- long2roman(listElement, true, theResult);
+ long2roman(executionContext, contextNode, listElement,
true, theResult);
theResult = toLowerCaseASCII(theResult);
break;
@@ -1262,24 +1264,40 @@
case 0x0430:
executionContext.error(
"Numbering format not supported yet",
- 0,
- this);
+ contextNode,
+ getLocator());
break;
// Handle the special case of Greek letters for now
case elalphaNumberType:
- if (evaluateLetterValueAVT(executionContext,
contextNode, Constants::ATTRVAL_TRADITIONAL) == true)
{
- NumberingResourceBundleMapType::const_iterator
i = s_resourceBundles.find(0x03B1);
+ // A string to hold the result.
+
StylesheetExecutionContext::GetAndReleaseCachedString
theGuard(executionContext);
+
+ XalanDOMString& letterVal =
theGuard.get();
- if (i != s_resourceBundles.end())
+ evaluateLetterValueAVT(executionContext,
contextNode, letterVal);
+
+ if (equals(letterVal,
Constants::ATTRVAL_TRADITIONAL) == true)
{
- traditionalAlphaCount(listElement,
(*i).second, theResult);
+
NumberingResourceBundleMapType::const_iterator i =
s_resourceBundles.find(0x03B1);
+
+ if (i != s_resourceBundles.end())
+ {
+
traditionalAlphaCount(listElement, (*i).second, theResult);
+ }
}
- }
- else
- {
- int2alphaCount(listElement,
s_elalphaCountTable, theResult);
+ else if (equals(letterVal,
Constants::ATTRVAL_ALPHABETIC) == true)
+ {
+ int2alphaCount(listElement,
s_elalphaCountTable, theResult);
+ }
+ else
+ {
+ executionContext.error(
+ "The legal values for
letter-value are 'alphabetic' and 'traditional'",
+ contextNode,
+ getLocator());
+ }
}
break;
@@ -1427,6 +1445,30 @@
{
// @@ JMD: We don't do languages yet, so this is just a placeholder
assert(false);
+}
+
+
+
+void
+ElemNumber::long2roman(
+ StylesheetExecutionContext&
executionContext,
+ XalanNode*
contextNode,
+ long
val,
+ bool
prefixesAreOK,
+ XalanDOMString&
theResult) const
+{
+ if(val < 0)
+ {
+ executionContext.error(
+ "I and i can only format positive numbers",
+ contextNode,
+ getLocator());
+
+ }
+ else
+ {
+ long2roman(val, prefixesAreOK, theResult);
+ }
}
1.32 +19 -2 xml-xalan/c/src/XSLT/ElemNumber.hpp
Index: ElemNumber.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.hpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- ElemNumber.hpp 2001/09/26 21:30:23 1.31
+++ ElemNumber.hpp 2001/12/07 18:57:56 1.32
@@ -228,6 +228,7 @@
* pattern.
* @param patterns if non-0, count only nodes
* that match this pattern, if 0 count all ancestors.
+ * @param executionContext The current execution context.
* @param node Count this node and it's ancestors.
* @param stopAtFirstFound If true, only get the first matching ancestor
* @param ancestors The ancestors that match the pattern.
@@ -333,11 +334,27 @@
private:
- bool
+ /**
+ * Convert a long integer into roman numerals.
+ * @param executionContext The current execution context.
+ * @param contextNode The current context node.
+ * @param val Value to convert.
+ * @param prefixesAreOK true to enable prefix notation (e.g. 4 = "IV"),
false to disable prefix notation (e.g. 4 = "IIII").
+ * @param theResult The formatted Roman numeral string.
+ */
+ void
+ long2roman(
+ StylesheetExecutionContext&
executionContext,
+ XalanNode*
contextNode,
+ long
val,
+ bool
prefixesAreOK,
+ XalanDOMString&
theResult) const;
+
+ void
evaluateLetterValueAVT(
StylesheetExecutionContext&
executionContext,
XalanNode*
contextNode,
- const XalanDOMString& compareValue)
const;
+ XalanDOMString& value)
const;
void
traditionalAlphaCount(
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]