B2G/gecko/content/xul/templates/tests/chrome/templates_shared.js
/*
 * copy the datasource into an in-memory datasource so that it can be modified
 */
copy the datasource into an in-memory datasource so that it can be modified
copy the datasource into an in - memory datasource so that it can be modified
function copyRDFDataSource(root, sourceds)
{
  var sourceds;
  var dsourcesArr = [];
  var composite = root.database;
  var dsources = composite.GetDataSources();
  while (dsources.hasMoreElements()) {
    sourceds = dsources.getNext().QueryInterface(Components.interfaces.nsIRDFDataSource);
    dsourcesArr.push(sourceds);
  }
  for (var d = 0; d < dsourcesArr.length; d++)
    composite.RemoveDataSource(dsourcesArr[d]);
  var newds = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
                createInstance(Components.interfaces.nsIRDFDataSource);
  var sourcelist = sourceds.GetAllResources();
  while (sourcelist.hasMoreElements()) {
    var source = sourcelist.getNext();
    var props = sourceds.ArcLabelsOut(source);
    while (props.hasMoreElements()) {
      var prop = props.getNext();
      if (prop instanceof Components.interfaces.nsIRDFResource) {
        var targets = sourceds.GetTargets(source, prop, true);
        while (targets.hasMoreElements())
          newds.Assert(source, prop, targets.getNext(), true);
      }
    }
  }
  composite.AddDataSource(newds);
  root.builder.rebuild();
  return newds;
}
function copyRDFDataSource ( root , sourceds ) { var sourceds ; var dsourcesArr = [ ] ; var composite = root . database ; var dsources = composite . GetDataSources ( ) ; while ( dsources . hasMoreElements ( ) ) { sourceds = dsources . getNext ( ) . QueryInterface ( Components . interfaces . nsIRDFDataSource ) ; dsourcesArr . push ( sourceds ) ; } for ( var d = 0 ; d < dsourcesArr . length ; d ++ ) composite . RemoveDataSource ( dsourcesArr [ d ] ) ; var newds = Components . classes [ "@mozilla.org/rdf/datasource;1?name=in-memory-datasource" ] . createInstance ( Components . interfaces . nsIRDFDataSource ) ; var sourcelist = sourceds . GetAllResources ( ) ; while ( sourcelist . hasMoreElements ( ) ) { var source = sourcelist . getNext ( ) ; var props = sourceds . ArcLabelsOut ( source ) ; while ( props . hasMoreElements ( ) ) { var prop = props . getNext ( ) ; if ( prop instanceof Components . interfaces . nsIRDFResource ) { var targets = sourceds . GetTargets ( source , prop , true ) ; while ( targets . hasMoreElements ( ) ) newds . Assert ( source , prop , targets . getNext ( ) , true ) ; } } } composite . AddDataSource ( newds ) ; root . builder . rebuild ( ) ; return newds ; }
copy the datasource into an in-memory datasource so that it can be modified
copy the datasource into an in - memory datasource so that it can be modified