[color=red]业务代码!:[/color]
XMLReader = Class.create(XML) ;
XMLReader.construct = function($self , $class){
var $point = -1 ;
var $database = null ;
var $rows = null ;
var $textDoc = null ;
this.next = function(){
if($point == this.count())
return false ;
$point ++ ;
if($point < this.count())
return true ;
else
return false ;
}
this.first = function(){
$point = 0;
}
this.last = function(){
$point = this.count() - 1 ;
}
this.previous = function(){
if($point == -1)
return false ;
$point -- ;
if($point >= 0)
return true ;
else
return false ;
}
this.getItem = function(_key){
try{
if($point == -1)
var _row = $self.super0.selectSingleNode("/table/row[1]") ;
else
var _row = $self.super0.selectSingleNode("/table/row[" + ($point + 1) + "]") ;
return _row.getAttribute(_key) ;
}catch(_err){
return "" ;
}
}
this.count = function(){
return $self.super0.getRoot().getNodes().length;
}
this.initialize = function(_rs , _type , _start , _limit){
this.registerClass("core.XMLReader") ;
try{
if(_rs.getType() == "core.XML"){
$self.super0.initialize(_rs.getXML()) ;
return ;
}
}catch(_err){
}
if(_start != null && _limit != null){
var _cnt = 0 ;
_start = _start.toInteger() ;
var _end = _start + _limit.toInteger() - 1 ;
}
$self.super0.initialize("<table/>") ;
var _root = this.getRoot() ;
while(!_rs.EOF){
if(_start != null && _end != null){
if(_cnt < _start || _cnt > _end){
_rs.MoveNext() ;
_cnt ++ ;
continue ;
}
}
var _row = this.newNode("row") ;
_row.setAttribute("index" , _cnt) ;
for(var _i = 0 ; _i < _rs.fields.Count ; _i ++){
if(_rs.fields.Item(_i).Type == 135)
if(String(_rs.fields.Item(_i).Value).trim() == null)
var _data = null ;
else
var _data = String(_rs.fields.Item(_i).Value).getDate().formatString() ;
else
var _data = String(_rs.fields.Item(_i).Value).trim() ;
if(_data != null)
if(_type != "text")
_row.setAttribute(String(_rs.fields.Item(_i).Name) , _data) ;
else
_row.newNode(String(_rs.fields.Item(_i).Name) , _data) ;
else
if(_type != "text")
_row.setAttribute(String(_rs.fields.Item(_i).Name) , "") ;
else
_row.newNode(String(_rs.fields.Item(_i).Name)) ;
}
_root.pushNode(_row) ;
_rs.MoveNext() ;
_cnt ++ ;
}
_root.setAttribute("count" , _cnt) ;
_rs.Close() ;
}
this.getXML = function(){
return $self.super0.getXML() ;
}
}
[color=red]调用代码:[/color]
var _writer = new Writer(_msg.getVariable("pnId" , true)) ;
Write.writeXML(_writer.documentView(_msg.getVariable("start" , true) , _msg.getVariable("limit" , true))) ;
改方法采用ASPSERVER框架! 这是具体分页代码部分! 经测试 ,完全没效能问题!
XMLReader = Class.create(XML) ;
XMLReader.construct = function($self , $class){
var $point = -1 ;
var $database = null ;
var $rows = null ;
var $textDoc = null ;
this.next = function(){
if($point == this.count())
return false ;
$point ++ ;
if($point < this.count())
return true ;
else
return false ;
}
this.first = function(){
$point = 0;
}
this.last = function(){
$point = this.count() - 1 ;
}
this.previous = function(){
if($point == -1)
return false ;
$point -- ;
if($point >= 0)
return true ;
else
return false ;
}
this.getItem = function(_key){
try{
if($point == -1)
var _row = $self.super0.selectSingleNode("/table/row[1]") ;
else
var _row = $self.super0.selectSingleNode("/table/row[" + ($point + 1) + "]") ;
return _row.getAttribute(_key) ;
}catch(_err){
return "" ;
}
}
this.count = function(){
return $self.super0.getRoot().getNodes().length;
}
this.initialize = function(_rs , _type , _start , _limit){
this.registerClass("core.XMLReader") ;
try{
if(_rs.getType() == "core.XML"){
$self.super0.initialize(_rs.getXML()) ;
return ;
}
}catch(_err){
}
if(_start != null && _limit != null){
var _cnt = 0 ;
_start = _start.toInteger() ;
var _end = _start + _limit.toInteger() - 1 ;
}
$self.super0.initialize("<table/>") ;
var _root = this.getRoot() ;
while(!_rs.EOF){
if(_start != null && _end != null){
if(_cnt < _start || _cnt > _end){
_rs.MoveNext() ;
_cnt ++ ;
continue ;
}
}
var _row = this.newNode("row") ;
_row.setAttribute("index" , _cnt) ;
for(var _i = 0 ; _i < _rs.fields.Count ; _i ++){
if(_rs.fields.Item(_i).Type == 135)
if(String(_rs.fields.Item(_i).Value).trim() == null)
var _data = null ;
else
var _data = String(_rs.fields.Item(_i).Value).getDate().formatString() ;
else
var _data = String(_rs.fields.Item(_i).Value).trim() ;
if(_data != null)
if(_type != "text")
_row.setAttribute(String(_rs.fields.Item(_i).Name) , _data) ;
else
_row.newNode(String(_rs.fields.Item(_i).Name) , _data) ;
else
if(_type != "text")
_row.setAttribute(String(_rs.fields.Item(_i).Name) , "") ;
else
_row.newNode(String(_rs.fields.Item(_i).Name)) ;
}
_root.pushNode(_row) ;
_rs.MoveNext() ;
_cnt ++ ;
}
_root.setAttribute("count" , _cnt) ;
_rs.Close() ;
}
this.getXML = function(){
return $self.super0.getXML() ;
}
}
[color=red]调用代码:[/color]
var _writer = new Writer(_msg.getVariable("pnId" , true)) ;
Write.writeXML(_writer.documentView(_msg.getVariable("start" , true) , _msg.getVariable("limit" , true))) ;
改方法采用ASPSERVER框架! 这是具体分页代码部分! 经测试 ,完全没效能问题!