-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[SR-2301] NSXMLParser not fully implemented #4342
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
Comments
I see same issue on drmohundro/SWXMLHash#97 using swift-3.0-PREVIEW-6 on ubuntu. |
Comment by Brian (JIRA) I put a PR up with some more tests and a fix. |
Comment by Maksim Rogov (JIRA) I believe this has been merged in and can be closed? |
lupinglade (JIRA User) No, it's still not working properly on linux |
Comment by Maksim Rogov (JIRA) @egorzhdan Really? We've tested it here and it seemed to be fine besides some inconsistency issues with the delegate method signatures. |
lupinglade (JIRA User) I noticed that the bug (partially) still exists using the current master.
I noticed that the tests in TestXMLParser.swift know about the |
I opened a pull request to add the |
When investigating SR-13546, I noticed that the entity declaration callbacks of XMLParserDelegate are never called, so this issue is still unresolved: func parser(_ parser: XMLParser,
foundExternalEntityDeclarationWithName name: String,
publicID: String?,
systemID: String?)
func parser(_ parser: XMLParser,
foundInternalEntityDeclarationWithName name: String,
value: String?)
func parser(_ parser: XMLParser,
foundUnparsedEntityDeclarationWithName name: String,
publicID: String?,
systemID: String?,
notationName: String?) Test case: import Foundation
import FoundationXML
class MyDelegate : NSObject, XMLParserDelegate {
func parser(_ parser: XMLParser, foundExternalEntityDeclarationWithName name: String, publicID: String?, systemID: String?) {
print("foundExternalEntityDeclarationWithName: \(name)")
}
func parser(_ parser: XMLParser, foundInternalEntityDeclarationWithName name: String, value: String?) {
print("foundInternalEntityDeclarationWithName: \(name)")
}
func parser(_ parser: XMLParser, foundUnparsedEntityDeclarationWithName name: String, publicID: String?, systemID: String?, notationName: String?) {
print("foundUnparsedEntityDeclarationWithName: \(name)")
}
}
let xml = """
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE root [
<!NOTATION notation PUBLIC "empty file">
<!ENTITY unparsedEntity SYSTEM "file:///dev/null" NDATA notation>
<!ENTITY externalEntity SYSTEM "file:///dev/null" >
<!ENTITY internalEntity "Internal" >
<!ELEMENT root (foo*) >
<!ELEMENT foo ANY >
<!ATTLIST foo bar ENTITY #REQUIRED>
]>
<root>
<foo>internal entity: &internalEntity;</foo>
<foo>external entity: &externalEntity;</foo>
<foo bar="unparsedEntity" />
</root>
"""
let parser = XMLParser(data: xml.data(using: .utf8)!)
parser.shouldProcessNamespaces = true
parser.shouldReportNamespacePrefixes = true
parser.shouldResolveExternalEntities = true
parser.externalEntityResolvingPolicy = .always
let delegate = MyDelegate()
parser.delegate = delegate
let res = parser.parse() Expected output:
(Working on it) |
Mostly (if not all) fixed in pull request #2920. Please note that the NSXMLParser implementation in macOS (and probably iOS) also fails to support entities. I did not get NSXMLParser to ever call the func parser(XMLParser, foundIgnorableWhitespace: String) delegate callback. |
Don't think this is fixed on current
|
@swift-ci create |
|
Comment by Stefan Springer (JIRA) Note that the processing of entities is still in part problematic, see my little example Github repository https://github.com/stefanspringer1/SwiftXMLParserExamples and the following issues that I posted: https://bugs.swift.org/browse/SR-14581, https://bugs.swift.org/browse/SR-14582, https://bugs.swift.org/browse/SR-14583, https://bugs.swift.org/browse/SR-14584, https://bugs.swift.org/browse/SR-14585, https://bugs.swift.org/browse/SR-14586. |
Attachment: Download
Environment
Ubuntu 14.04
swift-3.0-PREVIEW-2
Additional Detail from JIRA
md5: 803674b2c85303d495af09f40e0e6338
Issue Description:
I'm attempting to implement an xml parser using (swift-3.0-PREVIEW-2) on Ubuntu. When compiling it requires all of the NSXMLParserDelegate functions to be implemented (they are optional on OSX) which I have implemented. However at run time none of the the delegate functions are called even though .parse() completes with no error. Ie this function never gets called during the parsing.
so I have been using swift-3.0-PREVIEW-2 on ubuntu.
I have included an example parser.
Note that the important delegate functions
are never called.
The text was updated successfully, but these errors were encountered: