Re: svn commit: r149113 - /jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java /jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/suite.jelly

2005-01-31 Thread Brett Porter
Hi Paul,
This fixed the original issue. I have another issue (as I mentioned 
before), if you run maven -e xdoc on maven-1/plugins/trunk/ashkelon 
you can see it. I'll investigate when I can, but hold off on that 
release in the mean time :)

- Brett
[EMAIL PROTECTED] wrote:
Author: polx
Date: Sat Jan 29 23:47:05 2005
New Revision: 149113
URL: http://svn.apache.org/viewcvs?view=revrev=149113
Log:
x:set was returning empty-list in case of empty results whereas it used
to return a null (which becomes an empty string often in jexl or jelly).
Fixed so that when asString, single, and delim attributes are not set,
it is backwards compatible.
Reverted to the multi-slot evaluation-style as opposed to the single
policy introduced by Michael Schuerig.
paul
Modified:
  
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
  
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/suite.jelly
Modified: 
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
Url: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java?view=diffrev=149113p1=jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.javar1=149112p2=jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.javar2=149113
==
--- 
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
(original)
+++ 
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
Sat Jan 29 23:47:05 2005
@@ -30,9 +30,10 @@
import org.jaxen.JaxenException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.Collections;
+import java.util.ListIterator;
/** A tag which defines a variable from an XPath expression.
  * This function creates a variable of type [EMAIL PROTECTED] List} or [EMAIL PROTECTED] org.dom4j.Node}
@@ -66,6 +67,8 @@
private Boolean single = null;

private Boolean asString = null;
+
+private String delimiter = null;

private String delim = null;
@@ -86,7 +89,7 @@
Object xpathContext = getXPathContext();
Object value = null;
try {
-if(single!=null  single.booleanValue()==true) {
+if( single != null  single.booleanValue() == true ) {
value = select.selectSingleNode(xpathContext);
} else {
value = select.evaluate(xpathContext);
@@ -97,29 +100,74 @@
}

if (value instanceof List) {
+List list = (List) value;
// sort the list if xpCmp is set.
if (xpCmp != null  (xpCmp.getXpath() != null)) {
-Collections.sort((List)value, xpCmp);
+Collections.sort(list, xpCmp);
+}
+if(list.isEmpty()) {
+value = null;
}
}
+

-switch ( determineReturnType() ) {
-case RETURN_NODE_LIST:
-value = valueAsList(value);
-break;
-case RETURN_FIRST_NODE:
-value = valueAsSingle(value);
-break;
-case RETURN_STRING_LIST:
-value = nodeListToStringList(valueAsList(value));
-break;
-case RETURN_DELIMITED_STRING_LIST:
-value = joinDelimitedElements(nodeListToStringList(valueAsList(value)));
-break;
-case RETURN_FIRST_AS_STRING:
-value = singleValueAsString(valueAsSingle(value));
-break;
+// handle single
+if (single!=null) {
+if (single.booleanValue() == true) {
+if(value instanceof List) {
+List l = (List) value;
+if (l.size() == 0)
+value=null;
+else
+value=l.get(0);
+}
+} else { // single == false
+if(! (value instanceof List) ) {
+List l = null;
+if (value==null) {
+l = new ArrayList(0);
+} else {
+l = new ArrayList(1);
+l.add(value);
+}
+value = l;
+}
+}
+}
+
+// now convert the result(s) to string if need
+if(asString != null  asString.booleanValue()) {
+if(value instanceof Node) {
+value = ((Node) value).getStringValue();
+} else if(value instanceof List) {
+for(ListIterator it = ((List) value).listIterator(); it.hasNext(); ) {
+  

Re: svn commit: r149113 - /jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java /jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/suite.jelly

2005-01-31 Thread Paul Libbrecht
You must also have changed maven to svn... but the web-page still  
speaks about cvs! Or ?

paul
Le 31 janv. 05, à 13:22, Brett Porter a écrit :
This fixed the original issue. I have another issue (as I mentioned  
before), if you run maven -e xdoc on maven-1/plugins/trunk/ashkelon  
you can see it. I'll investigate when I can, but hold off on that  
release in the mean time :)

- Brett
[EMAIL PROTECTED] wrote:
Author: polx
Date: Sat Jan 29 23:47:05 2005
New Revision: 149113
URL: http://svn.apache.org/viewcvs?view=revrev=149113
Log:
x:set was returning empty-list in case of empty results whereas it  
used
to return a null (which becomes an empty string often in jexl or  
jelly).
Fixed so that when asString, single, and delim attributes are not set,
it is backwards compatible.
Reverted to the multi-slot evaluation-style as opposed to the single
policy introduced by Michael Schuerig.
paul

Modified:
   
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/ 
apache/commons/jelly/tags/xml/SetTag.java
   
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/test/org/ 
apache/commons/jelly/tags/xml/suite.jelly

Modified:  
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/ 
apache/commons/jelly/tags/xml/SetTag.java
Url:  
http://svn.apache.org/viewcvs/jakarta/commons/proper/jelly/trunk/ 
jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ 
SetTag.java?view=diffrev=149113p1=jakarta/commons/proper/jelly/ 
trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ 
SetTag.javar1=149112p2=jakarta/commons/proper/jelly/trunk/jelly- 
tags/xml/src/java/org/apache/commons/jelly/tags/xml/ 
SetTag.javar2=149113
== 

---  
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/ 
apache/commons/jelly/tags/xml/SetTag.java	(original)
+++  
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/ 
apache/commons/jelly/tags/xml/SetTag.java	Sat Jan 29 23:47:05 2005
@@ -30,9 +30,10 @@
import org.jaxen.JaxenException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.Collections;
+import java.util.ListIterator;
/** A tag which defines a variable from an XPath expression.
  * This function creates a variable of type [EMAIL PROTECTED] List} or [EMAIL PROTECTED]  
org.dom4j.Node}
@@ -66,6 +67,8 @@
private Boolean single = null;
private Boolean asString = null;
++private String delimiter = null;
private String delim = null;
@@ -86,7 +89,7 @@
Object xpathContext = getXPathContext();
Object value = null;
try {
-if(single!=null  single.booleanValue()==true) {
+if( single != null  single.booleanValue() == true ) {
value = select.selectSingleNode(xpathContext);
} else {
value = select.evaluate(xpathContext);
@@ -97,29 +100,74 @@
}
if (value instanceof List) {
+List list = (List) value;
// sort the list if xpCmp is set.
if (xpCmp != null  (xpCmp.getXpath() != null)) {
-Collections.sort((List)value, xpCmp);
+Collections.sort(list, xpCmp);
+}
+if(list.isEmpty()) {
+value = null;
}
}
+-switch ( determineReturnType() ) {
-case RETURN_NODE_LIST:
-value = valueAsList(value);
-break;
-case RETURN_FIRST_NODE:
-value = valueAsSingle(value);
-break;
-case RETURN_STRING_LIST:
-value = nodeListToStringList(valueAsList(value));
-break;
-case RETURN_DELIMITED_STRING_LIST:
-value =  
joinDelimitedElements(nodeListToStringList(valueAsList(value)));
-break;
-case RETURN_FIRST_AS_STRING:
-value = singleValueAsString(valueAsSingle(value));
-break;
+// handle single
+if (single!=null) {
+if (single.booleanValue() == true) {
+if(value instanceof List) {
+List l = (List) value;
+if (l.size() == 0)
+value=null;
+else
+value=l.get(0);
+}
+} else { // single == false
+if(! (value instanceof List) ) {
+List l = null;
+if (value==null) {
+l = new ArrayList(0);
+} else {
+l = new ArrayList(1);
+l.add(value);
+}
+value = l;
+}
+}
+}
++// now convert the result(s) to string if need
+if(asString != null  asString.booleanValue()) {
+if(value instanceof Node) {
+value = ((Node) 

svn commit: r149113 - /jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java /jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/suite.jelly

2005-01-29 Thread polx
Author: polx
Date: Sat Jan 29 23:47:05 2005
New Revision: 149113

URL: http://svn.apache.org/viewcvs?view=revrev=149113
Log:
x:set was returning empty-list in case of empty results whereas it used
to return a null (which becomes an empty string often in jexl or jelly).
Fixed so that when asString, single, and delim attributes are not set,
it is backwards compatible.
Reverted to the multi-slot evaluation-style as opposed to the single
policy introduced by Michael Schuerig.
paul

Modified:
   
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
   
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/suite.jelly

Modified: 
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
Url: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java?view=diffrev=149113p1=jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.javar1=149112p2=jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.javar2=149113
==
--- 
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
(original)
+++ 
jakarta/commons/proper/jelly/trunk/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
Sat Jan 29 23:47:05 2005
@@ -30,9 +30,10 @@
 import org.jaxen.JaxenException;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Collections;
+import java.util.ListIterator;
 
 /** A tag which defines a variable from an XPath expression.
   * This function creates a variable of type [EMAIL PROTECTED] List} or [EMAIL 
PROTECTED] org.dom4j.Node}
@@ -66,6 +67,8 @@
 private Boolean single = null;
 
 private Boolean asString = null;
+
+private String delimiter = null;
 
 private String delim = null;
 
@@ -86,7 +89,7 @@
 Object xpathContext = getXPathContext();
 Object value = null;
 try {
-if(single!=null  single.booleanValue()==true) {
+if( single != null  single.booleanValue() == true ) {
 value = select.selectSingleNode(xpathContext);
 } else {
 value = select.evaluate(xpathContext);
@@ -97,29 +100,74 @@
 }
 
 if (value instanceof List) {
+List list = (List) value;
 // sort the list if xpCmp is set.
 if (xpCmp != null  (xpCmp.getXpath() != null)) {
-Collections.sort((List)value, xpCmp);
+Collections.sort(list, xpCmp);
+}
+if(list.isEmpty()) {
+value = null;
 }
 }
+
 
-switch ( determineReturnType() ) {
-case RETURN_NODE_LIST:
-value = valueAsList(value);
-break;
-case RETURN_FIRST_NODE:
-value = valueAsSingle(value);
-break;
-case RETURN_STRING_LIST:
-value = nodeListToStringList(valueAsList(value));
-break;
-case RETURN_DELIMITED_STRING_LIST:
-value = 
joinDelimitedElements(nodeListToStringList(valueAsList(value)));
-break;
-case RETURN_FIRST_AS_STRING:
-value = singleValueAsString(valueAsSingle(value));
-break;
+// handle single
+if (single!=null) {
+if (single.booleanValue() == true) {
+if(value instanceof List) {
+List l = (List) value;
+if (l.size() == 0)
+value=null;
+else
+value=l.get(0);
+}
+} else { // single == false
+if(! (value instanceof List) ) {
+List l = null;
+if (value==null) {
+l = new ArrayList(0);
+} else {
+l = new ArrayList(1);
+l.add(value);
+}
+value = l;
+}
+}
+}
+
+// now convert the result(s) to string if need
+if(asString != null  asString.booleanValue()) {
+if(value instanceof Node) {
+value = ((Node) value).getStringValue();
+} else if(value instanceof List) {
+for(ListIterator it = ((List) value).listIterator(); 
it.hasNext(); ) {
+Object v = it.next();
+if(v instanceof Node) {
+v = ((Node) v).getStringValue();
+it.set(v);
+}
+}
+}
 }
+