You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/10/30 03:09:10 UTC
svn commit: r469052 -
/incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js
Author: mturyn
Date: Sun Oct 29 19:09:09 2006
New Revision: 469052
URL: http://svn.apache.org/viewvc?view=rev&rev=469052
Log:
Handles the return of a string or a number, instead of an array of nodes, such as one gets from XPath string and number functions.
Modified:
incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js
Modified: incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js?view=diff&rev=469052&r1=469051&r2=469052
==============================================================================
--- incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js (original)
+++ incubator/xap/trunk/src/xap/data/datasource/SimpleDocumentDataSource.js Sun Oct 29 19:09:09 2006
@@ -131,23 +131,29 @@
currentCount = currentIndex + 1;
totalCount = context.getDataSet().size() ;
// We got back an array of result nodes; get
- // their values:
- theData = new Array(rawData.length) ;
- for(var jj=0; jj <rawData.length; ++jj){
- var firstTextNode
- = xap.xml.dom.XapElement.getFirstTextChild(rawData[jj]) ;
- // If a text node, use its text value:
- if (firstTextNode != null ){
- theData[jj] = firstTextNode.nodeValue ;
- } else {
+ // their values: or,
+ // we got back a number or a string---use it:
+ if( typeof rawData == "string" || typeof rawData=="number"){
+ theData = rawData ;
+ } else {
+ theData = new Array(rawData.length) ;
+ for(var jj=0; jj <rawData.length; ++jj){
+ var firstTextNode
+ = xap.xml.dom.XapElement.getFirstTextChild(rawData[jj]) ;
+ // If a text node, use its text value:
+ if (firstTextNode != null ){
+ theData[jj] = firstTextNode.nodeValue ;
+ } else {
theData[jj] = rawData[jj].nodeValue ;
+ }
}
+ // Special, common, case---why do
+ // I suddenly wish this were C?
+ if( theData.length == 1 ){
+ theData = theData[0] ;
+ }
}
- // Special, common, case---why do
- // I suddenly wish this were C?
- if( theData.length == 1 ){
- theData = theData[0] ;
- }
+
}