mkwan 2002/09/19 07:54:05
Modified: java/src/org/apache/xalan/lib ExsltDynamic.java
ExsltMath.java ExsltStrings.java
Log:
Extension work. A few Javadoc correction. Fix problems in math:max and
math:min.
Revision Changes Path
1.2 +2 -0 xml-xalan/java/src/org/apache/xalan/lib/ExsltDynamic.java
Index: ExsltDynamic.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltDynamic.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExsltDynamic.java 6 Sep 2002 16:50:56 -0000 1.1
+++ ExsltDynamic.java 19 Sep 2002 14:54:04 -0000 1.2
@@ -484,7 +484,9 @@
* as the first argument, then on the node set resulting from that and so
on until no
* more nodes are found. For example:
*
+ * <pre>
* dyn:closure(., '*')
+ * </pre>
*
* returns all the descendant elements of the node (its element children,
their
* children, their children's children and so on).
1.5 +42 -43 xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java
Index: ExsltMath.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExsltMath.java 6 Sep 2002 16:37:59 -0000 1.4
+++ ExsltMath.java 19 Sep 2002 14:54:04 -0000 1.5
@@ -102,29 +102,27 @@
*
* @param nl The NodeList for the node-set to be evaluated.
*
- * @return String representation of the maximum value found, NaN if any
node cannot be
- * converted to a number.
+ * @return the maximum value found, NaN if any node cannot be converted to
a number.
*
* @see <a href="http://www.exslt.org/">EXSLT</a>
*/
- public static String max (NodeList nl)
+ public static double max (NodeList nl)
{
- Node maxNode = null;
- double m = Double.MIN_VALUE;
- for (int i = 0; i < nl.getLength(); i++)
- {
- Node n = nl.item(i);
- double d = toNumber(n);
- if (Double.isNaN(d))
- return "NaN";
- else if (d > m)
- {
- m = d;
- maxNode = n;
- }
- }
+ if (nl == null || nl.getLength() == 0)
+ return Double.NaN;
+
+ double m = Double.MIN_VALUE;
+ for (int i = 0; i < nl.getLength(); i++)
+ {
+ Node n = nl.item(i);
+ double d = toNumber(n);
+ if (Double.isNaN(d))
+ return Double.NaN;
+ else if (d > m)
+ m = d;
+ }
- return toString(maxNode);
+ return m;
}
/**
@@ -139,28 +137,27 @@
*
* @param nl The NodeList for the node-set to be evaluated.
*
- * @return String representation of the minimum value found, NaN if any
node cannot be
- * converted to a number.
+ * @return the minimum value found, NaN if any node cannot be converted to
a number.
*
* @see <a href="http://www.exslt.org/">EXSLT</a>
*/
- public static String min (NodeList nl)
+ public static double min (NodeList nl)
{
- Node minNode = null;
+ if (nl == null || nl.getLength() == 0)
+ return Double.NaN;
+
double m = Double.MAX_VALUE;
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
double d = toNumber(n);
if (Double.isNaN(d))
- return "NaN";
+ return Double.NaN;
else if (d < m)
- {
m = d;
- minNode = n;
- }
}
- return toString(minNode);
+
+ return m;
}
/**
@@ -181,19 +178,20 @@
* if any node cannot be converted to a number.
*/
public static NodeList highest (NodeList nl)
- {
- double high = new Double(max(nl)).doubleValue();
+ {
+ double maxValue = max(nl);
+
NodeSet highNodes = new NodeSet();
- highNodes.setShouldCacheNodes(true);
+ highNodes.setShouldCacheNodes(true);
- if (Double.isNaN(high))
+ if (Double.isNaN(maxValue))
return highNodes; // empty Nodeset
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
double d = toNumber(n);
- if (d == high)
+ if (d == maxValue)
highNodes.addElement(n);
}
return highNodes;
@@ -218,19 +216,19 @@
*/
public static NodeList lowest (NodeList nl)
{
- double low = new Double(min(nl)).doubleValue();
+ double minValue = min(nl);
NodeSet lowNodes = new NodeSet();
lowNodes.setShouldCacheNodes(true);
- if (Double.isNaN(low))
+ if (Double.isNaN(minValue))
return lowNodes; // empty Nodeset
for (int i = 0; i < nl.getLength(); i++)
{
Node n = nl.item(i);
double d = toNumber(n);
- if (d == low)
+ if (d == minValue)
lowNodes.addElement(n);
}
return lowNodes;
@@ -372,14 +370,15 @@
/**
* The math:constant function returns the specified constant to a set
precision.
* The possible constants are:
- *
- * PI
- * E
- * SQRRT2
- * LN2
- * LN10
- * LOG2E
- * SQRT1_2
+ * <pre>
+ * PI
+ * E
+ * SQRRT2
+ * LN2
+ * LN10
+ * LOG2E
+ * SQRT1_2
+ * </pre>
*/
public static double constant(String name, double precision)
{
1.3 +6 -1 xml-xalan/java/src/org/apache/xalan/lib/ExsltStrings.java
Index: ExsltStrings.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltStrings.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExsltStrings.java 16 Sep 2002 15:56:50 -0000 1.2
+++ ExsltStrings.java 19 Sep 2002 14:54:04 -0000 1.3
@@ -213,12 +213,14 @@
* string. The string given by the first argument is split at any
occurrence of
* this pattern. For example:
*
+ * <pre>
* str:split('a, simple, list', ', ')
* Gives the node set consisting of:
*
* <token>a</token>
* <token>simple</token>
* <token>list</token>
+ * </pre>
*
* If the second argument is omitted, the default is the string ' '
(i.e. a space).
*/
@@ -281,7 +283,8 @@
* string consisting of a number of characters. Each character in this
string is
* taken as a delimiting character. The string given by the first argument
is split
* at any occurrence of any of these characters. For example:
- *
+ *
+ * <pre>
* str:tokenize('2001-06-03T11:40:23', '-T:')
* Gives the node set consisting of:
*
@@ -291,6 +294,8 @@
* <token>11</token>
* <token>40</token>
* <token>23</token>
+ * </pre>
+
* If the second argument is omitted, the default is the string
'	

 '
* (i.e. whitespace characters).
*
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]