Switch some internal users of text/xml to application/xml. Bug 247024, patch

by Anne van Kesteren <bug@annevankesteren.nl>, r+sr=bzbarsky
This commit is contained in:
bzbarsky%mit.edu 2005-02-27 19:34:11 +00:00
Родитель cc3c78f387
Коммит 9edf6924d0
14 изменённых файлов: 16 добавлений и 485 удалений

Просмотреть файл

@ -177,7 +177,7 @@ inSearchService.prototype =
// This method of loading the xml doesn't work, but it should. See bug 54237... // This method of loading the xml doesn't work, but it should. See bug 54237...
var doc = document.implementation.createDocument("", "", null); var doc = document.implementation.createDocument("", "", null);
doc.addEventListener("load", SearchFileLoadListener, false); doc.addEventListener("load", SearchFileLoadListener, false);
doc.load(aURL, "text/xml"); doc.load(aURL, "application/xml");
*/ */
}, },

Просмотреть файл

@ -199,7 +199,7 @@ XBLBindings.prototype =
if (aURL) { if (aURL) {
var doc = document.implementation.createDocument(null, "", null); var doc = document.implementation.createDocument(null, "", null);
doc.addEventListener("load", gDocLoadListener, true); doc.addEventListener("load", gDocLoadListener, true);
doc.load(aURL, "text/xml"); doc.load(aURL, "application/xml");
this.mBindingDoc = doc; this.mBindingDoc = doc;
this.mBindingURL = aURL; this.mBindingURL = aURL;

Просмотреть файл

@ -263,7 +263,7 @@ nsPolicyViewer.prototype =
this.mXMLHttpRequest.onload = this; this.mXMLHttpRequest.onload = this;
// Override the mime type because without it XMLHttpRequest hangs // Override the mime type because without it XMLHttpRequest hangs
// on certain sites that serve HTML instead ofXML. // on certain sites that serve HTML instead ofXML.
this.mXMLHttpRequest.overrideMimeType("text/xml"); this.mXMLHttpRequest.overrideMimeType("application/xml");
this.mXMLHttpRequest.open("GET", aLocation); this.mXMLHttpRequest.open("GET", aLocation);
this.mXMLHttpRequest.send(null); this.mXMLHttpRequest.send(null);
} }

Просмотреть файл

@ -29,7 +29,7 @@
function validateDOMNode(aNodeValue, aType, aIsValid) { function validateDOMNode(aNodeValue, aType, aIsValid) {
var rv = false; var rv = false;
var x = dp.parseFromString('<test xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema" xsi:type="' + aType + '">' + aNodeValue + '</test>', "text/xml"); var x = dp.parseFromString('<test xmlns="http://www.mozilla.org/schema/test" xmlns:xsi="http://www.w3.org/1999/XMLSchema" xsi:type="' + aType + '">' + aNodeValue + '</test>', "application/xml");
rv = getValidator().validate(x.documentElement); rv = getValidator().validate(x.documentElement);
counter++; counter++;
@ -50,7 +50,7 @@
function validateComplexType(aNodeValue, aType, aIsValid){ function validateComplexType(aNodeValue, aType, aIsValid){
var rv = false; var rv = false;
var x = dp.parseFromString(aNodeValue, "text/xml") var x = dp.parseFromString(aNodeValue, "application/xml")
rv = getValidator().validate(x.documentElement); rv = getValidator().validate(x.documentElement);
counter++; counter++;

Просмотреть файл

@ -1,79 +0,0 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TransforMiiX XSLT processor code.
*
* The Initial Developer of the Original Code is
* Axel Hecht.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var gParser = new DOMParser;
var gProc = new XSLTProcessor;
var gTimeout;
function Test(aTitle, aSourceURL, aStyleURL, aNumber, aObserver)
{
this.mTitle = aTitle;
this.mObserver = aObserver;
this.mTotal = aNumber;
this.mDone = 0;
var xmlcontent = loadFile(aSourceURL);
var xslcontent = loadFile(aStyleURL);
this.mSource = gParser.parseFromString(xmlcontent, 'text/xml');
this.mStyle = gParser.parseFromString(xslcontent, 'text/xml');
}
function runTest(aTitle, aSourceURL, aStyleURL, aNumber, aObserver)
{
test = new Test(aTitle, aSourceURL, aStyleURL, aNumber,
aObserver);
gTimeout = setTimeout(onNextTransform, 100, test, 0);
}
function onNextTransform(aTest, aNumber)
{
res = document.implementation.createDocument('', '', null);
var startTime = Date.now();
gProc.transformDocument(aTest.mSource, aTest.mStyle, res, null);
var endTime = Date.now();
aNumber++;
var progress = aNumber / aTest.mTotal * 100;
if (aTest.mObserver) {
aTest.mObserver.progress(aTest.mTitle, endTime - startTime,
progress);
}
if (aNumber < aTest.mTotal) {
gTimeout = setTimeout(onNextTransform, 100, aTest, aNumber);
} else if (aTest.mObserver) {
aTest.mObserver.done(aTest.mTitle);
}
}

Просмотреть файл

@ -1,390 +0,0 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TransforMiiX XSLT processor code.
*
* The Initial Developer of the Original Code is
* Axel Hecht.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org>
* Peter Van der Beken <peterv@propagandism.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var parser = new DOMParser();
var methodExpr = (new XPathEvaluator).createExpression("xsl:output/@method",
{
lookupNamespaceURI: function(aPrefix)
{
if (aPrefix == "xsl")
return "http://www.w3.org/1999/XSL/Transform";
return "";
}
});
const nsIWebProgListener = Components.interfaces.nsIWebProgressListener;
var runQueue =
{
mArray : new Array(),
push : function(aRunItem)
{
this.mArray.push(aRunItem);
},
observe : function(aSubject, aTopic, aData)
{
var item = this.mArray.shift();
if (item) {
item.run(this);
}
},
run : function()
{
this.observe(null,'','');
}
}
var itemCache =
{
mArray : new Array(),
getItem : function(aResource)
{
// Directory selected
if (kContUtils.IsSeq(runItem.prototype.kDatabase, aResource)) {
var aSeq = kContUtils.MakeSeq(runItem.prototype.kDatabase, aResource);
dump("sequence: "+aSeq+" with "+aSeq.GetCount()+" elements\n");
var child, children = aSeq.GetElements();
var m = 0, first;
while (children.hasMoreElements()) {
m += 1;
child = children.getNext();
child.QueryInterface(nsIRDFResource);
if (!first)
first = itemCache.getItem(child);
else
itemCache.getItem(child);
}
return first;
}
if (aResource.Value in this.mArray) {
return this.mArray[aResource.Value];
}
var retItem = new runItem(aResource);
this.mArray[aResource.Value] = retItem;
runQueue.push(retItem);
return retItem;
},
rerunItem : function(aResource, aObserver)
{
var anItem = new runItem(aResource);
this.mArray[aResource.Value] = anItem;
anItem.run(aObserver);
},
observe : function(aSubject, aTopic, aData)
{
this.mRun += 1;
if (aTopic == "success") {
if (aData == "yes") {
this.mGood += 1;
}
else {
this.mFalse +=1;
}
}
}
}
function runItem(aResource)
{
this.mResource = aResource;
// Directory selected
if (kContUtils.IsSeq(this.kDatabase,this.mResource)) {
var aSeq = kContUtils.MakeSeq(this.kDatabase,this.mResource);
dump("THIS SHOULDN'T HAPPEN\n");
var child, children = aSeq.GetElements();
var m = 0;
while (children.hasMoreElements()) {
m += 1;
child = children.getNext();
child.QueryInterface(nsIRDFResource);
itemCache.getItem(child);
}
}
}
runItem.prototype =
{
// RDF resource associated with this test
mResource : null,
// XML documents for the XSLT transformation
mSourceDoc : null,
mStyleDoc : null,
mResDoc : null,
// XML or plaintext document for the reference
mRefDoc : null,
// bitfield signaling the loaded documents
mLoaded : 0,
kSource : 1,
kStyle : 2,
kReference : 4,
// a observer, potential argument to run()
mObserver : null,
mSuccess : null,
mMethod : 'xml',
// XSLTProcessor, shared by the instances
kProcessor : new XSLTProcessor(),
kXalan : kStandardURL.createInstance(nsIURL),
kDatabase : null,
kObservers : new Array(),
run : function(aObserver)
{
if (aObserver && typeof(aObserver)=='function' ||
(typeof(aObserver)=='object' &&
typeof(aObserver.observe)=='function')) {
this.mObserver=aObserver;
}
var name = this.kDatabase.GetTarget(this.mResource, krTypeName, true);
if (name) {
var cat = this.kDatabase.GetTarget(this.mResource, krTypeCat, true);
var path = this.kDatabase.GetTarget(this.mResource, krTypePath, true);
cat = cat.QueryInterface(nsIRDFLiteral);
name = name.QueryInterface(nsIRDFLiteral);
path = path.QueryInterface(nsIRDFLiteral);
var xalan_fl = this.kXalan.resolve(cat.Value+"/"+path.Value);
var xalan_ref = this.kXalan.resolve(cat.Value+"-gold/"+path.Value);
this.mRefURL =
this.kXalan.resolve(cat.Value + "-gold/" + path.Value + ".out");
dump(name.Value+" links to "+xalan_fl+"\n");
}
// Directory selected
if (kContUtils.IsSeq(this.kDatabase,this.mResource)) {
return;
var aSeq = kContUtils.MakeSeq(this.kDatabase,this.mResource);
dump("sequence: "+aSeq+" with "+aSeq.GetCount()+" elements\n");
var child, children = aSeq.GetElements();
var m = 0;
while (children.hasMoreElements()) {
m += 1;
child = children.getNext();
child.QueryInterface(nsIRDFResource);
}
}
this.mSourceDoc = document.implementation.createDocument('', '', null);
this.mSourceDoc.addEventListener("load",this.onload(1),false);
this.mSourceDoc.load(xalan_fl+".xml");
this.mStyleDoc = document.implementation.createDocument('', '', null);
this.mStyleDoc.addEventListener("load",this.styleLoaded(),false);
this.mStyleDoc.load(xalan_fl+".xsl");
},
// nsIWebProgressListener
QueryInterface: function(aIID)
{
return this;
},
onStateChange: function(aProg, aRequest, aFlags, aStatus)
{
if ((aFlags & nsIWebProgListener.STATE_STOP) &&
(aFlags & nsIWebProgListener.STATE_IS_DOCUMENT)) {
aProg.removeProgressListener(this);
this.mRefDoc = document.getElementById('hiddenHtml').contentDocument;
this.fileLoaded(4);
}
},
onProgressChange: function(aProg, b,c,d,e,f)
{
},
onLocationChange: function(aProg, aRequest, aURI)
{
},
onStatusChange: function(aProg, aRequest, aStatus, aMessage)
{
},
onSecurityChange: function(aWebProgress, aRequest, aState)
{
},
// onload handler helper
onload : function(file)
{
var self = this;
return function(e)
{
return self.fileLoaded(file);
};
},
styleLoaded : function()
{
var self = this;
return function(e)
{
return self.styleLoadedHelper();
};
},
styleLoadedHelper : function()
{
var method = methodExpr.evaluate(this.mStyleDoc.documentElement, 2,
null).stringValue;
var refContent;
if (!method) {
// implicit method, guess from result
refContent = this.loadTextFile(this.mRefURL);
if (refContent.match(/^\s*<html/gi)) {
method = 'html';
}
else {
method = 'xml';
}
}
this.mMethod = method;
switch (method) {
case 'xml':
if (!refContent) {
refContent = this.loadTextFile(this.mRefURL);
}
this.mRefDoc = parser.parseFromString(refContent, 'text/xml');
this.mLoaded += 4;
break;
case 'html':
view.loadHtml(this.mRefURL, this);
break;
case 'text':
if (!refContent) {
refContent = this.loadTextFile(this.mRefURL);
}
const ns = 'http://www.mozilla.org/TransforMiix';
const qn = 'transformiix:result';
this.mRefDoc =
document.implementation.createDocument(ns, qn, null);
var txt = this.mRefDoc.createTextNode(refContent);
this.mRefDoc.documentElement.appendChild(txt);
this.mLoaded += 4;
break;
default:
throw "unkown XSLT output method";
}
this.fileLoaded(2)
},
fileLoaded : function(mask)
{
this.mLoaded += mask;
if (this.mLoaded < 7) {
return;
}
this.doTransform();
},
doTransform : function()
{
this.kProcessor.reset();
try {
this.kProcessor.importStylesheet(this.mStyleDoc);
this.mResDoc =
this.kProcessor.transformToDocument(this.mSourceDoc);
this.mRefDoc.normalize();
isGood = DiffDOM(this.mResDoc.documentElement,
this.mRefDoc.documentElement,
this.mMethod == 'html');
} catch (e) {
isGood = false;
};
dump("This succeeded. "+isGood+"\n");
isGood = isGood.toString();
for (var i=0; i<this.kObservers.length; i++) {
var aObs = this.kObservers[i];
if (typeof(aObs)=='object' && typeof(aObs.observe)=='function') {
aObs.observe(this.mResource, 'success', isGood);
}
else if (typeof(aObs)=='function') {
aObs(this.mResource, 'success', isGood);
}
}
if (this.mObserver) {
if (typeof(this.mObserver)=='object') {
this.mObserver.observe(this.mResource, 'success', isGood);
}
else {
this.mObserver(this.mResource, 'success', isGood);
}
}
},
loadTextFile : function(url)
{
var serv = Components.classes[IOSERVICE_CTRID].
getService(nsIIOService);
if (!serv) {
throw Components.results.ERR_FAILURE;
}
var chan = serv.newChannel(url, null, null);
var instream = doCreate(SIS_CTRID, nsISIS);
instream.init(chan.open());
return instream.read(instream.available());
}
}
runItem.prototype.kXalan.QueryInterface(nsIStandardURL);
var cmdTestController =
{
supportsCommand: function(aCommand)
{
switch(aCommand) {
case 'cmd_tst_run':
case 'cmd_tst_runall':
return true;
default:
}
return false;
},
isCommandEnabled: function(aCommand)
{
return this.supportsCommand(aCommand);
},
doCommand: function(aCommand)
{
switch(aCommand) {
case 'cmd_tst_run':
dump("cmd_tst_run\n");
break;
case 'cmd_tst_runall':
dump("cmd_tst_runall\n");
var tst_run = document.getElementById('cmd_tst_run');
tst_run.doCommand();
default:
}
}
};
registerController(cmdTestController);

Просмотреть файл

@ -824,7 +824,7 @@ function con_respondsourcetext (response, sourceText)
if ("markup" in sourceText) if ("markup" in sourceText)
{ {
response.channel.contentType = "text/xml"; response.channel.contentType = "application/xml";
response.start(); response.start();
response.append(sourceText.markup); response.append(sourceText.markup);
response.end(); response.end();
@ -833,7 +833,7 @@ function con_respondsourcetext (response, sourceText)
{ {
maxDigits = Math.floor(Math.log(sourceLines.length) / Math.LN10) + 1; maxDigits = Math.floor(Math.log(sourceLines.length) / Math.LN10) + 1;
dd ("OFF building response {"); dd ("OFF building response {");
response.channel.contentType = "text/xml"; response.channel.contentType = "application/xml";
resultSource = "<?xml version='1.0'"; resultSource = "<?xml version='1.0'";
// if ("charset" in sourceText) // if ("charset" in sourceText)
// resultSource += " encoding=\"" + sourceText.charset + "\""; // resultSource += " encoding=\"" + sourceText.charset + "\"";

Просмотреть файл

@ -689,7 +689,7 @@ nsSchemaLoader::Load(const nsAString& schemaURI,
} }
// Force the mimetype of the returned stream to be xml. // Force the mimetype of the returned stream to be xml.
rv = request->OverrideMimeType(NS_LITERAL_CSTRING("text/xml")); rv = request->OverrideMimeType(NS_LITERAL_CSTRING("application/xml"));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -746,7 +746,7 @@ nsSchemaLoader::LoadAsync(const nsAString& schemaURI,
} }
// Force the mimetype of the returned stream to be xml. // Force the mimetype of the returned stream to be xml.
rv = request->OverrideMimeType(NS_LITERAL_CSTRING("text/xml")); rv = request->OverrideMimeType(NS_LITERAL_CSTRING("application/xml"));
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }

Просмотреть файл

@ -214,7 +214,7 @@ nsWebScriptsAccess::GetDocument(const nsACString& aDeclFilePath,
PR_FALSE, empty, empty); PR_FALSE, empty, empty);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = mRequest->OverrideMimeType(NS_LITERAL_CSTRING("text/xml")); rv = mRequest->OverrideMimeType(NS_LITERAL_CSTRING("application/xml"));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = mRequest->Send(0); rv = mRequest->Send(0);

Просмотреть файл

@ -153,7 +153,7 @@ int main (int argc, char* argv[])
if (NS_SUCCEEDED( rv )) { if (NS_SUCCEEDED( rv )) {
nsString str; str.AssignWithConversion(argv[2]); nsString str; str.AssignWithConversion(argv[2]);
rv = pDOMParser->ParseFromString(str.get(), "text/xml", rv = pDOMParser->ParseFromString(str.get(), "application/xml",
getter_AddRefs( pDOMDocument ) ); getter_AddRefs( pDOMDocument ) );
if (NS_SUCCEEDED( rv )) { if (NS_SUCCEEDED( rv )) {
@ -193,7 +193,7 @@ int main (int argc, char* argv[])
rv = pDOMParser->ParseFromStream( pInputStream, rv = pDOMParser->ParseFromStream( pInputStream,
"UTF-8", "UTF-8",
uiContentLength, uiContentLength,
"text/xml", "application/xml",
getter_AddRefs( pDOMDocument ) ); getter_AddRefs( pDOMDocument ) );
if (NS_SUCCEEDED( rv )) { if (NS_SUCCEEDED( rv )) {
printf( "DOM parse of %s successful\n", argv[2] ); printf( "DOM parse of %s successful\n", argv[2] );

Просмотреть файл

@ -1,6 +1,6 @@
#!/usr/bin/perl #!/usr/bin/perl
print "Content-type: text/xml\n\n"; print "Content-type: application/xml\n\n";
print "<?xml version=\"1.0\"?>\n"; print "<?xml version=\"1.0\"?>\n";
if ($ENV{'REQUEST_METHOD'} eq 'POST') if ($ENV{'REQUEST_METHOD'} eq 'POST')

Просмотреть файл

@ -21,7 +21,7 @@ function execute()
var parser = new DOMParser(); var parser = new DOMParser();
var str = var str =
'<?xml version="1.0"?>\n<!DOCTYPE doc [\n<!ATTLIST d id ID #IMPLIED>\n]>\n<doc>\n <foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>\n <d id="id3">Three</d>\n</doc>\n'; '<?xml version="1.0"?>\n<!DOCTYPE doc [\n<!ATTLIST d id ID #IMPLIED>\n]>\n<doc>\n <foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>\n <d id="id3">Three</d>\n</doc>\n';
var doc = parser.parseFromString(str,"text/xml"); var doc = parser.parseFromString(str,"application/xml");
document.getElementById("id1").firstChild.nodeValue = str; document.getElementById("id1").firstChild.nodeValue = str;
document.getElementById("id2").firstChild.nodeValue = doc; document.getElementById("id2").firstChild.nodeValue = doc;

Просмотреть файл

@ -21,7 +21,7 @@ function execute()
var parser = new DOMParser(); var parser = new DOMParser();
var str = var str =
'<?xml version="1.0"?>\n<?xml-stylesheet href="display.css" type="text/css"?>\n<!DOCTYPE doc [\n<!ATTLIST d id ID #IMPLIED>\n]>\n<doc>\n <foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>\n <d id="id3">Three</d>\n</doc>\n'; '<?xml version="1.0"?>\n<?xml-stylesheet href="display.css" type="text/css"?>\n<!DOCTYPE doc [\n<!ATTLIST d id ID #IMPLIED>\n]>\n<doc>\n <foo xmlns="foobar">One</foo> <x:bar xmlns:x="barfoo">Two</x:bar>\n <d id="id3">Three</d>\n</doc>\n';
var doc = parser.parseFromString(str,"text/xml"); var doc = parser.parseFromString(str,"application/xml");
document.getElementById("id1").firstChild.nodeValue = str; document.getElementById("id1").firstChild.nodeValue = str;
document.getElementById("id2").firstChild.nodeValue = doc; document.getElementById("id2").firstChild.nodeValue = doc;

Просмотреть файл

@ -1569,7 +1569,7 @@ NS_IMETHODIMP mozXMLTermSession::InitStream(const nsString& streamURL,
break; break;
case XML_DOCUMENT: case XML_DOCUMENT:
contentType = "text/xml"; contentType = "application/xml";
break; break;
default: default: