-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Duplicate Namespace Declarations #5972
Changes from 13 commits
64106b3
7bb806c
d400d84
6555c79
4b55019
650f40b
a4fc372
f532e72
d61c00f
9d6a2ce
ed60e00
34cef55
bd864e0
a9b0215
64404bd
a5730ef
b99f687
5f22786
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,6 +282,28 @@ define([ | |
return text; | ||
} | ||
|
||
function removeDuplicateNamespaces(text) { | ||
var index = text.indexOf('xmlns:'); | ||
var endDeclaration = text.indexOf('>', index); | ||
var namespace, startIndex, endIndex; | ||
|
||
while ((index !== -1) && (index < endDeclaration)) { | ||
namespace = text.slice(index, text.indexOf('\"', index)); | ||
startIndex = index; | ||
index = text.indexOf(namespace, index + 1); | ||
if (index !== -1) { | ||
endIndex = text.indexOf('\"', (text.indexOf('\"', index) + 1)); | ||
text = text.slice(0, index -1) + text.slice(endIndex + 1, text.length); | ||
index = text.indexOf('xmlns:', startIndex - 1); | ||
} | ||
else { | ||
index = text.indexOf('xmlns:', startIndex + 1); | ||
} | ||
} | ||
|
||
return text; | ||
} | ||
|
||
function loadXmlFromZip(reader, entry, uriResolver, deferred) { | ||
entry.getData(new zip.TextWriter(), function(text) { | ||
text = insertNamespaces(text); | ||
|
@@ -2369,6 +2391,9 @@ define([ | |
//Insert missing namespaces | ||
text = insertNamespaces(text); | ||
|
||
//Remove Duplicate Namespaces | ||
text = removeDuplicateNamespaces(text); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't get called for kmz files. Look for all the occurrences of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for finding that. I have updated the PR with a call for KMZ's as well. Please let me know if you find any other issues. Thank you. |
||
|
||
//IE raises an exception | ||
var kml; | ||
var error; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"> | ||
<Document xsi:schemaLocation="http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd http://www.google.com/kml/ext/2.2 http://code.google.com/apis/kml/schema/kml22gx.xsd"> | ||
<Placemark> | ||
<Style> | ||
<IconStyle> | ||
<Icon> | ||
<href>image.png</href> | ||
</Icon> | ||
</IconStyle> | ||
</Style> | ||
<description><![CDATA[image.png <a href="./image.png">image.png</a><img src="image.png"/>]]></description> | ||
<Point> | ||
<coordinates>1,2,3</coordinates> | ||
</Point> | ||
</Placemark> | ||
</Document> | ||
</kml> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Else should be on same line as the previous curly brace.