home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 July & August
/
PCWorld_2005-07-08_cd.bin
/
komunikace
/
netscape
/
nsb-install-8-0.exe
/
chrome
/
toolkit.jar
/
content
/
global
/
rdfdump.js
< prev
next >
Wrap
Text File
|
2005-01-13
|
2KB
|
45 lines
function textEntered(event) {
var text = event.target.value;
debug('textEntered('+text+')');
var RDFService = Components.classes["@mozilla.org/rdf/rdf-service;1"]
.getService(Components.interfaces.nsIRDFService);
var ds = RDFService.GetDataSourceBlocking(text);
handleDataSource(ds);
//ds.QueryInterface(Components.interfaces.nsIRDFXMLSink);
//ds.addXMLSinkObserver(rdfLoadObserver);
}
function debug(msg) {
dump('rdfdump.js: '+msg+'\n');
}
var rdfLoadObserver = {
onBeginLoad : function(sink){},
onInterrupt : function(sink){},
onResume : function(sink){},
onError : function(sink,status,msg){},
onEndLoad : function(sink) {
this.debug('onEndLoad('+sink.URI+')');
// Load datasource
sink.removeXMLSinkObserver(this);
sink.QueryInterface(Components.interfaces.nsIRDFDataSource);
handleDataSource(sink);
},
debug : function(msg) {
debug('rdfLoadObserver: '+msg);
}
};
function handleDataSource(ds) {
var localFile = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("ProfD", Components.interfaces.nsILocalFile);
localFile.append('temp.rdf');
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var localFileURI = ioService.newFileURI(localFile);
ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
ds.FlushTo(localFileURI.spec);
document.getElementById('content').setAttribute('src', 'view-source:'+localFileURI.spec);
}