Open Bug 297167 Opened 20 years ago Updated 2 years ago

can't load xml file after saving by using channels

Categories

(Core :: XML, defect)

x86
Windows 2000
defect

Tracking

()

UNCONFIRMED

People

(Reporter: surkov, Unassigned)

Details

Attachments

(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; ru-RU; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 (ax)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; ru-RU; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 (ax)

I save and then load local xml file by using channels. 

var ioservice=Components.classes["@mozilla.org/network/io-service;1"].
            getService(Components.interfaces.nsIIOService);
var channel=ioservice.newChannel(url, null, null);

var uploadChannel = channel.QueryInterface(Components.interfaces.nsIUploadChannel);
var stream=Components.classes['@mozilla.org/io/string-input-stream;1'].
          createInstance(Components.interfaces.nsIStringInputStream);
 
stream.setData(data, data.length);
uploadChannel.setUploadStream(stream, "text/xml", -1);

var listener={
  onStartRequest: function(){
  },
  onStopRequest: function(){
  },
  onDataAvailable: function(){
  }
};

channel.asyncOpen(listener, null);

I try to load xml file when onStopRequest is called. Can I load just saved file
when onStopRequest is called or I need one more event? When I load xml file on
onStopRequest event then I get parser error: "no element found".

Reproducible: Always
Bugzilla isn't a forum for these type of questions, please use the newsgroups
(http://www.mozilla.org/community/developer-forums.html). Thanks.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
I'm sorry that I form my bug as a question. Issue of the bug is I can't load
local xml file directly after saving.

Just I don't know exactly what is wrong: either onStopRequest is called too
quiqly or I need new event (when onStopRequest is not intended for such things).
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Summary: is there event on complete of file uploading? → can't load xml file after saving by using channels
onStopRequest is called when the upload (and actually the download too, if any)
is finished. how are you loading the xml file?
I load file by the following way:

var ioservice=Components.classes["@mozilla.org/network/io-service;1"].
            getService(Components.interfaces.nsIIOService);
var channel=ioservice.newChannel(url, null, null);

var istream=channel.open();

var domparser=new DOMParser();
domparser.parseFromStream(istream, "utf-8", istream.available(), "text/xml");

I try to load file after onStopRequest calling.
No. If I save xml file and then load it after timeout (setTimeout() method) then
xml file is loaded successfully.
this needs a full testcase.
Attached file run it
save on root of local disc 'c:'
Attached file js
save it on root of local disc 'c:'
Attached file test xml
save it on root of local disc 'c:'
If you will run test case then you will see exception "Error: [Exception...
"Access to restricted URI denied"  code: "1012" nsresult: "0x805303f4
(NS_ERROR_DOM_BAD_URI)" after trying to serialize loaded xml document.

If you uncomment lines 24 and 28 to load document after timeout, you don't get
this exception.
(In addition to comment #11)

documentElement.tagName of loaded document is "parseerror" element.
Put
|netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");|	
before the call to onSaved. The onStopRequest callback makes us use the safe
context, so you can't access doc which comes from file://. Not sure what we can
do about that.
Attachment #186308 - Attachment mime type: application/octet-stream → application/x-javascript
Yes, when I add
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead")
before onSave() then exception is disappeared. But as before sometimes loaded
doc is valid, sometimes is not (parseerror).
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
confirm Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a1) Gecko/20050909
SeaMonkey/1.1a
Assignee: xml → nobody
QA Contact: ashshbhatt → xml
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: